question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

On 6.0.0 foreground notification no longer appears on Android

See original GitHub issue

Bug

I have the “notification_foreground” option in AndroidManifest.xml set to “true”, as I would like foreground notifications to appear.

In v5.1.1 of this package the notification appears as expected while the app is in the foreground.

When I update to 6.0.0 the notification no longer appears. Notifications continue to appear while the app is in the background ok.

When I roll back to 5.1.1 (with no other changes) the foreground notifications appear again.

Has something changed in 6.0.0 which would affect this behaviour?

Thanks

Environment info

react-native info output:

 // paste it here

Library version: 6.0.0

Steps To Reproduce

  1. Install 6.0.0 of this library
  2. Set “notification_foreground” to true in AndroidManifest.xml
  3. Run the app on Android
  4. Trigger a remote notification while the app is open in the foreground
  5. Don’t see the notification appear
  6. Roll back to 5.1.1 and repeat the steps
  7. See the notification appear while the app is open in the foreground …

Describe what you expected to happen:

Foreground notification behaviour doesn’t change between version 5.1.1 and 6.0.0.

Reproducible sample code

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:33

github_iconTop GitHub Comments

8reactions
olgaababiccommented, Jan 11, 2021

Hey I’m using version 7.0.0 and I’m experiencing same problem. I’ve created my channel:

PushNotification.createChannel(
      {
        channelId: INTERNAL_NOTIFICATIONS_CHANNEL, // (required)
        channelName: '..., // (required)
        channelDescription: '...', // (optional) default: undefined.
        soundName: 'default', // (optional) See `soundName` parameter of `localNotification` function
        importance: 4, // (optional) default: 4. Int value of the Android notification importance
        vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
      },
      (created) => console.log({created}), // (optional) callback returns whether the channel was created, false means it already existed.
    );

And I’m reacting to notification like this:

  PushNotification.localNotification({
          id: messageId,
          title: notification.title, // (optional)
          message: notification.body, // (required)
          userInfo: data,
          channelId: INTERNAL_NOTIFICATIONS_CHANNEL,
        });

It works when application is in background but not when it’s in foreground. Do you know what could I be doing wrong?

5reactions
Dallas62commented, Sep 28, 2020

I just released the version 6.1.0. In your case you can create a channel and define it as default channel for FCM notifications in AndroidManifest, the version 6.1.0 allow this also for foreground notifications. Then you don’t need to specify the channel id in your backend. This should keep the compatibility with old versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to receive notification in foreground on Android 8 ...
Got it to work. It's because from Android 8 you need to create a channel // Build a channel const channel = new...
Read more >
Receive messages in an Android app - Firebase - Google
Firebase notifications behave differently depending on the foreground/background state of the receiving app.
Read more >
Android 6.0 Changes | Android Developers
The adb shell dumpsys notification command no longer prints out your notification text. Use the adb shell dumpsys notification --noredact ...
Read more >
flutter_local_notifications 6.0.0 | Flutter Package - Pub.dev
A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.
Read more >
Releases | Notifee
To learn more, view the Foreground Notifications documentation ... [Android]: Fixes an issue where the current version of Notifee does not build when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found