简体   繁体   中英

how to play custom notification sound in ios push notification using FCM

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM