How to prevent app from coming to foreground on notification action click
See original GitHub issueIn a Headless.js task I trigger a localPushNotification
with notification actions.
PushNotification.localNotification({
title: REQUEST_TITLE,
message: REQUEST_MESSAGE,
playSound: false,
soundName: "default",
actions: '["Yes", "No"]',
});
I configured the handling this way:
PushNotification.configure({
onNotification: handleNotificationClick
});
PushNotification.registerNotificationActions(["Yes", "No"]);
DeviceEventEmitter.addListener('notificationActionReceived', (event) => {
console.log("Received notification action event" + JSON.stringify(event));
});
When the app is in background and I click one of the notification actions, the application is launched and brought to foreground.
The onNotification
handler is called, the DeviceEventEmitter.addListener
callback is not called.
Does anyone know how to solve this issue? I want to handle the notification action click without bringing the application to the foreground.
The configuration of the push notifications is executed in the componentWillMount
method in App.js
.
My setup is:
- react-native:
0.59.5
- react-native-push-notifications:
3.1.9
Thanks in advance!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:57
Top Results From Across the Web
android - Hide notification from Foreground Service on click ...
You have to use .setOngoing(false) to dismiss the notification. Share.
Read more >Handling Notifications and Notification-Related Actions
Tapping one of the buttons forwards the selected action to your app, without bringing the app to the foreground. If your app supports...
Read more >Receiving Notifications - Expo Documentation
On Android, users can set certain OS-level settings (usually revolving around performance and battery optimisation), that can prevent notifications from being ...
Read more >App notification content - Windows apps | Microsoft Learn
Using a selection menu and two buttons, we can create a reminder notification that utilizes the system snooze and dismiss actions. Make sure...
Read more >[Cloud Messaging Plugin (Firebase)] App doesn't open on ...
When we click on the notification then app opens when in background but when is in foreground and the user gets push notification...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So far it seems to work like a glove! I also like the new way of handling the actions. Good work! I will let you know if I find any issues or bugs.
I strongly believe that Open Source Development should be supported more. If you are the new maintainer of this project @Dallas62 and enable Sponsoring for this repo I will be happy to show my support and gratitude 😃
@Dallas62 Hi! Is it possible to prevent app invocation on action press on iOS?