Device Token Receiving Nil

I have a strange problem. Some of my users return empty (or zero) device tokens for Apple Push Notification . This happens only to some users, but not to all users,

Here is my code,

 - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { #if !TARGET_IPHONE_SIMULATOR [_globalKRData setPreferences:deviceToken withKey:kPushToken]; // Preferences PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation setDeviceTokenFromData:deviceToken]; currentInstallation.channels = @[@"global"]; [currentInstallation saveInBackground]; #endif } 

Is it possible if the device is Jail break , why do I get the token of the nil device?

Refresh

For example, the first user to enable push notification and work correctly,

Now the user will go to the settings and disable the notification from the settings

Disable Notification

Then after that I won’t get the device token , it was fine, but the problem now turned off the application,

Then after downloading the application again, after didRegisterForRemoteNotificationsWithDeviceToken not called, so I get a device token zero, and when I check the setting, it will show a notification

+8
ios objective-c ios9 apple-push-notifications
source share
1 answer

In iOS8, I deleted my application before I turned off the notification, then I started the application and the register was not called, then I go back to settings and find that Allow notification is ON , but didRegisterForRemoteNotification did not receive the call.

Then I turn β€œ Allow notification ” to OFF , and again I turn it ON , then I come to my application. I found the device a token, but after that it works fine, but the user must turn it off manually, and again it must turn it on, of course its a bug of apple ,

It works great in iOS 9

+3
source share

All Articles