evollu / evollu/react-native-fcm

Can't access notification data when the app is in background or killed

Open
#623 14 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

Hi!

First of all, great work with this library!

```
react-native@0.48.0
react-native-fcm@10.0.2
OS: Android - Emulator - 7.0.2
```

When my app is in foreground, its working perfectly, I receive the data in this function

`FCM.on(FCMEvent.Notification, async (notif) => {`

And I can handle everything

![image](https://user-images.githubusercontent.com/2410951/31851008-c188596e-b65d-11e7-97f5-1a8091d90536.png)

But when the app is in background, the notification is received, but when I tap the banner, the app goes foreground, the same function is triggered, but the notif object is different, and don't contains my data.

![image](https://user-images.githubusercontent.com/2410951/31851025-05098c58-b65e-11e7-90b3-c6b6a52a42f0.png)

When the app is killed, also the notification is received, but when I tap the banner, the app starts, the
`FCM.getInitialNotification()`
is triggered, and my notif object doen't also contain the data, the same behaviour than in background

![image](https://user-images.githubusercontent.com/2410951/31851066-b2c0b3ee-b65e-11e7-999a-96f0209ea072.png)

I am testing the format of the messages using node-gcm library, of firebase web interface, but nothing works.

This is a sample of my message:

```
let message = new gcm.Message({
priority: 'high',
content_available: true,
timeToLive: 3,
data: {
key1: 'message1',
key2: 'message2'
},
notification: {
title: "Hello, World",
icon: "ic_launcher",
body: "This is a notification that will be displayed if your app is in the background."
},
custom_notification: {
key1: 'message1',
key2: 'message2'
}

});
```

How should I proceed to send and receive data in those cases? Because is driving me crazy.

If you need more data, ask for it :)

Thanks!!

EDIT:

I have two activities in my native part, as I am handling a splash screen in the native way. can this be causing this effect?

This is my manifest.xml. I don't want to handle local notifications, only remotes

```


























```

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.