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

onNotification is not called when local notification arrives and app is in background in android

Open anuj47billion opened this issue 6 years ago • 18 comments

Code for Local Noification

PushNotification.localNotification({ autoCancel: true, title: 'Test Title', message: 'Test Message', vibrate: true, vibration: 1000, playSound: false, data: {}, });

Trying to get in configure onNotification

PushNotification.configure({ onRegister: function(token) { console.log('TOKEN:', token); }, onNotification: function(notification) { console.log('NOTIFICATION:', notification); }, permissions: { alert: true, badge: true, sound: true, }, popInitialNotification: true, requestPermissions: true, });

anuj47billion avatar Aug 20 '20 06:08 anuj47billion

Hi,

onNotification will not be called for local/scheduled notifications if there is no user interaction.

Dallas62 avatar Aug 20 '20 08:08 Dallas62

@Dallas62 , It still not working when the app is in background

anuj47billion avatar Aug 20 '20 08:08 anuj47billion

Does the user interact with the notification ?

Dallas62 avatar Aug 20 '20 08:08 Dallas62

Yes set the userInteraction parameter as true

anuj47billion avatar Aug 20 '20 08:08 anuj47billion

So the user Press the notification and onNotification is not called ?

Does .configure inside a component ? Do you have a splashscreen in your application ?

Dallas62 avatar Aug 20 '20 09:08 Dallas62

Yes onNotification in not called when user press in notifcation when app is in background. .configure is not inside a component. Not having splashscreen

anuj47billion avatar Aug 20 '20 09:08 anuj47billion

Did you test the example project ?

Dallas62 avatar Aug 20 '20 09:08 Dallas62

I compared AndroidManifest.xml from example folder and added all changes

anuj47billion avatar Aug 20 '20 09:08 anuj47billion

Did you looked at: https://github.com/zo0r/react-native-push-notification/issues/1592

Dallas62 avatar Aug 20 '20 09:08 Dallas62

Yes @Dallas62 but not succeed

anuj47billion avatar Aug 20 '20 09:08 anuj47billion

Can't do more without a reproducible example.

Dallas62 avatar Aug 20 '20 09:08 Dallas62

@Dallas62 , I also used PushNotification.popInitialNotification to fulfill my requirement but it also returns undefined randomly

anuj47billion avatar Aug 20 '20 12:08 anuj47billion

The initial notification is the notification which start the application, bring back to foreground an application in background doesn't change or set the initial notification.

Dallas62 avatar Aug 20 '20 12:08 Dallas62

Screen Shot 2020-09-02 at 15 00 59 onNotification function gets called in android , but. in ios I am having issue to get response in onNotification function . Do. you have any suggestion on that @Dallas62

kirantripathi avatar Sep 02 '20 09:09 kirantripathi

Yes this is an issue from the iOS library, looking into it. https://github.com/react-native-community/push-notification-ios/pull/122

Dallas62 avatar Sep 02 '20 10:09 Dallas62

Yes this is an issue from the iOS library, looking into it. react-native-community/push-notification-ios#122

do we have any idea on how we can tackle it ?

kirantripathi avatar Sep 02 '20 11:09 kirantripathi

Hi! You can test the version on dev branch, react-native-community/push-notification-ios#122 has been merged recently.

Dallas62 avatar Sep 12 '20 20:09 Dallas62

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[bot] avatar Sep 13 '21 00:09 github-actions[bot]