iOS 8 enabled device not receiving PUSH notifications after code update

后端 未结 8 2499
陌清茗
陌清茗 2020-11-27 03:45

I recently upgraded one of my test iphones to iOS 8 and then upgraded the PUSH registration code as below (using xCode 6)

-(BOOL)hasNotificationsEnabled {

          


        
8条回答
  •  长情又很酷
    2020-11-27 03:53

    I tried to get the type information of the settings object and found out that the types property is basically a bitmask. Here is how you can extract the informations.

    My example is in Swift and >= iOS 8.0 though.

        let settings = UIApplication.sharedApplication().currentUserNotificationSettings()
    
        if settings.types.rawValue & UIUserNotificationType.Alert.rawValue == UIUserNotificationType.Alert.rawValue
        {
           // can receive alert!
        }
        else
        {
           // if the user is not even able to receive alerts, show him a hint on how to reenable notifications in system settings
        }
    
        if settings.types.rawValue & UIUserNotificationType.Badge.rawValue == UIUserNotificationType.Badge.rawValue
        {
            // can receive badge!
        }
        if settings.types.rawValue & UIUserNotificationType.Sound.rawValue == UIUserNotificationType.Sound.rawValue
        {
            // can receive sound!
        }
    

提交回复
热议问题