After several hours searching the web for answers on how to enable the default sound on Firebase cloud messaging notifications, for both android and iOS, I finally figured it out by myself. I could not really find any answers to this problem anywhere on the web, so I thought I should post the answer here.
Hope this helps :)
Stay organized with collections Save and categorize content based on your preferences. For Apple client apps, you can receive notification and data payloads up to 4000 bytes over the Firebase Cloud Messaging APNs interface.
This particular snippet is written in node.js, but except from the 3 first lines, the syntax is the same in Typescript.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const payload = {
notification: {
title: "X",
body: "XXX",
},
android: {
notification: {
sound: 'default'
},
},
apns: {
payload: {
aps: {
sound: 'default'
},
},
},
topic: 'X'
};
return admin.messaging().send(payload).then(response => {
console.log("Successfully sent message:", response);
})
.catch(function (error) {
console.error("Error sending message:", error);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With