2
votes

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

2
Please replace "notification" key with “aps” key.Rohit Parihar

2 Answers

1
votes

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.

0
votes

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