简体   繁体   中英

didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios8

I know this question already asked previously and also have some solution for it,i tried all the solution available ,but nothing is working for me. Code is working perfectly on my side but when i submit the App store they reject it (till now i got 3 rejections from App store).

I try the the code from the following link:-

why didRegisterForRemoteNotificationsWithDeviceToken is not called

Get Device Token in iOS 8

https://developer.apple.com/library/ios/technotes/tn2265/_index.html

I also check provisional profile and certificates they all are fine.

Anyone please help

Push notification registration process has been changed in iOS 8, Make sure you have added this

 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
    {
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

        [[UIApplication sharedApplication] registerForRemoteNotifications];

}

I have used this way. I didn't get any issue from app store.

#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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM