0
votes

I had to change the APNS provider and of course I generated new certificates for the new provider.

Things are going well if the device under APNS registration is new to Apple

The issue happen when I have an already, from Apple point of view, registered device because the callback method: - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

is not called and I'm unable to register the token with the new provider.

I'm looking a solution to reset all tokens that Apple knows in that way each device will be managed as new and didRegisterForRemoteNotificationsWithDeviceToken is finally called (with the previous original token does not matter)

Can anybody tell me if this is possible or how to workaround the issue ?

Thanks

Dario

1

1 Answers

0
votes

The issue was related to my code. This question can be deleted. Thanks

Reply for Sofie

Hi Sofie, it was an very old issue and I try to remember.

Probably we were at iOS8 timeā€¦ and ,as you read, I made a mistake in my code.

When I received a token registration from Apple (didRegisterForRemoteNotificationsWithDevice) I was storing the value in UsersDefaults using a function similar to your handleNewDeviceToken:deviceToken

In that function, to avoid useless network activity, I was calling the APN service provider - at that time UrbanAirShip - only if the token received was different from the token already stored in UserDefaults (that was my mistake!)

For different reasons I had to change the service provider passing from UrbanAirship to Parse.

Checking for a correct migration I discovered that only the new devices were able to register in the (new service provider) database but of course, at the end of the investigation, it was normal because the old devices did not call the service provider registration because the token stored in users defaults was already present (so already registered in the "old" service provider database)

In effect the function didRegisterForRemoteNotificationsWithDevice was always called of course only at the launch of the applicationā€¦.

I removed the token comparison with userDefaults registering everytime the token with the service provider and rebuilding the "new" database.

I hope to have been clear and of course I hope that helps you .

Dario