android - 收到推送通知(firebase)时如何在背景上触发一些声音〜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)
}
})
这里!问题是收到通知时未触发声音。
请帮我解决一下这个。提前致谢。
解决方案
推荐阅读
- java - 如何在不同时间混合两个音频文件?
- java - Corda:CollectSignaturesFlow 产生 UnsupportedOperationException
- kubernetes - 通过 ssh 在远程计算机中启动 minikube 仪表板
- python - WSL 终端接收命令,但集成的 VSCode 集成终端没有
- swift - 由于证书不受信任,Swift 5.1 UIWebView 不查看 URL
- html - 盒子定位问题
- c++ - 中止运行方法/线程
- python - 如何在 Django 中预取嵌套数据?
- c# - 如何合并两个 XSD 文件并保留旧 XSD 文件中的旧类?
- ios - 为什么 didFailToRegisterForRemoteNotificationsWithError 返回错误 == nil?