evollu / evollu/react-native-fcm

How to tell if the app was launched from the notification or is in foreground when receiving the notification?

Open
#839 3 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

Hello,

I am successfully using this library to receive both foreground and background notifications on iOS 11.3 on an iPhone 6s.
```
"react-native-fcm": "^13.1.0",
"react-native": "0.51.0",
```
It's working great, but I am struggling to detect whether the notification was received in the foreground.

I've tried placing
```javascript
FCM.getInitialNotification().then(notif => {
console.log("INITIAL NOTIFICATION", notif)
});
```
both inside and outside my
```javascript
FCM.on(FCMEvent.Notification, notification => {
console.info('Notification:', notification);
}
```
function but it is always `undefined`.

I've also tried checking `notification.opened_from_tray` but that is also undefined.

My message payload looks like:
```
{
"notification": {
"body": "blah blah",
"title": "foo",
"sound": "default",
"click_action": "my_app_id"
},
"data": {
"channelID": 123
}
}
```

my notification (passed to the above function) looks like:
untitled

What could I be missing? I'm relying on code posted in recent comments but I seem to be getting very different data.

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.