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

Get the soundName by soundID to assign it to a UILocalNotification

我有一个 UILocalNotification,我不想将它设置为使用默认音调。我用过AudioToolbox.framework,参考这个库有一个SystemSoundIDhttps://github.com/TUNER88/iOSSystemSoundsLibrary

但是UILocalNotification需要一个声音名字。如何从 SystemSoundID?

中获取名称

soundName in UILocalNotification Class Reference 次提及的描述

For this property, specify the filename (including extension) of a sound resource in the app’s main bundle or UILocalNotificationDefaultSoundName to request the default system sound.

因此,如果您想要默认的本地通知声音,请使用 UILocalNotificationDefaultSoundName

此外,来自 Multimedia Programming Guide

的注释

Note: System-supplied alert sounds and system-supplied user-interface sound effects are not available to your application.

所以你不能使用你在iOSSystemSoundsLibrary中找到的任何系统声音ID。

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