如何从解析中注册通知以获取声音和警报? (在斯威夫特)
Posted
技术标签:
【中文标题】如何从解析中注册通知以获取声音和警报? (在斯威夫特)【英文标题】:How to register notifications from parse for sound and alerts? (in Swift) 【发布时间】:2015-03-26 21:38:27 【问题描述】:我正在使用解析通知,但我希望通知发出警报和声音。我现在有这个:
var pushSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: .Alert, categories: nil)
但是我如何也注册 .sound?在 Objective-C 中,显然是这样的:
// Let device know you're going to be sending one of these types of notifications.
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
但是,我对 Swift 很陌生,我真的不知道如何在 Swift 中使用它!
提前致谢!
【问题讨论】:
【参考方案1】:这应该可以...
let pushSettings = UIUserNotificationSettings(forTypes: .Alert | .Badge | .Sound, categories: nil)
【讨论】:
以上是关于如何从解析中注册通知以获取声音和警报? (在斯威夫特)的主要内容,如果未能解决你的问题,请参考以下文章