Title says it all… I am calling registerForRemoteNotificationTypes on every app launch. It worked brilliantly the first time. Got a device token, but all I did was NSLog it.
Now running the app again… neither the didRegister* nor didFail* callbacks are being executed. Nothing has changed in terms of my code/network.
Is this correct behavior? I am seeing conflicting answers here on StackOverflow. This SO answer implies that the didRegister* callback should occur every time. Some people say you should never cache the device token. Well, that’s fine… but I didn’t do anything with my token the first time I got one, so now it’s lost??? Normally of course the app should push the token up to my push notification server, but I’m just in the development phase here and didn’t do that. So now this token is lost and my app will not receive another? This seems odd given that Apple documentation says to call registerForRemoteNotificationTypes on every app start! What is the point of this if you don’t get back a new (or recycled) token each time? Or is there something else going on here?
didRegisterForRemoteNotificationsWithDeviceToken should execute every time.
My phone must have been in an odd state. I finally noticed that in Notifications Center, the app was listed, but there was no Badges, Alerts, or Sounds text below the app name. I edited the settings manually and enabled these notifications. Then the next time I ran the app, the didRegister callback was triggered.
Could not duplicate the bad state by disabling the alerts/badges/sounds. Still getting the callback every time. Going to chalk this up to a fluke.