I am playing with the my app using React Native for implementation.
There is a case that after receiving a push notification (using react-native-firebase), app will play sound (using react-native-sound):
- "Hey, new music is waiting for ya". (when there is a new music)
- "Hey, new magazine is waiting for ya". (when there is a new magazine)
The thing is:
- In foreground, everything works.
- In background (background audio mode is enable), I cannot play my sound after the default push notification sound "ting". If my sound plays alone, everything works.
According to react-native-firebase
:
// index.jsimport { AppRegistry } from 'react-native';import messaging from '@react-native-firebase/messaging';import App from './App';// Register background handlermessaging().setBackgroundMessageHandler(async remoteMessage => { console.log('Message handled in the background!', remoteMessage); // ==== I play my sound here ====});AppRegistry.registerComponent('app', () => App);
If you have any suggestion, please let me know.
Thank you in advanced!