Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

didRegisterForRemoteNotificationsWithDeviceToken - Push Notifications

I just wanted to confirm "didRegisterForRemoteNotificationsWithDeviceToken" is meant to be called everytime the application loads and my PHP server or application needs to deal with whether or not to resubmit to store in my database? Or is there something I am missing?

Thanks James

like image 291
jodm Avatar asked Dec 04 '22 09:12

jodm


1 Answers

First, you are not meant to call this method directly. Rather, you should call registerForRemoteNotificationTypes: on every launch of your app which then in turn calls application:didRegisterForRemoteNotificationsWithDeviceToken: which you must implement.

Second, yes, you are supposed to resubmit the token to your server every time. From the documentation:

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 other than the one that the backup was created for (for example, the user migrates data to a new device), 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 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 iOS passing the device token to the delegate immediately without incurring additional overhead.

like image 54
Ole Begemann Avatar answered Dec 25 '22 11:12

Ole Begemann