registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

前端 未结 15 1733
时光说笑
时光说笑 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:28

    This is cleaner way I am doing and it just works great

    if (floor(NSFoundationVersionNumber) < NSFoundationVersionNumber_iOS_8_0)
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
         UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound];
         else {
             [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 
             [application registerForRemoteNotifications];
         }
    

提交回复
热议问题