ios - Receive null device token sometimes -


i'm working on project allows user receive push notifications whenever there new on user account. i'm using parse push notifications service. i'm having no problem until our server starting receive empty token device on every push notification registration, problem not happening. when tried app on device run should when app tested on our client device , our server receive empty token device client user. how can happen? how can fix this? , how best practice , set device token?

here code in appdelegate:

- (void) application:(uiapplication *)application didregisterforremotenotificationswithdevicetoken:(nsdata *)devicetoken{ const unsigned *tokenbytes = [devicetoken bytes]; nsstring *token = [nsstring stringwithformat:@"%08x%08x%08x%08x%08x%08x%08x%08x",                             ntohl(tokenbytes[0]), ntohl(tokenbytes[1]), ntohl(tokenbytes[2]),                             ntohl(tokenbytes[3]), ntohl(tokenbytes[4]), ntohl(tokenbytes[5]),                             ntohl(tokenbytes[6]), ntohl(tokenbytes[7])];  //function saving device token server [[asengine defaultengine] setcurrentdevicetoken:token]; if([[asengine defaultengine] currentcredential] != nil) {     [[asengine defaultengine] webstoredevicetoken:token];  }  //save current instalation parse pfinstallation *currentinstallation = [pfinstallation currentinstallation]; [currentinstallation setdevicetokenfromdata:devicetoken]; [currentinstallation saveinbackgroundwithblock:^(bool succeeded, nserror *error) {     nslog(@"error e current installation: %@", error); }];  //save device token locally [[nsuserdefaults standarduserdefaults] setobject:devicetoken forkey:@"devicetoken"]; } 

an empty token wont ever generated, ios provides didfailtoregisterforremotenotificationswitherror method being called in case, please make sure check errors in token creation.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -