我想从
播放UILocalNotificationDefaultSoundNamealert.soundName = UILocalNotificationDefaultSoundName;
with:
NSURL *soundFileURLRef = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"wav"]];
OSStatus oStatus = AudioServicesCreateSystemSoundID ((__bridge CFURLRef)soundFileURLRef, &aSoundID);
if (oStatus == kAudioServicesNoError)
AudioServicesPlaySystemSound (aSoundID);
有没有办法可以获得UILocalNotificationDefaultSoundName
的名称和类型?
答案 0 :(得分:0)
不幸的是,您的应用无法使用系统声音。来自文档:
注意:iOS应用程序无法使用系统提供的警报声和系统提供的用户界面声音效果。例如,使用kSystemSoundID_UserPreferredAlert常量作为AudioServicesPlayAlertSound函数的参数将不会播放任何内容。
更新
虽然Apple确实说你无法访问系统声音,但我认为它们必须意味着你不能出于自己的目的访问它们,但我看到UILocalNotification.h提供了:
UIKIT_EXTERN NSString *const UILocalNotificationDefaultSoundName;
“标识显示通知警报时要播放的默认系统声音。将此值分配给soundName属性。”我现在在我的应用程序中使用它,它似乎工作正常。