I'm trying to get silent push from CloudKit. But it only works when my app in foreground (OR when its launched from Xcode, in that case notifications are delivered in background too).
I've enabled all corresponding Background Modes.
Registered for remoteNotifications and specified background fetchInterval in didFinishLaunchingWithOptions
UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
application.registerForRemoteNotifications()
I'm getting didRegisterForRemoteNotificationsWithDeviceToken no problems here.
I've implemented method for handling remoteNotifications:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
NSLog(__FUNCTION__)
let identifier : UIBackgroundTaskIdentifier = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler(){
}
CoreDataStack.sharedInstance.ensemblesSynchronizeWithCompletion(){
UIApplication.sharedApplication().endBackgroundTask(identifier)
completionHandler(UIBackgroundFetchResult.NewData)
}
}
I've tried switching CloudKit container to Production and testing with TestFlight. There results are always the same : In the foreground I'm getting CKNotifications,but for background in console I see this:
Error: apsd[81] : Silent Push: Deny app not available
Additionally I've tried: Changing container completely - no luck.
I've also edited my AppID accordingly, but I don't think its necessary for CloudKit notifications (or is it?) :
in Settings everything is enabled :
Console output when started from device (not from Xcode)
App running background :
When started from Xcode I get notification in background & foreground.