Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve already aquired push notification token

We are working on an app that is suposed to receive push notifications. On our test device when we were prompted for an ok to send notifications we clicked ok but failed to store the token that we received. (The request to the server on our end was not handled properly and the token was not stored anywhere else by us).

We have tried the following to have the function didRegisterForRemoteNotificationsWithDeviceToken trigger again (to no avail):

  • Completely remove the app and reinstall
  • Turn off notifications for our app in the iPhone settings

However, we cant get it to 'prompt' us again, and the APN development server seems to have already registered so I am assuming that is why the didRegisterForRemoteNotificationsWithDeviceToken doesnt trigger again.

In the end we cannot get a new token, and I don't know how to retrieve the already registered token. Does anyone know how to retrieve the already registered token?

like image 258
ophychius Avatar asked Dec 12 '11 12:12

ophychius


1 Answers

  1. if you call registerForRemoteNotificationTypes: method of UIApplication every time your application launch, the application:didRegisterForRemoteNotificationsWithDeviceToken: delegate method will be called every time also. When the first time registration, iOS will ask user if they want receive notifications, and iOS connect the Apple Notification Service to register and get device token. After that, registerForRemoteNotificationTypes: method call will neither ask user nor connect APN, iOS will immediately call delegate method with the already registered token.

  2. if you want to the Application launching to ask user again, call the unregisterForRemoteNotifications , then call registerForRemoteNotificationTypes: method again.

some detail information related: iOS Application Client Side Device Token Management With Apple Push Notification

like image 184
Wubao Li Avatar answered Sep 19 '22 07:09

Wubao Li