Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Call registerForPushNotifications every time app launches?

According to Apple, "an application should register every time it launches and give its provider the current token."

"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."

URL:
https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/IPhoneOSClientImp/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1

From this, I assume we should be calling Ti.Network.registerForPushNotifications EVERY TIME the app launches, correct? If the device has registered previously, the call will simply return the deviceToken without issuing another request to register with Apple, so executing this code every time on app launch won't add much overhead.

Also, if my push notifications only contain a badge number and alert message, should I be registering for the type Titanium.Network.NOTIFICATION_TYPE_SOUND? Or should that only be used if I have a custom sound embedded in my bundle that I want played when a notification is received?

— asked November 16th 2010 by Slim McKinsley
  • devicetoken
  • registerforpushnotifications
2 Comments
  • Did you ever receive an answer for this? I got the exact same question.

    — commented July 3rd 2011 by Petter Palander
  • http://developer.appcelerator.com/question/127498/registerforpushnotifications-at-every-startup-

    — commented September 23rd 2012 by Nir Weber

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.