There are many third party push notification providers like Appboy (Braze), Localytics, Urban Airship, etc. Our app is in production using "Provider A" but we are switching to "Provider B." Fresh installations get push notifications, but upgrade installations do not. Upon inspection it looks like didRegisterForRemoteNotificationsWithDeviceToken
isn't called. How can push be enabled without having to re-prompt the user?
Asked
Active
Viewed 351 times
0

AtomicBoolean
- 1,070
- 13
- 19
1 Answers
1
It is enough to call registerForRemoteNotifications
in didFinishLaunchingWithOptions
. It will trigger didRegisterForRemoteNotificationsWithDeviceToken
or didFailToRegisterForRemoteNotificationsWithError
callback if they've opted-in. The best part is that the callbacks are triggered if they opt-in sometime in the future (Assuming they've been prompted in-app at least once via registerUserNotificationSettings
).
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//...
UIApplication.shared.registerForRemoteNotifications()
//...
}
See: iOS 8 Remote notifications - When should I call registerForRemoteNotifications()?

AtomicBoolean
- 1,070
- 13
- 19
-
what do you mean by `didRegisterForRemoteNotificationsWithDeviceToken` is successfully called? – mfaani Mar 13 '18 at 15:09
-
1AFAIK `registerForRemoteNotifications` never prompts the user. See [here](https://stackoverflow.com/questions/42275060/what-is-difference-between-remote-notification-and-silent-notification-in-ios/42302369#42302369) and look for "Registering does NOT require user permission" – mfaani Mar 13 '18 at 15:44