Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native: Use Push Notification to wake a background task

As far as I know, push notification can be used in react native, even when the app is closed. would it be possible to use push notification to run a background task in react native?

for example, when a push notification is sent to a device, it runs a function to fetch data from server and update database.

https://github.com/zo0r/react-native-push-notification

like image 270
Ata Mohammadi Avatar asked Oct 16 '16 09:10

Ata Mohammadi


1 Answers

Push notification and data notification handling part could be done using react-native-firebase easily (I recommend to use react-native-firebase instead of react-native-push-notification because it has wide community support and support for many more firebase services)

And in here it show how to fetch data in background for iOS; with the few modification same thing could be done in android also.

Useful links :

  • https://rnfirebase.io/messaging/usage
  • https://www.npmjs.com/package/react-native-background-task
like image 188
EL173 Avatar answered Sep 25 '22 12:09

EL173