如何在不重新提示启用推送通知的情况下切换推送通知提供程序?

时间:2017-10-18 17:00:59

标签: ios apple-push-notifications remote-notifications

有许多第三方推送通知提供商,如Appboy(Braze),Localytics,Urban Airship等。我们的应用程序正在使用“提供商A”进行生产,但我们正在切换到“提供商B”。全新安装会获得推送通知,但升级安装则不会。检查后,看起来didRegisterForRemoteNotificationsWithDeviceToken未被调用。如何在不必重新提示用户的情况下启用推送?

1 个答案:

答案 0 :(得分:1)

registerForRemoteNotifications中拨打didFinishLaunchingWithOptions即可。如果他们选择加入,它会触发didRegisterForRemoteNotificationsWithDeviceTokendidFailToRegisterForRemoteNotificationsWithError回调。最好的部分是,如果回调在将来的某个时间选择加入,则会触发回调(假设它们已经通过registerUserNotificationSettings至少一次在应用程序中被提示)。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    //...
        UIApplication.shared.registerForRemoteNotifications()
    //...
}

请参阅: iOS 8 Remote notifications - When should I call registerForRemoteNotifications()?