我有一個奇怪的問題,我無法自行復制。我的一些用戶正在爲Apple推送通知返回空白(或空)設備令牌。它可能發生在5%的用戶身上。 任何人都有同樣的問題或知道這件事。設備令牌NULL
我爲獲得設備令牌代碼是:
- (void)application: (UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken: (NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
NSString* tokenString = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""] ;
NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
[def setObject:tokenString forKey:@"deviceToken"];
}
- (void)application: (UIApplication*)application didFailToRegisterForRemoteNotificationsWithError: (NSError*)error
{
NSLog(@"Failed to get token, error: %@", error) ;
}
順便說一句,我得到了答案。那些用戶正在使用越獄手機:) – 2014-09-05 07:19:30
@ArsalanHaider我的答案依然存在;您沒有希望使用您的代碼重新創建設備令牌。 – trojanfoe 2014-09-05 07:24:01