Are silent remote push notifications deprecated in iOS 11?
E

1

7

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.

Eggert answered 12/2, 2018 at 23:50 Comment(0)
P
7

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
Prodigal answered 13/2, 2018 at 1:34 Comment(2)
Thank you so much!! I don't know why the documentation doesn't redirect to that one.Eggert
Yeah that's weird. The deprecation info in UIApplication.h shows it though.Prodigal

© 2022 - 2024 — McMap. All rights reserved.