I wrote an iPad app which recieves remote push notifications through apns. The app revieves notifications and handles them correctly.
In AppDelegate.m i call:
registerForRemoteNotificationTypes:
and also i have the:
application: didRegisterForRemoteNotificationsWithDeviceToken:
set and all works like a charm.
Within the delegate i construct a url pointing to a registration script on the server. The Delegate is called, and this leads to a url being called registering the device etc. in my server application for sending push notification to.
BUT !! If the user starts the App for the first time, he has no credentials set so far. The App registers for recieving remote notifications, but i have not "key" telling me which user belongs to which device on my server.
I thought about calling the registration-URL later (after setting the credentials in App), but then i need the DeviceToken available, which i don't have outside the delegate
didRegisterForRemoteNotificationsWithDeviceToken:
How could i solve this? I have to send the deviceToken AND the username to my server to be able to send the notifications to the USER later ...
Hopefully this wrecking description is understandable :)
Any Help is appreciated...
You want your DeviceToken to be accessible outside of your app delegate it sounds like. This should help with your issue:How to use the device token in method other than didRegisterForRemoteNotificationsWithDeviceToken?