FCM Notification in iOS doesn't play sound when received

Jr Pro picture Jr Pro · Sep 5, 2016 · Viewed 26.2k times · Source

I am using Firebase push notifications in my iOS Application. Although I am able to send the notification by sending below payload, it doesn't play a sound when received.

{
    "to": "myToken",
    "notification": {
        "body": "test",
        "title": "test"
    },
    "priority": "high"
    "sound": "default"
}

If I send the test message from console, it works well and plays notification sound.
Note:

  1. My Authorization code is correct
  2. I am sending http request to https://fcm.googleapis.com/fcm/send
  3. I have tested it on IPhone 4 , IPhone 6 and IPhone 6S, All recieve notifications without sound

Answer

kaitosenpai picture kaitosenpai · Sep 6, 2016

your JSON "sound" : "default" should be inside the "notification" key not in the root of the JSON. This JSON should work.

{
    "to": "myToken",
    "notification": {
         "body": "test",
         "title": "test",
         "sound": "default"
    },
    "priority": "high"
}