Get device token for push notifications after app was deleted

后端 未结 2 1520
灰色年华
灰色年华 2020-12-30 13:06

When you install an app for the first time and want to register for Push notifications, the app asks you whether you want to receive alerts or not. This is being permanently

相关标签:
2条回答
  • 2020-12-30 13:13

    From Push Notification Programming Guide

    An application should register every time it launches and give its provider the current token. It calls the registerForRemoteNotificationTypes: method to kick off the registration process.

    By requesting the device token and passing it to the provider every time your application launches, you help to ensure that the provider has the current token for the device. If a user restores a backup to a device or computer other than the one that the backup was created for (for example, the user migrates data to a new device or computer), he or she must launch the application at least once for it to receive notifications again. If the user restores backup data to a new device or computer, or reinstalls the operating system, the device token changes. Moreover, never cache a device token and give that to your provider; always get the token from the system whenever you need it. If your application has previously registered, calling registerForRemoteNotificationTypes: results in the operating system passing the device token to the delegate immediately without incurring additional overhead.

    To answer your question: Call registerForRemoteNotificationTypes: on every launch, and use the latest token.

    0 讨论(0)
  • 2020-12-30 13:17

    call registerForRemoteNotificationTypes on every launch of your application so your didRegisterForRemoteNotificationsWithDeviceToken method get call and you will get your device token every time from APNS. And device token for your application is same on every launch.

    0 讨论(0)
提交回复
热议问题