0
votes

I am trying to play a custom sound when receiving a push notification to my iOS app. I am using GCM on my server to push to Android and Apple devices.

By defaults I was sending the following in my push notification payload: "sound":"default". This was working no problems, 100%.

As soon as I changed it to: "sound":"sound.wav" I was no longer receiving the "sound" tag in my payload in the debugger and naturally no sound was playing when the device received the payload.

Obviously I have added sound.wav to my bundle and checked it in the bundle resources.

Can anybody shed some light on this problem?

2

2 Answers

0
votes

There are few things which can cause this.

  1. The sound file "sound.wav" should be a second long and limited size in KBs.
  2. Make sure your payload is like this:
{
  "title": "Some title",
  "data": [
    {
      "version": "1.0"
    }
  ],
  "aps": {
    "badge": 1,
    "sound": "soundfilenameinbundle.wav",
    "alert": "Some Alert to Show"
  }
}

Please make sure "sound" tag goes in "aps".

  1. As you have said you have added the sound file, can you also check if it is added in the required target.

  2. Sometimes big sized payloads also cause this. Try by reducing your payload size by removing some data for testing and check

  3. As you said you cannot see "sound" tag in the payload. I suspect the problem in payload itself. Can you try changing file name.

Also try on iOS 7/8/9 to check if the problem is not OS specific.

I hope this will help.

0
votes

Thanks Suhail,

The problem is with Google Cloud Messaging. They only support the "default" value for the sound tag. So whenever I change it to anything but that the GCM server does not send the sound tag at all.

Hope they fix it soon...

Details here: https://developers.google.com/cloud-messaging/http-server-ref