【发布时间】:2016-07-30 12:59:21
【问题描述】:
我正在使用 CloudKit 中的推送通知。这是我在 Swift 3 之前使用的:
notification.soundName = UILocalNotificationDefaultSoundName
(通知是CKNotificationInfo)
但是,这给了我一个警告:
“UILocalNotificationDefaultSoundName”在 iOS 10.0 中已弃用:使用 UserNotifications Framework 的 +[UNNotificationSound defaultSound]
所以我将 UserNotification 框架添加到我的 Xcode 项目中,并将它导入到我的 ViewController 中。然后我尝试了这个:
notification.soundName = UNNotificationSound.default()
但是,这给了我一个错误:
无法将“UNNotificationSound”类型的值分配给“String”类型的值?
所以默认声音是UNNotificationSound,但我需要声音名称。如何从声音中获取声音名称?谢谢!
【问题讨论】:
标签: ios swift audio push-notification swift3