1.1.1 • Published 5 years ago
react-native-background-jobs v1.1.1
react-native-background-jobs
Getting started
$ npm install react-native-background-jobs --save
Mostly automatic installation
Linking is done automatically.
Usage
- Open up
android/app/src/main/AndroidManifest
- Add
<service android:name="kendhia.reactlibrary.BackgroundJobsService" />
. - Add the following permissions:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
- Inside your
index.js
- Register the service the same way you register your app.
AppRegistry.registerHeadlessTask('BackgroundJobsEvent', () => BackgroundJobsEvent);
- Now, you can define the code you want to be running forever. Ex:
const BackgroundJobsEvent = async () => { console.log("running forever...") };
- Register the service the same way you register your app.
// TODO:Enrich the Readme I know this readme file might not be so much understandable. I'll try to update it asap.