react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

Push Notification not displaying in status bar

Open prasad456 opened this issue 5 years ago • 17 comments

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

prasad456 avatar Oct 07 '20 02:10 prasad456

Hi, Please upgrade your version before reporting issues. Old version won't be fixed, no time for that. Regards

Dallas62 avatar Oct 07 '20 04:10 Dallas62

Hi

@Dallas62

I updated the package to v6.1.1 having same issue

prasad456 avatar Oct 07 '20 15:10 prasad456

Did you follow the upgrade process ?

Dallas62 avatar Oct 07 '20 15:10 Dallas62

I uninstalled the previous version and installed the new one

prasad456 avatar Oct 08 '20 03:10 prasad456

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

@Dallas62 I need really fix this thing, can you please help? Don't mind if I bothering you....

prasad456 avatar Oct 08 '20 03:10 prasad456

context is always null and mReactInstanceManager.hasStartedCreatingInitialContext() is always returning true handleRemotePushNotification((ReactApplicationContext) context, bundle); this line doesn't execute at all any problem ? from my end..

prasad456 avatar Oct 08 '20 04:10 prasad456

Did you follow instructions in the Changelog? There is breaking changes in the version, please refer to the Channel documentation of the readme.

Dallas62 avatar Oct 08 '20 05:10 Dallas62

I got the same issue, any luck with this thread ?

jrartiga avatar Oct 15 '20 03:10 jrartiga

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

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

brijeshmkt avatar Oct 20 '20 20:10 brijeshmkt

Hi @jrartiga @brijeshmkt

Again:

Did you follow instructions in the Changelog? There is breaking changes in the version, please refer to the Channel documentation of the readme.

Regards

Dallas62 avatar Oct 20 '20 21:10 Dallas62

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?

rbarri777 avatar Oct 20 '20 23:10 rbarri777

Hi @jrartiga @brijeshmkt

Again:

Did you follow instructions in the Changelog? There is breaking changes in the version, please refer to the Channel documentation of the readme.

Regards

Thank you, my client's main requirement was to have a push notification that should in the foreground. And 5.1.1 is working like a charm for this.!

brijeshmkt avatar Oct 21 '20 04:10 brijeshmkt

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

Dallas62 avatar Oct 21 '20 05:10 Dallas62

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

Surely will do this today. And will try to share the output so that it might help others too! So that they can use the latest version without facing any issues.

brijeshmkt avatar Oct 21 '20 06:10 brijeshmkt

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

Balthazar33 avatar Apr 28 '21 10:04 Balthazar33

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"/>

usmansbk avatar Jul 31 '21 23:07 usmansbk

Hi, I had the same issue for remote notifications using Firebase Cloud Messaging :

  • When app was in background or closed, notifications did not appear in status bar
  • When app was in background, onNotification event was fired
  • When app was close, onNotification event wasn't fired

In my case the problem was about the FCM notification payload format (JSON).

My wrong format was : { "to": "DEVICE_TOKEN", "data": { "title": "Notification title", "body": "Notification body", "acme1": "yep", "acme2": "yepa", } }

The right format to use when send notification via FCM server is : { "to": "DEVICE_TOKEN", "notification": { "title": "Notification title", "body": "Notification body", }, "data": { "acme1": "yep", "acme2": "yepa", } }

Version of my current react-native-push-notification : ^8.1.1

So, here my current react-native infos: System: OS: macOS 12.6 CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz Memory: 17.51 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 18.6.0 - ~/.nvm/versions/node/v18.6.0/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.13.2 - ~/.nvm/versions/node/v18.6.0/bin/npm Watchman: Not Found Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9014738 Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.2 => 0.70.2 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found

Hope it helps,

seb-montana avatar Oct 11 '22 12:10 seb-montana