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.

Disable foreground notifications?

See original GitHub issue

Is it possible to disable foreground receiving foreground notifications from my own app? (when the app is open). Specifically for Android?

I have this set but i still see remote notifications for my app while its in the foreground

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

3reactions
classiebitcommented, Jun 4, 2021

This is working for us-

Android

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

iOS

// Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
    completionHandler(UNNotificationPresentationOptionNone);
}

In this way, when the app is in the foreground, no notification shown while in the background, notification is showing. Hence, this solution is working for us.

1reaction
Dallas62commented, Mar 13, 2021

Hi,

<!-- Change the value to true to enable pop-up for in foreground on receiving remote notifications (for prevent duplicating while showing local notifications set this to false) -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="false"/>

This parameter is for remote notification, please use the following for local notifications:

ignoreInForeground: false, // (optional) if true, the notification will not be visible when the app is in the foreground (useful for parity with how iOS notifications appear). should be used in combine with `com.dieam.reactnativepushnotification.notification_foreground` setting

Without context / reproducible exemple, can’t help more.

Regards,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hiding foreground services notifications in Android - Spiria
Here, the trick is to create two services that start in the foreground with the same foreground id, then to stop one of...
Read more >
How to stop firebase notification if app is in foreground
We can configure like showing notification only when app is in background and disable when app is in foreground.We can check whether app...
Read more >
Can I disable these foreground service notifications or will it ...
Yes, swipe a bit right or left, push settings wheel once, then again and turn off highlited notification.
Read more >
Foreground services - Android Developers
To remove the service from the foreground, call stopForeground() . This method takes a boolean, which indicates whether to remove the status bar...
Read more >
How to stop foreground services from the notification drawer in ...
How to stop active background apps on Android 13 · 1. Swipe down from the top of your screen to pull down the...
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