I am building an application similar to Swiggy, So When getting a new order from a customer, I am triggering a push notification, At that time I need to trigger a different Horn Sound.
Modules used:
// For Firebase notification
@react-native-firebase/messaging
react-native-push-notification (for local notification)
// Background lisner to trigger sound
import messaging from '@react-native-firebase/messaging';
import SoundPlayer from 'react-native-sound-player'
messaging().setBackgroundMessageHandler(async(remoteMsg) => {
try {
SoundPlayer.playSoundFile('air_horn', 'mp3')
} catch (e) {
console.log(`cannot play the sound file`, e)
}
})
Here! The problem is Sound is not triggered when notification is received.
Please Help me with this. Thanks in advance.