我正在使用Swift for iOS8編寫我的應用程序。iOS8 - UILocalNotification,稍後再從代碼中檢查權限
我想使用UILocalNotification通知用戶一些事情。爲此,我已經通過此應用程序發佈請求了許可:
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil))
確認框顯示要求許可。如果用戶允許,則沒有問題。
如果用戶沒有給予權限,我該如何檢查本地通知是否從代碼啓用(以編程方式)?
'notification.soundName'從哪裏來?沒有這個,這是有效的。謝謝。 – MKatleast3 2015-01-05 08:59:04
@ MKatleast3 - 哦,謝謝你,我忘了添加一個UILocalNotification變量。在我的功能中有更多的線條 - 我建議你準確地配置你的通知。 「if」框對我的解決方案非常重要。 – kurtanamo 2015-01-05 12:29:51
不錯,thx!使用Swift 3,考慮使用--- if(currentSettings?.types.contains(required))! ---代替現在在2個UIUserNotificationType成員之間棄用的&運算符 – GrayFox 2016-11-10 09:45:34