registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later

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

    Swift 2.0

    // Checking if app is running iOS 8
        if application.respondsToSelector("isRegisteredForRemoteNotifications") {
    
            print("registerApplicationForPushNotifications - iOS 8")
    
            application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil));
            application.registerForRemoteNotifications()
    
        } else {
            // Register for Push Notifications before iOS 8
            print("registerApplicationForPushNotifications - 

提交回复
热议问题