Greg Price
Greg Price

Reputation: 2556

iOS 4.3, iPhone 4 not playing custom sound with UILocalNotification

There are posts similar to mine, but I have not found one exactly like it. Here is what happens:

In my app I schedule a local notification:

        UIApplication* app = [UIApplication sharedApplication];

        [app cancelAllLocalNotifications];

        UILocalNotification *localNotif = [[ UILocalNotification alloc ] init];

        NSDate *date = [ [[ NSDate alloc] initWithTimeIntervalSinceNow:30 ] autorelease ];

        if (localNotif == nil) {
            return;
        }

        localNotif.fireDate = date;
        localNotif.alertBody = @"Nearing Return Location!";
        localNotif.alertAction = @"Ok";
        localNotif.soundName = @"2_bubble_wrap.caf";


        [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
        [localNotif release];

Which works just fine in iOS 5. In iOS 4.3 I took care to make sure that the sound was on and loud before testing. Naturally the file is less than 30 seconds duration. When it triggers on the iPhone 4, I got no sound, just the alert box. When I retested with the default sound, it played that with the notification. When I replaced the .caf file name with gibberish, it also played the default sound, so it knew my file was there just did not play it. When I run it in the iOS 4.3 simulator it does play my .caf sound. I am losing it. Any ideas anyone?

Greg

-

Upvotes: 0

Views: 841

Answers (1)

Björn Kaiser
Björn Kaiser

Reputation: 9912

Simulator != Device especially when you play media files, as your Mac supports more codecs than iPhones do. Checking that your caf file is encoded the way the iPhone needs it and correcting any issues with encoding may solve the problem.

Upvotes: 2

Related Questions