通知中使用的 none 大小写在哪里?
where is the none case used in notifications?
let types: UIUserNotificationType = [.alert, .sound, .badge, .none]
let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
或this代码:
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() where settings.types != .None else {}
不确定如何理解它,显然,如果您注册了它,那么您将在您的 设置 类型中找到它...
我已阅读 here and here 但无法理解。也找不到相关文档。虽然,当我命令 + 单击它时说:
the application may not present any UI upon a notification being received
是不是表示一旦收到通知,用户就什么都不能做了?那是我们应该注册的东西吗?!如果我们不为此注册会出什么问题?
.none
只是零选项——既不是 .alert
也不是 .sound
也不是 .badge
。它不是一个选项,而是缺少任何选项。
显然,您 不需要为 .none
编写代码 register。但是用户可能会在设置中配置东西,完全关闭通知显示警报、添加徽章或播放声音的能力,并且您需要一种方式来了解这一点并进行检查。
请注意,顺便说一句,.none
(零选项)在Swift 3 中不是按名称导入的;它仅对应于空集 []
。 (无论如何,UIUserNotificationType 在 iOS 10 中已被弃用。)
let types: UIUserNotificationType = [.alert, .sound, .badge, .none]
let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
application.registerUserNotificationSettings(settings)
或this代码:
guard let settings = UIApplication.sharedApplication().currentUserNotificationSettings() where settings.types != .None else {}
不确定如何理解它,显然,如果您注册了它,那么您将在您的 设置 类型中找到它...
我已阅读 here and here 但无法理解。也找不到相关文档。虽然,当我命令 + 单击它时说:
the application may not present any UI upon a notification being received
是不是表示一旦收到通知,用户就什么都不能做了?那是我们应该注册的东西吗?!如果我们不为此注册会出什么问题?
.none
只是零选项——既不是 .alert
也不是 .sound
也不是 .badge
。它不是一个选项,而是缺少任何选项。
您 不需要为 .none
编写代码 register。但是用户可能会在设置中配置东西,完全关闭通知显示警报、添加徽章或播放声音的能力,并且您需要一种方式来了解这一点并进行检查。
请注意,顺便说一句,.none
(零选项)在Swift 3 中不是按名称导入的;它仅对应于空集 []
。 (无论如何,UIUserNotificationType 在 iOS 10 中已被弃用。)