1

i was registered for apns service. i am getting device token, i want to send it to my server.if already this this device id exists in my server i don't want to send it again.

      - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
    {
         NSLog(@"My token is: %@", deviceToken);//so from here i want to send my   token to server using service.if got same device token when user runs app in the same phone i will

          get device id,i want to send it only at first time if it is same phone 
     }

how to proceed thank you

Eran
  • 387,369
  • 54
  • 702
  • 768
siva
  • 251
  • 2
  • 16

1 Answers1

1

You can store it locally on your phone. If the device token you get in didRegisterForRemoteNotificationsWithDeviceToken is equal to the locally stored one, you don't send it to your server. If you don't have a locally stored device token, or the locally stored token is different from the newly received one, send it to your server and update the locally stored token.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • how to store that one in iphone app – siva Jul 13 '13 at 11:54
  • shall i use NSUSERDEFAULTS ? – siva Jul 15 '13 at 05:09
  • thankyou for help,still one doubt if user deleted the app after some days – siva Jul 16 '13 at 10:51
  • @siva If a user deletes the app, your server won't know about it immediately, but after you try to send a few push notifications to that device, the APNS service will detect the app is no longer installed on it, and the next time you run the Feedback service, the device token of that device will be returned (and you'll know you should remove that token from your DB). – Eran Jul 16 '13 at 21:42
  • thank you very much for your help,let me know how apple send that device token if user deletes – siva Jul 17 '13 at 04:46
  • @siva You can read about the Feedback Service [here](http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW3) – Eran Jul 17 '13 at 14:50