jamesisaac / react-native-background-task

Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.
MIT License
1.1k stars 111 forks source link

Register Headless js #84

Open valiaghaei opened 3 years ago

valiaghaei commented 3 years ago

Hi it does not work for me and I got warning register headless js , i want to run this code in background BackgroundTask.define(() => { console.log('Hello from a background task'); BackgroundTask.finish(); }); but I do not you what exactly should i register in headless js ? could you please anyone help me

vestronv commented 2 years ago

As per -> https://github.com/jamesisaac/react-native-background-task#android

Android

The linking of the library can be done automatically by running:

react-native link react-native-background-task

One manual step is still needed - in your project file `android/app/src/main/java/myapp/MainApplication.java`, add the following to the end of the `onCreate()` method:

BackgroundTaskPackage.useContext(this);