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

标签 ios cocoa-touch uilocalnotification

我有一个 UILocalNotification,但我不想将其设置为使用默认铃声。我使用了AudioToolbox.framework,通过引用这个库我有一个SystemSoundID:https://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为此。

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

关于ios - 通过 soundID 获取 soundName 将其分配给 UILocalNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35784633/

相关文章:

ios - 本地化导航栏中的默认后退按钮

iphone - MapKit 支持 Google 街景吗

iphone - 发件人标签总是返回 1

iphone - ScheduleLocalNotification 不适用于越狱应用程序?

ios - 什么是 UserNotification 框架相当于 didReceive 通知 : UILocalNotification?

ios - MFI Apple 计划/认证

javascript - 使用 React Native 在 Android/iOS 上使用不同的 lineHeight

ios - 如何在 SceneKit Editor 中使模型的枢轴点居中

objective-c - 将 UIImage 转换为 NSData

android - ios 闹钟功能受限?