evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 681 forks source link

when app is in background i received notification when i click on notification i am trying to show alert which is not working #877

Open madhududdukuri opened 6 years ago

madhududdukuri commented 6 years ago

i am using react-native-fcm version is13.3.1 Android7.0 -motog4 Application is in background when my application is in background iam sending notification through fcm console i received notification. but when i click on notification banner it is redirecting to application but it is not able to show the alert in my application but when i debug the app the alert is showing // present local notification code FCM.presentLocalNotification({ title: notifcationTitle, body: message, priority: 'high', show_in_foreground: true, sound: 'default', click_action: 'com.cmtventra.MainActivity', action: 'android.intent.action.MAIN', }); } //on notification received

**this.notificationListner = FCM.on(FCMEvent.Notification, async(notif) => { if (notif.opened_from_tray) { Alert.alert(notif.title, notif.body, [ { text: 'OK' }, ], { cancelable: false });

 }
 else {
    EmailPrefrences.showLocalNotification(notif);
 }
});**
madhududdukuri commented 6 years ago

i am using react-native-fcm version is13.3.1 Android7.0 -motog4 Application is in background when my application is in background iam sending notification through fcm console i received notification. but when i click on notification banner it is redirecting to application but it is not able to show the alert in my application but when i debug the app its showing // present local notification code FCM.presentLocalNotification({ title: notifcationTitle, body: message, priority: 'high', show_in_foreground: true, sound: 'default', click_action: 'com.cmtventra.MainActivity', action: 'android.intent.action.MAIN', }); } //on notification received

**this.notificationListner = FCM.on(FCMEvent.Notification, async(notif) => { if (notif.opened_from_tray) { Alert.alert(notif.title, notif.body, [ { text: 'OK' }, ], { cancelable: false });

     }
     else {
        EmailPrefrences.showLocalNotification(notif);
     }
    });**
evollu commented 6 years ago

try set a timeout around the alert. check the example project, it shows alert when user tap notification