如何为UILocalNotification添加声音?

use*_*740 12 ios uilocalnotification

我已经为我的应用程序完成了基本通知.我想在我的通知中添加声音效果.

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
if (localNotification == nil)
    return;

localNotification.fireDate = [NSDate date];
//localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = msg;
localNotification.soundName = @"Morse.aiff";

[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
Run Code Online (Sandbox Code Playgroud)

如何添加音效?

til*_*ilo 13

您可能需要先阅读本地和推送通知编程指南的准备自定义警报声音(确保您的自定义声音短于30秒).

如果你想使用默认声音:使用 UILocalNotificationDefaultSoundName(按照Euroboy的建议)

更新:您似乎不是唯一遇到此问题的人.这里描述一种可能的(但当然不是很好的)解决方案.