I want to use custom sound on remote notification appears.Especially for IOS , in latest firebase library react-native-firebase/messaging(@6.7.1)lease help me regarding this.onNotification action is not performingBelow is the snippet of code i used.I have a react native app, Its a react hooks based app, where i want to play custom music based on notification payload data. And its working only when app is opened, But i want to play the custom sound when app is in background too.
async componentDidMount() {let res = await retrieveItem('user').then((response)=>{if(response != null){messaging().setBackgroundMessageHandler(async (remoteMessage) => {console.log('Message handled in the background!', remoteMessage);// alert('hello1')});messaging().onMessage(async remoteMessage => {if(Platform.OS=='ios'){console.log('enter background notif',remoteMessage)PushNotification.localNotification({alertAction: "view", // (optional) default: viewcategory: "", // (optional) default: empty stringuserInfo: {}, // (optional) default: {} (using null throws a JSON value '<null>' error)title: remoteMessage.notification.title, // (optional)message: remoteMessage.notification.body, // (required)soundName:'Alarm'// playSound: false, // (optional) default: true});// alert('hell7o')}});messaging().onNotificationOpenedApp(async (remoteMessage) => {console.log('Notification caused app to open from background state:',remoteMessage);});messaging().getInitialNotification().then(async(remoteMessage) => {if (remoteMessage) {console.log('Notification caused app to open from quit state:',remoteMessage);}});this.props.BaseStore.userStore.user=responsethis.props.BaseStore.userStore.docid=response.idthis.props.BaseStore.userStore.type=response.typethis.props.navigation.navigate('Home')console.log(response.type);}}).catch((error)=>{console.log(error)})console.log(this.props.BaseStore.userStore.type)// this.set(this.props.BaseStore.userStore.type)}