didRegisterForRemoteNotificationsWithDeviceToken is not called up in ios 9

前端 未结 3 1057
旧巷少年郎
旧巷少年郎 2020-12-11 20:30

I have to implement APNS in my project, I have created APNS SSL in developer portal, and using this i have created new pro

相关标签:
3条回答
  • 2020-12-11 21:17

    Try with this one.

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
    
        UIUserNotificationType types = UIUserNotificationTypeBadge |
        UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
    
        UIUserNotificationSettings *mySettings =
        [UIUserNotificationSettings settingsForTypes:types categories:nil];
    
        [application registerUserNotificationSettings:mySettings];
        [application registerForRemoteNotifications];
    
    
    }else{
        [application registerForRemoteNotificationTypes:
         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
    }
    
    0 讨论(0)
  • 2020-12-11 21:21

    I think you forget your didRegisterUserNotificationSettings method so:

    - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
        if (notificationSettings.types != UIUserNotificationTypeNone) {
            NSLog(@"didRegisterUser is called");
            [application registerForRemoteNotifications];
        }
    }
    

    at the same place check the following scenario also.

    • try in another device once
    0 讨论(0)
  • 2020-12-11 21:24

    in ios 9 you need to required only if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; [[UIApplication sharedApplication] registerForRemoteNotifications]; }

    an other changes is

    1. select Project->General set team
    2. go capabilities and turn on Push notification.
    0 讨论(0)
提交回复
热议问题