Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onNotification() is not fired when app is in background. #652

Closed
kckunal2612 opened this issue Feb 20, 2018 · 9 comments
Closed

onNotification() is not fired when app is in background. #652

kckunal2612 opened this issue Feb 20, 2018 · 9 comments
Labels

Comments

@kckunal2612
Copy link

I am able to get logs on the console from onNotification() method when app is open (in foreground), but not getting any when app is closed (not killed).

Here is my code -

PushNotification.configure({
            // (required) Called when a remote or local notification is opened or received
            onNotification: function (notification) {
                console.log(notification);
            },
            // IOS ONLY (optional): default: all - Permissions to register.
            permissions: {
                alert: true,
                badge: true,
                sound: true
            },
            // Should the initial notification be popped automatically
            // default: true
            popInitialNotification: true,
            /**
.....

@atebit
Copy link

atebit commented Feb 22, 2018

it not supposed to be in the component tree, hope that helps.

@Husseinhj
Copy link

same problem

@xinhash
Copy link

xinhash commented Mar 14, 2018

@atebit Unable to understand what your wrote. Should we place PushNotification.configure() outside of the component

@vvavdiya
Copy link

This might be helpful.

@iamrutvik
Copy link

React Native Push Notifications clearly states that we need to call configure outside of the React Native Lifecycle. This is very important.

https://product.farewell.io/visible-react-native-push-notifications-that-work-on-both-ios-and-android-5e90badb4a0f

https://prnt.sc/k61hz7

@sergiulucaci
Copy link

Having the same issue, @kckunal2612 any workaround?

@atebit
Copy link

atebit commented Apr 15, 2019

Do not put PushNotification.configure inside of a React.Component, it must be outside of the React rendering lifecycle. If you put the PushNotification.configure on your index.js file and a console.log, you will see it working.

This can be closed as it's not an issue...

@tomthornton
Copy link

@atebit why is this the way it is? I need to navigate and do react things in the onNotification() call back.

@github-actions
Copy link

github-actions bot commented May 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label May 8, 2021
@github-actions github-actions bot closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants