由于不同的系统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( "已开启")
}
}