zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.76k stars 2.05k forks source link

How to handle notification when app is closed(not background mode) #700

Closed leventyildirim61 closed 4 years ago

leventyildirim61 commented 6 years ago

Hello.

How to handle notification when app is closed(not background mode)

gusilveiramp commented 6 years ago

+1

devlargs commented 6 years ago

Create an app exit listener and fire:

PushNotifications.cancelAllLocalNotifications()

gusilveiramp commented 6 years ago

@devlargs Thanks for tip, but how? How to create an exit listener? And why call PushNotifications.cancelAllLocalNotifications() if this function remove all listeners? Could you explain better or give an example?

devlargs commented 6 years ago

Hi. I surely misunderstood this one. I thought you're saying how to remove a notification after you close the app.

If you are going to push a notification when the app is closed, you need another plugin for that. As for what I am using:

https://github.com/jamesisaac/react-native-background-task. (but the task fires for a minimum time of 7m30s).

But if you are going to fire a notification from one phone to another phone (like chatting... etc), Im not sure that feature is supported yet.

See also: https://github.com/zo0r/react-native-push-notification/issues/219

github-actions[bot] commented 4 years ago

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.