![](/img/trans.png)
[英]didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios 9
[英]didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios8
我知道這個問題以前已經問過了,也有一些解決方案,我嘗試了所有可用的解決方案,但沒有任何工作對我有用。 代碼在我這方面運行良好,但是當我提交App Store時,他們拒絕了它(到現在為止,我收到App Store的3次拒絕)。
我嘗試以下鏈接中的代碼:
為什么不調用registerForRemoteNotificationsWithDeviceToken
https://developer.apple.com/library/ios/technotes/tn2265/_index.html
我還檢查了臨時配置文件和證書,它們都很好。
有人請幫忙
推送通知注冊過程已在iOS 8中更改,請確保已添加
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
我用這種方式。 我沒有從應用商店得到任何問題。
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}
#endif
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier
forRemoteNotification:(NSDictionary *)notification completionHandler:(void(^)())completionHandler
{
NSLog(@"Received push notification: %@, identifier: %@", notification, identifier); // iOS 8 s
completionHandler();
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken
{
NSString *newToken = [devToken description];
newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"NotificationToken: %@",newToken);
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSLog(@"Error while registering for notifications: %@", error);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.