1

I'm using FCM to send push notification to iOS devices from the server but I'm getting the notification successfully but unable to play custom notification sound.

here is my payload

{
    "to":"myToken",
    "notification":{
        "title":"new message",
        "body":"Hello World!",
        "sound":"tweet_sent.caf",
        "badge": 3
    }
}

Note: Also i added 'tweet_sent.caf' file to Xcode bundle

Nani
  • 446
  • 7
  • 24

2 Answers2

0

Please replace notification key with aps like:

{
    "to":"myToken",
    "aps":{
        "title":"new message",
        "body":"Hello World!",
        "sound":"tweet_sent.caf",
        "badge": 3
    }
}

And also add sound tweet_sent.caf file into your project resource location.

Subair K
  • 1,760
  • 1
  • 11
  • 31
Kiran K
  • 919
  • 10
  • 17
  • For FCM you use `"notification"` and not "`aps"` https://firebase.google.com/docs/cloud-messaging/concept-options#notifications – Andrew Nov 21 '19 at 12:42
  • As per this link- https://firebase.google.com/docs/cloud-messaging/ios/receive , "aps" is part of Payload. – Kiran K Nov 22 '19 at 12:11
  • Firebase repackages the payload that is sent to it before it goes out. It recreates it in the way that is required for Apple. Your link shows how it is delivered to the app, not how you send it to firebase. – Andrew Nov 22 '19 at 12:21
  • 4
    How do I add the sound to my `project resource location`? – genericUser May 11 '21 at 09:43
0

thanks for your answers and comments

It is working fine now after adding notification file in build phases (Xcode).

For Ref: Playing a custom sound on receiving a remote push notification on iOS 12 from FCM

Nani
  • 446
  • 7
  • 24