8

我一直在寻找几个小时的解决方案.. 运气绝对为零。

我设置了本地通知:

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...等),但通知只是弹出默认声音:/

我在 Resources 文件夹中有“fireburn.caf”文件。

为什么不播放我的声音??????

谢谢。

4

3 回答 3

10

回答:

代码没什么问题。。

只是愚蠢的iPhone没有取消我用默认声音发出的旧通知-_-

当我清理项目时,从手机中删除了该应用程序并重新启动了手机,然后它就可以工作了..

希望有人觉得这很有帮助。

于 2010-11-16T06:24:03.520 回答
1

你在清理旧通知吗

UIApplication* app = [UIApplication sharedApplication];
NSArray*  oldNotifications = [app scheduledLocalNotifications];

// Clear out the old notification before scheduling a new one.
[app cancelAllLocalNotifications];

?

于 2011-11-02T19:47:09.433 回答
0

尝试这个:

notif.soundName = [strSoundFileName copy];
于 2012-08-03T06:15:24.337 回答