How do I give permission to allow audio in Android app without going to settings of phone? I am using push notification with firebase cloud message, when there is received notification but no notification sound. If I go to phone's settings and turn on notifications for app then get an audio notification

Have a try by creating a custom notification channel using the react-native-push-notification npm package.
Create an android notification channel with your requirements like sound, notification importance, etc.
For example:
PushNotification.createChannel(
{
channelId: "channel-id", // (required)
channelName: "My channel", // (required)
channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
playSound: false, // (optional) default: true
soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
importance: 4, // (optional) default: 4. Int value of the Android notification importance
vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
},
(created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
);
and add the notification channel-id name in the firebase.json to receive notification from firebase cloud messaging.
Like:
// <projectRoot>/firebase.json
{
"react-native": {
"messaging_android_notification_channel_id": "channel-id"
}
}
Check out the official docs for more information.
https://github.com/zo0r/react-native-push-notification
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