Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

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

Closed
anuj47billion opened this issue Aug 20, 2020 · 18 comments
Labels

Comments

@anuj47billion
Copy link

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,
});

@Dallas62
Copy link
Collaborator

Hi,

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

@anuj47billion
Copy link
Author

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

@Dallas62
Copy link
Collaborator

Does the user interact with the notification ?

@anuj47billion
Copy link
Author

Yes set the userInteraction parameter as true

@Dallas62
Copy link
Collaborator

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

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

@anuj47billion
Copy link
Author

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

@Dallas62
Copy link
Collaborator

Did you test the example project ?

@anuj47billion
Copy link
Author

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

@Dallas62
Copy link
Collaborator

Did you looked at: #1592

@anuj47billion
Copy link
Author

Yes @Dallas62 but not succeed

@Dallas62
Copy link
Collaborator

Can't do more without a reproducible example.

@anuj47billion
Copy link
Author

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

@Dallas62
Copy link
Collaborator

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.

@kirantripathi
Copy link

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

@Dallas62
Copy link
Collaborator

Dallas62 commented Sep 2, 2020

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

@kirantripathi
Copy link

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 ?

@Dallas62
Copy link
Collaborator

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

@github-actions
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants