evollu / evollu/react-native-fcm

How to make notification on-click detection work ?

Open
#737 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.7k
Forks
661
PR merge metrics
No merged PRs in 30d

Description

1. What version of RN and react-native-fcm are you running?

- "react-native": "0.50.3",
- "react-native-fcm": "11.1.0"

2. What device are you using? (e.g iOS9 emulator, Android 6 device)? **Android 6 Emulator**.

3. Is your app running in foreground, background or not running? **Background.**

I have followed the code that you have given on the react-native fcm homepage where I have put the FCM.Notification listener outside component scope -

```
// this shall be called regardless of app state: running, background or not running. Won't be called when app is killed by user in iOS

FCM.on(FCMEvent.Notification, async (notif) => {
// there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
if(notif.local_notification){
//this is a local notification
console.log("local notification");
}
if(notif.opened_from_tray){
//iOS: app is open/resumed because user clicked banner
//Android: app is open/resumed because user clicked banner or tapped app icon
console.log("opened_from_tray");
}
....
```
However, when I receive notification from _FCM Notification Composer_ and click on the received notification banner, `notif.local_notification` is not called. Could you help me with how to work with this ?
I just need to set a small flag when user clicks on notification.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.