Skip to content

A react native library [For Android] that allows you to run a background service forever (even when the user terminates the app or restart the phone)

License

Notifications You must be signed in to change notification settings

kendhia/react-background-jobs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

react-native-background-jobs

Getting started

$ npm install react-native-background-jobs --save

Mostly automatic installation

Linking is done automatically.

Usage

  1. 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" />
  1. 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...")
    };
    

// TODO:Enrich the Readme

I know this readme file might not be so much understandable. I'll try to update it asap.

About

A react native library [For Android] that allows you to run a background service forever (even when the user terminates the app or restart the phone)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published