UILocalNotification 自定义声音
我已经寻找解决方案几个小时了..运气绝对为零。
我设置了一个本地通知:
UILocalNotification *notif = [[cls alloc] init];
[dateComp setDay:j+1];
[dateComp setHour:[[time objectAtIndex:0] integerValue]+offset];
[dateComp setMinute:[[time objectAtIndex:1] integerValue]];
NSLog(@"Year: %i, Month: %i, Day: %i, Time:%i:%i\n",[dateComp year], [dateComp month],
[dateComp day], [dateComp hour], [dateComp minute]);
notif.fireDate = [gregorian dateFromComponents:dateComp];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = [names objectAtIndex: k];
notif.soundName = @"fireburn.caf";
注意声音名称...
我尝试输入 10 种声音(aiff、wav、caf...等),但通知只是以默认声音弹出:/
我有“fireburn.txt”。资源文件夹中的“caf”文件。
为什么不播放我的声音????
谢谢。
I have been searching for a solution for hours.. with absolutely zero luck.
I set up a Local Notification:
UILocalNotification *notif = [[cls alloc] init];
[dateComp setDay:j+1];
[dateComp setHour:[[time objectAtIndex:0] integerValue]+offset];
[dateComp setMinute:[[time objectAtIndex:1] integerValue]];
NSLog(@"Year: %i, Month: %i, Day: %i, Time:%i:%i\n",[dateComp year], [dateComp month],
[dateComp day], [dateComp hour], [dateComp minute]);
notif.fireDate = [gregorian dateFromComponents:dateComp];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = [names objectAtIndex: k];
notif.soundName = @"fireburn.caf";
Notice the sound name...
I tried to put 10 sounds (aiff, wav, caf...etc), but the notification just pops up with the default sound :/
I have the "fireburn.caf" file in the Resources folder.
Why is it not playing my sound?????
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
解答:
代码没有问题。
只是愚蠢的 iPhone 没有取消我用默认声音发出的旧通知 -_-;
当我清理项目时,从手机中删除了应用程序并重新启动手机,然后它就工作了。
希望有人觉得这有帮助。
ANSWER:
Nothing wrong with the code..
It's just that the stupid iPhone didn't cancel the old notifications that I made with the default sound -_-;
When I cleaned the project, deleted the app from the phone AND REBOOTED the phone THEN it worked..
Hope someone finds this helpful.
您正在使用 清理旧通知吗
?
are you cleaning the old notifications with
?
试试这个:
Try this: