Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase push notifications custom sound

I am currently working on an app and I have implement firebase Push Notification service into my app. I am recieving notification on my iphone but I am unable to set the custom alert sound that I want.

  • I added the sound as a .caf
  • I added the sound to the Copy Bundle Resources

using print (userInfo) I have collected this data that is incomming from Firebase

aps: {
alert =     {
    body = MSG;
    title = Title;
};
sound = default;}, {...}, sound: alarm.caf

I understand where the problem is, I just dont understand how to fix it so that the app plays my custom notification sound.

Firebase notification console IMG

like image 219
Mentos Avatar asked Aug 07 '16 06:08

Mentos


People also ask

Is Firebase good for push notifications?

Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.

How do I get sound on push notifications?

Go to Settings > Sound & Notification > App Notifications. Select the app, and make sure that Notifications are turned on and set to Normal.


1 Answers

It's been over 5 years, but if someone still looking for an answer, here is what I did.

  1. Make sure you have configured Firebase Messaging & receiving Notifications.

  2. Add .caf ( sound file ) to the app. It must be visible on 'Target' - > 'Build Phases' & then under 'Copy Bundle Resources'

enter image description here

  1. Delete the app from the device ( This is important )

  2. I use Postman as my server, so message format would be,

    { 
     "notification": {
     "title": "Hello",
     "sound":"small_message.caf",
     "body": "You have a new Job"
    },
    
    "to": "your device token"
    }
    
like image 134
Heshan Sandeepa Avatar answered Sep 22 '22 14:09

Heshan Sandeepa