No sounds for ios FCM notifications

3,397 views
Skip to first unread message

Bob Smith

unread,
Jan 30, 2022, 12:40:58 PM1/30/22
to Firebase Google Group
Hi There,

I have been trying for hours to get a custom notification sound to work in an ios app.  I have sound files in both wav and mp3 formats in my main app bundle and they are showing in "Copy bundle resources" in xcode.  As I change the json payload for the notification, sometimes they are vibrating sometimes they are not, but they never give a sound whether I use 'default' or the name of my file.

Here is the payload I am currently trying to send:

{
'notification': {'title': 'Sending push form python script',
'body': 'New Message',
},
'to':
deviceToken,
'priority': 'high',

'apns': {
'headers':{
"apns-collapse-id": "solo_changed_administrator",
"content-available": "1",
"apns-priority": "10",
},
'payload':{
'aps':{
'sound': 'pager.wav',
'badge': 12213123223
}
}
},
# 'data': dataPayLoad,
}

Is there something wrong with this payload?  Notification appears on phone but sound does not play.

Bob Smith

unread,
Jan 30, 2022, 4:52:06 PM1/30/22
to Firebase Google Group
Note that I have also tried the file as a cef file and no dice.

Sorry about the formatting of the json, couldn't figure out how to do a code block.

Carsten Hagemann

unread,
Jan 30, 2022, 7:31:13 PM1/30/22
to Firebase Google Group
Yeah, the payload does not look right, e.g.
1. `content-available` indicates a background notification (is that what you want?) and resides in the `aps` object (https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app).

Here is it in proper format:
{

   "notification":{
      "title":"Sending push form python script",
      "body":"New Message"
   },
   "to":"deviceToken",

   "priority":"high",
   "apns":{
      "headers":{
         "apns-collapse-id":"solo_changed_administrator",
         "content-available":"1",
         "apns-priority":"10"
      },
      "payload":{
         "aps":{
            "sound":"pager.wav",
            "badge":12213123223
         }
      }
   },
   "data":"dataPayLoad"
}

Bob Smith

unread,
Jan 30, 2022, 9:47:12 PM1/30/22
to Firebase Google Group
Thanks for the speedy response.  I have tried all manner of formats and nothing is working for me.  This one isn't working either.


I have tried the filename with a sound= parameter on the notify_single_device too, and that wasn't working for me either.

Yes I am looking for a sound on a background notification just while the phone is sitting idle.

Bob Smith

unread,
Jan 31, 2022, 7:48:49 PM1/31/22
to Firebase Google Group
Note that I made two changes to your proposed json payload.  I changed the "to" to an actual variable 'deviceToken' that contains the FCM token, and I removed "data":"dataPayLoad".

Notification comes through but still no sound.

Carsten Hagemann

unread,
Jan 31, 2022, 7:48:49 PM1/31/22
to Firebase Google Group
With background notification you are responsible to create and display the notification in your app. Do you receive a notification and struggle to present it to the user?

The spec says "Number', but it's might worthwhile to use a value for 'badge' that is within the integer range.

Bob Smith

unread,
Jan 31, 2022, 7:49:06 PM1/31/22
to Firebase Google Group
I'm embarrassed, I didn't realize there was a physical 'silence' switch on the side of the phone and it was mostly that.  Funny that some sound was still working and there was no indication about that in the UI.  I don't normally use iphones.  Thanks for the help.

On Sunday, 30 January 2022 at 22:47:12 UTC-4 Bob Smith wrote:

Kato Richardson

unread,
Feb 3, 2022, 11:39:13 AM2/3/22
to Firebase Google Group
Hi Bob, you'd think a physical silence switch would, you know, silence it? Glad you were able to figure it out!

☼, Kato

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e568e14c-7bf2-457a-ae61-f83285f6549an%40googlegroups.com.


--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages