Two possibilities
One
You missed below code for iOS 8 and above
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
NSLog(@"ios8 app");
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
NSLog(@"lower ios8 app");
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
}
OR
Two
User click Don't allow for Push
Edit 1
If this is happening with some users, then those users iPhone are Jailbroken. Make sure who get device token as null are not Jailbroken
Edit 2
To check if jailbroken or not
NSString *path = @"/Applications/Cydia.app";
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:path];
if (fileExists) {
//device is jailbroken
} else {
//device is not jailbroken
}
Reference
OR
NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *info = [bundle infoDictionary];
if ([info objectForKey: @"SignerIdentity"] != nil)
{
/* do something */
}
Reference