Question

I have to get device Token from Apple Push Notification Server in static library.

That means user do not have to implement didRegisterForRemoteNotificationsWithDeviceToken method in AppDelegate, i have to handle it my self, and get device token.

  • Does it possible to get device token else where in program ?

  • Is there any method that will notify me when device token is generated ?

Because i have to register device token after user logged-in. So I have implemented my code such that

  1. didRegisterForRemoteNotificationsWithDeviceToken i am calling static library method to save device token ( That will save device token in NSUSerDefault )

  2. After user logged-in i am sending device token to Server for adding that device token in Database.

I do not have to save device Token and then register, i have to generate device token one time when user log in and send it to server.

So, Does it possible ?

Thanks & Regards, Abbas Mulani

Was it helpful?

Solution

didRegisterForRemoteNotificationsWithDeviceToken is the only way to get the device token from Apple after registering for push notifications (by calling registerForRemoteNotificationTypes:). This method can pass the device token to where ever you need it, or store it in some persistent store (such as NSUSerDefault), so that it can be accessed by who ever needs it.

If you want to get the device token form Apple only when the user logs in, you should call registerForRemoteNotificationTypes: only when the user logs in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top