如何判斷消息提醒是否開啓

由於不同的系統api 的調用是不一樣的,
在ios8中我們要用currentUserNotificationSettings
而在8以下我們要用enabledRemoteNotificationTypes
首先我們要判斷:

var isIos8 =  UIDevice.currentDevice().systemVersion > "8.0"
        if isIos8{
         let notificationSettings: UIUserNotificationSettings! = UIApplication.sharedApplication().currentUserNotificationSettings()
        if notificationSettings.types == UIUserNotificationType.None {
             println("未開啓") 
        }else{
         println( "已開啓") 
        }
        }else{
            if UIApplication.sharedApplication().enabledRemoteNotificationTypes() == UIRemoteNotificationType.None{
                 println("未開啓") 
            }else{
              println( "已開啓") 
            }
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章