Reputation: 36287
let types: UIUserNotificationType = [.alert, .sound, .badge, .none]
let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
or this code:
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() where settings.types != .None else {}
not sure how to make sense of it, obviously if you register for it, then you would have it among your settings types...
I've read here and here but can't figure it out. Couldn't find documentation on it either. Though, when I Command + Click on it says:
the application may not present any UI upon a notification being received
Is it used to signify that once the notification is received the user can do nothing? How is that something that we should register for?! What can go wrong if we don't register for this?
Upvotes: 0
Views: 202
Reputation: 535057
.none
is merely the zero option — neither .alert
nor .sound
nor .badge
. It is not an option so much as an absence of any of the options.
You wouldn't need to write code to register for .none
, obviously. But the user might configure things that way in Settings, completely turning off the ability for notifications to present alerts, add badges, or play sounds, and you need a way to be told this and to check for it.
Note, by the way, that .none
(the zero option) is not imported by name in Swift 3; it corresponds merely to the empty set []
. (And in any case UIUserNotificationType is deprecated in iOS 10.)
Upvotes: 1