react-native-push-notification: Push Notification not displaying in status bar

Bug

Push notifications can able receive in receiver but could not display in Status bar.

Environment info

System:
    OS: macOS 10.15.6
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
    Memory: 829.48 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 13.8.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.13.7 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK: Not Found
    Android SDK:
      API Levels: 23, 25, 28, 29, 30
      Build Tools: 28.0.3, 29.0.3, 30.0.0, 30.0.2
      System Images: android-29 | Google APIs Intel x86 Atom, android-R | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_242 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0 
    react-native: ^0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: “react-native-push-notification”: “^4.0.0”,

Steps To Reproduce - Scenario 1

  1. Receiver can able to receive notifications from FCM, printing logs
  2. Notification data is sent jsDelivery.notifyNotification(bundle);
  3. config.getNotificationForeground() getting false

Steps To Reproduce - UseCase 2

  1. Receiver can able to receive notifications from FCM, printing logs 2.context is null
  2. config.getNotificationForeground() getting false …

Describe what you expected to happen:

  1. Need to display the notification in status bar

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 2
  • Comments: 17

Most upvoted comments

Please do not downgrade. To make notifications work, just follow the changelog and create a Channel. As I said: read the Channel part! Regards

I have the same issue and I read the instructions in the Changelog and I added in my AndroidManifest.xml the configurations for the Channels. In ChangeLog said that default channel is “fcm_fallback_notification_channel” and my problem is that when I send a remote notification (from Firebase console), I don’t see the notification like the @brijeshmkt image. Only I can see the information in my console:

NOTIFICATION: {"channelId": "fcm_fallback_notification_channel", "color": null, "data": {}, "finish": [Function finish], "foreground": true, "id": "404230", "message": "task again", "priority": "high", "sound": null, "tag": "campaign_collapse_key", "title": "new", "userInteraction": false, "visibility": "private"}

I can receive push in background, because I close my app and retry to send a new notification and the notification appears in statusbar.

The more curious, is that when I open again the same app and send another notification now sometimes the notification appears in the statusbar and I can see the same information in my console: (with different message of course)

NOTIFICATION: {"channelId": "fcm_fallback_notification_channel", "color": null, "data": {}, "finish": [Function finish], "foreground": true, "id": "-2109342", "message": "With my notification 2", "priority": "high", "sound": null, "tag": "campaign_collapse_key", "title": "What happend", "userInteraction": false, "visibility": "private"}

Why doesn’t show the notification the first time that I send push? (I tried installed and uninstalled the app to replicate the same behavior) What’s wrong?

For future reference, the solution is here. Change the android:value to true

        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="true"/>

This is what I have in my manifest file:

 <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="true"/>
        <!-- Change the resource name to your App's accent color - or any other color you want -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/theme"/> <!-- or @android:color/{name} to use a standard color -->

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>

        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

And this is how I’ve created the channel:

 PushNotification.createChannel(
      {
        channelId: "channel", // (required)
        playSound: false, // (optional) default: true
        soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
        vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
      },
      (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
    );

RN version : 0.63.4 react-native-push-notification: ^7.2.3,

Can you tell me where I might be making a mistake ? I’m not able to see the notification the first time in foreground. Thanks. @prasad456 @brijeshmkt @jrartiga

I have the same issue. Changing to 5.1.1 solved my problem.

WhatsApp Image 2020-10-21 at 1 49 02 AM

I uninstalled the previous version and installed the new one