title: Not receiving Push Notifications from CloudKit Subscriptions
body: <p>I'm not receiving Push Notifications I expect from <code>CloudKit</code> Subscriptions. </p>
  
  <p>Here's what I've done so far:</p>
  
  <ul>
  <li>Enabled the <code>CloudKit</code> and Remote Notifications capabilities.</li>
  <li>Created a 'Test' Record Type using the CloudKit dashboard.</li>
  <li>Created a subscription for the appropriate record type (Test), which
  I can see in the CloudKit dashboard.</li>
  <li>Use a physical device to test, which is signed in to <code>iCloud</code> and
  connected to the internet.</li>
  <li>Set up the app delegate to receive notifications.</li>
  <li>Manually Inserted/Updated/Deleted records via the <code>CloudKit</code> portal.</li>
  </ul>
  
  <p>Unfortunately I never receive any push notifications, ever. The code involved is shown below. Literally, this is the only code in a brand new blank project.</p>
  
  <pre><code>    // MARK: - SUBSCRIPTIONS
  func subscribeToRecordChangesWithRecordType (recordType:String, database:CKDatabase) {
  
      let predicate = NSPredicate(value: true)
      let subscription = CKSubscription(recordType: recordType, predicate: predicate, options: CKSubscriptionOptions.FiresOnRecordCreation|CKSubscriptionOptions.FiresOnRecordDeletion|CKSubscriptionOptions.FiresOnRecordUpdate)
  
      database.saveSubscription(subscription, completionHandler: { (savedSubscription, error) -&gt; Void in
          if let _error = error {
              NSLog("ERROR saving '%@' subscription %@",recordType, _error)
          } else {
              NSLog("SUCCESS creating '%@' subscription: %@", recordType, savedSubscription)
          }
      })
  }
  func createSubscriptions () {
      let privateDB = CKContainer.defaultContainer().privateCloudDatabase
      let publicDB = CKContainer.defaultContainer().publicCloudDatabase
  
  
      // NOTE: create a Record Type called 'Test' in the CloudKit dashboard
      self.subscribeToRecordChangesWithRecordType("Test", database: privateDB)
      self.subscribeToRecordChangesWithRecordType("Test", database: publicDB)
  }
  
  // MARK: - PUSH NOTIFICATIONS
  func registerForPushNotifications (application: UIApplication) {
      self.createSubscriptions()
      let settings = UIUserNotificationSettings(forTypes: .Alert, categories: nil)
      application.registerUserNotificationSettings(settings)
      application.registerForRemoteNotifications()
  }
  func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
      NSLog("Registered for Push Notifications with token: %@", deviceToken);
  }
  func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
      NSLog("FAILED to register for Push Notifications. %@", error)
  }
  func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
      NSLog("RECEIVED Push Notification")
      NSNotificationCenter.defaultCenter().postNotificationName("PushNotificationReceived", object: userInfo)
  }
  func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
      NSLog("RECEIVED LOCAL Push Notification")
  }
  func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -&gt; Void) {
  
      NSLog("RECEIVED Push Notification with fetchCompletionHandler")
      NSNotificationCenter.defaultCenter().postNotificationName("PushNotificationReceived", object: userInfo)
  }
  
  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
  
      self.registerForPushNotifications(application)
      return true
  }
  </code></pre>
  
  <p>Thanks in advance for any tips or suggestions. I hope this isn't a bug and that I'm doing something wrong here ... it should 'just work'!</p>
  
  <p>Cheers</p>