小编Al *_*old的帖子

自定义iOS UILocalNotification声音无法播放(可能与Xcode更新有关)

我正试图让一个自定义声音工作UILocalNotification,而我根本就没有声音.如果我使用UILocalNotificationDefaultSoundName,我确实得到默认声音,但是当指定自定义声音时,没有声音,只有消息.据我所知,声音不到30秒,而且格式正确.这是文件信息的屏幕截图:

我已经在XCode的DerivedData目录中检查了.app目录,并且alarm.caf文件位于应用程序的根目录,我相信这意味着它在捆绑包中(对吗?).

我很确定这是前一段时间了,我已经升级了Xcode.也许这是一个提示?

我也试过删除/重新安装/重启,如其他答案中所述.如你所见,我cancelAllLocalNotifications先打电话.

有谁知道什么可能是错的?

[[UIApplication sharedApplication] cancelAllLocalNotifications];
NSLog(@"installing alarm");
[arguments pop]; // name
[arguments pop]; // title
alarm.alertBody = [arguments pop];
alarm.fireDate = [[NSDate date] addTimeInterval:[[arguments pop] intValue]/1000];
//alarm.soundName = UILocalNotificationDefaultSoundName;
alarm.soundName = @"alarm.caf";

[[UIApplication sharedApplication] scheduleLocalNotification:alarm];
Run Code Online (Sandbox Code Playgroud)

objective-c ios uilocalnotification

7
推荐指数
1
解决办法
6889
查看次数

标签 统计

ios ×1

objective-c ×1

uilocalnotification ×1