通过soundID获取soundName以将其分配给UILocalNotification

时间:2015-04-18 20:03:00

标签: ios cocoa-touch uilocalnotification

我有UILocalNotification,我不想将其设置为使用默认音调。我使用过AudioToolbox.framework,并且我引用了这个库SystemSoundIDhttps://github.com/TUNER88/iOSSystemSoundsLibrary

但是UILocalNotification需要一个合理的名称。如何从SystemSoundID获取名称?

1 个答案:

答案 0 :(得分:3)

soundName in UILocalNotification Class Reference提及

的说明
  

对于此属性,请指定a的文件名(包括扩展名)   应用程序主要包中的声音资源或   UILocalNotificationDefaultSoundName请求默认系统   声音。

因此,如果您希望默认的本地通知声音使用UILocalNotificationDefaultSoundName

此外,来自Multimedia Programming Guide

的说明
  

注意:系统提供的警报声和系统提供的用户界面   您的应用程序无法使用声音效果。

因此,您无法使用iOSSystemSoundsLibrary中找到的任何系统声音ID。

如果您想要自定义声音,则必须提供自己的声音。