registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

前端 未结 15 1731
时光说笑
时光说笑 2020-11-29 15:09

When trying to register for push notifications under iOS 8.x:

application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotific         


        
15条回答
  •  半阙折子戏
    2020-11-29 15:12

    I couldn't figure out what the "categories" NSSet variable should be set to, so if someone could fill me in I will gladly edit this post. The following does, however, bring up the push notification dialog.

    [[UIApplication sharedApplication] registerForRemoteNotifications];
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    

    Edit: I got a push notification to send to my phone with this code, so I'm not sure the categories parameter is necessary.

提交回复
热议问题