未通知声音不起作用 [英] UNNotificationSound doesn't work
本文介绍了未通知声音不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
新iOS10用户通知框架的自定义声音不起作用。 相同的文件适用于旧的UILocalNotify,但现在总是播放默认的系统声音。当我设置为nil时,我没有声音,因此只使用名称初始化是有问题的
let notificationContent = UNMutableNotificationContent()
notificationContent.title = "XYZ"
notificationContent.body = "XYZ"
notificationContent.sound = UNNotificationSound(named: "sound_name.aif")
推荐答案
我更改了此行:
notificationContent.sound = UNNotificationSound(named: "sound_name.aiff")
收件人:
notificationContent.sound = UNNotificationSound.init(named: "sound_name.aiff")
如您所见,我将声音转换为*.aiff
,在阅读API参考后,我将声音文件移动到一个名为Sound的文件夹中。
并且我确保我的声音文件在30秒内
这篇关于未通知声音不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文