![](/img/trans.png)
[英]Firebase Push notification is not playing sound when app is in background
[英]How to trigger some sound on background when push notification(firebase) received ~ React Native
我正在构建一个类似于Swiggy的应用程序,因此当从客户那里获得新订单时,我正在触发推送通知,那时我需要触发不同的喇叭声音。
使用的模块:
// 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)
}
})
这里! 问题是收到通知时不会触发声音。
请帮我解决一下这个。 提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.