Question

I've got an iPhone app that I'm working on that uses Push Notifications.

In the payload I'm specifying a few things:

  • message body
  • sound
  • action-loc-key because I don't want the user to be able to launch the app from the notification

The notification is getting to my iPhone just fine. It shows a message without buttons. So body and action-loc-key are working just fine. But, it's not playing any sound.

However, there are a couple of things I've noticed during troubleshooting:

  1. if I implement application:didReceiveRemoteNotification, everything looks fine. The Dictionary argument contains a key for sound, whose value is indeed the name of the file I want to play.
  2. The sound file itself "works" because if I play it inside of the app (using the SoundEffect class from the BubbleLevel sample) it works just fine.

Despite these two facts, the sound effect simply isn't playing.

In the settings app, everything looks right - Push is turned on for my app, and I have both "sounds" and "alerts" set to on as well.

The iPhone documentation center suggests using Quicktime to look at the format of the file. This is what it looks like.

alt text

Finally, if I look at the info for this file in XCode, it says the file type is simply the default, "file." From what I could tell there is no audio-caf option in the list. I tried audio-WAV (the sound engineer told me the original files were WAVs) but that didn't change anything.

In addition, the code:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// view controller set up stuff
    // ...

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];

}

Was it helpful?

Solution

I should have posted the JSON as well, it turns out I was constructing it wrong. The reason it worked in didReceieveRemote notification is b/c I was parsing the JSON myself and the fact that I had stuff out of order didn't matter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top