4
我正在檢查以確保用戶已授權警報和徽章。一旦得到它,我就會遇到一個問題,想知道如何處理當前的設置。檢查通知設置iOS8
let settings = UIApplication.sharedApplication().currentUserNotificationSettings()
println(settings)
// Prints - <UIUserNotificationSettings: 0x7fd0a268bca0; types: (UIUserNotificationTypeAlert UIUserNotificationTypeBadge UIUserNotificationTypeSound);>
if settings.types == UIUserNotificationType.Alert // NOPE - this is the line that needs an update
{
println("Yes, they have authorized Alert")
}
else
{
println("No, they have not authorized Alert. Explain to them how to set it.")
}
謝謝。奇蹟般有效。 – ShadowDES 2014-10-04 23:52:25
不幸的是,從Swift 2開始,這不起作用:/ – cph2117 2015-11-05 20:33:41