evollu / evollu/react-native-fcm

Cannot receive the data payload (only data key) in both foreground, background and not running

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

Description

Before openning an issue
1. Reproduce it with the example project in this repo.
2. If you can't receive iOS notification, make sure you can receive notification using quickstart-ios project provided by Firebase team

When openning an issue, please include following information for better support

1. What version of RN and react-native-fcm are you running?
react-native: 0.43.4
react-native-fcm: "^10.0.3"

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

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

I am trying to receive the notification from Firebase function (the serverless structure). My payload is like:

```
data: {
type: "chat",
senderName: "name",
message: "msg",
senderId: "id",
createdAt: "time"
}
```

However, the frontend using react-native-fcm cannot receive the notification in all different state (foreground, background and not running).

I used the following code to receive the notification

```
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
// format of JSON
console.log("RECEIVED NOTIFICATION: " + JSON.stringify(notif));
}
```

Noted that I can receive the notification if i pass the 'notification' key as payload to send.

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.