Device token getting Nil
Asked Answered
A

1

9

I have a strange issue, Some of my users are returning blank (or null) device tokens for Apple Push Notification. It happening only some of user's only not for all user's,

Here's 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 device is Jail break that's why i getting nil device token ?

Update

For example First time user allowing push notification and it works properly,

Now user go to setting and disable the notification from setting's

Disable notification

Then after it i will not get device token that was fine but problem is now user uninstall the app,

Then after Download the app again then after didRegisterForRemoteNotificationsWithDeviceToken not called so i getting nil device token and when i check setting it will showing notification on

Astronomy answered 2/12, 2015 at 4:21 Comment(15)
No, they simply may not have granted the permission.Brooklime
@HarikrishnanT so it means if the device is jail break then device token not generated right ?Astronomy
If you need the device token, the user must provide permission to receive push notification. If they deny the permission, the device token will not be received. And when you try to access it from the defaultPreferances, it will return nullBrooklime
@HarikrishnanT yes i know this thing but user may have set ON the notification but not getting the device tokenAstronomy
you have provisional certificate in configure push notification?Rodrique
@Rohitsuvagiya yes its works properly this issue regarding Some of my users are returning blank (or null) not all ..Astronomy
@Mayank Patel please check internet connection at the time getting the device token , this also will be the reasonSpeos
No, look at the code - it's saving in an asynchronous background serviceDisparage
@MayankPatel did the method "didRegisterForRemoteNotificationsWithDeviceToken" gets a call or not??Speos
Post a picture of your Installation table from Parse ?Disparage
@Disparage i have updated question check itAstronomy
@Speos internet connection working perfectly check my updated questionAstronomy
So... why is any of that confusing? Wouldn't you expect to get a nil token in that case ?Disparage
@Disparage when i uninstall the app during notification is disable from setting now reinstall the app again and checking notification is on but didRegisterForRemoteNotificationsWithDeviceToken this method is not calledAstronomy
Seems there are a few other SO posts about it not being called on iOS 9.. Eg.: #33541729Disparage
S
3

In iOS8 I have deleted my app before that i turn OFF the notification,then i run my application did register is not called,then i again go to the settings and find that Allow notification is ON, but the "didRegisterForRemoteNotification" didn't get a call,

Then I turn "Allow notification" to OFF and again i turn it ON, then i come to my app I found the device token, But its working fine after that, but user have to turn it off by manually and again he has to turn it on, of course its a bug of apple,

It will work fine in iOS 9

Speos answered 2/12, 2015 at 7:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.