evollu / evollu/react-native-fcm

Cannot receive notifications from Firebase console on Android while app is in foreground

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

Description

React Native Version: 0.47.2
Device: LG V20 (Model number LG-H990ds)
Android Version: 7.0
App is running in the foreground

I'm testing out using Firebase Cloud Messaging with our React Native app and went through the setup instructions for this library on Android. I saw that the app receives notifications just fine while in the background, but in the foreground, the app doesn't receive any push notifications.

For testing, I set up a new project in the Firebase console and I'm using the Notifications Composer on the Firebase console to send push notifications. All I'm sending is a simple notification with "Hello world!" as the message, and it's not showing up in the notification tray when the app is in the foreground, even though I have the local notification publisher set up. I downloaded the example project and I also wasn't seeing a push notification when the app is in the foreground.

I have two questions:
1. When the example app is in the foreground, is a notification expected to appear in the system tray when sending it through the Firebase console?
2. Is there something wrong with my setup? For the example project, I did the following:
- Cloned the repository
- Opened the project in Android studio (the folder `Examples/simple-fcm-client/android/`)
- Created a new project in the Firebase console with the example project's bundle ID
- Downloaded the google-services.json file and put it into the project, as the console instructed.
- Ran `npm install` in the root folder of the example project (the folder `Examples/simple-fcm-client`)
- Ran `npm start` in the root folder of the example project
- Hit the "run" button in Android studio and selected my device

I started debugging some of the code in the library and saw some obvious issues. For one, the intent in the `onMessageReceived` function within the class `MessagingService` passes in an action named "com.evollu.react.fcm.ReceiveNotification", and there's nothing in the Android manifest listening for an action with that name. After correcting this naming issue and adding an intent filter in the Android manifest, I noticed that the `SendNotificationTask` assumes the intent has some extras with properties such as `body`, `title`, etc., but the intent has a `RemoteMessage` object as its single extra under the `data` key.

Please let me know if there's something wrong with my project setup that's causing the issue, otherwise I'm going to have to submit some major changes to the Android side of the code, and update the setup instructions.

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.