Search code examples
swiftapple-push-notificationsunusernotificationcentercksubscriptionsilent-notification

Are silent remote push notifications deprecated in iOS 11?


Currently I'm able to receive silent push using app delegate's didReceiveRemoteNotification method.

That method is deprecated and according to this we're supposed to be switching to UNUserNotificationCenter's willPresent method, but I can't seem to get it to work for silent push. Since there's no notification to present in a silent push, it would be counterintuitive if that did work, to say the least.

Have read registering for push Xcode 8, CKSub w/out notification, and plenty others but everything keeps coming back to the deprecated method.

Is there an alternative we're supposed to be using for silent push (which is not a user facing notification, but in this case it's a CKQuerySubscription report that triggers background activity)? Or should willPresent work for silent pushes (in which case I've missed a part of the config...)?

Thanks in advance.


Solution

  • Use this

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler
    

    or for Swift

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    
    }
    

    The deprecated one is

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo