8

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.

Mazyod
  • 22,319
  • 10
  • 92
  • 157

3 Answers3

10

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.

Mazyod
  • 22,319
  • 10
  • 92
  • 157
  • 3
    If someone should still be struggling with this issue, I discovered that it might be necessary do one more thing. When drag-drop'in the audio file into your project, besides checking "Copy ...", you might need to to check the "Add to target" option as well. This did the thing for me. Thanks for the answer anyway. – Kasper Munck Jun 16 '12 at 16:22
  • Awesome, but then again, your issue has to do with ANY resource file you add (images, sounds, fonts, ... etc.) ;) – Mazyod Jun 17 '12 at 14:49
1

are you cleaning the old notifications with

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

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

?

junglecat
  • 643
  • 1
  • 10
  • 19
Duck
  • 34,902
  • 47
  • 248
  • 470
0

Try this:

notif.soundName = [strSoundFileName copy];
Jonas G. Drange
  • 8,749
  • 2
  • 27
  • 38