rn-foreground-service
v1.0.8
Published
```npm i rn-foreground-service```
Downloads
6
Readme
Installation:
npm i rn-foreground-service
Usage:
<Button title="start service" color={'green'} onPress={()=>{RNForegroundService.toggle(1).then(res=>log(res))}}/>
<Button title="Stop service" color={'red'} onPress={()=>{RNForegroundService.toggle(0).then(res=>log(res))}}/>
// if you stopped the service and restarted the device then it won't start the service automatically.
// I will add this functionality in next update. For now I am not using the services in my app anymore.
You Might need to make some changes in AndroidManifest.xml
<application>
...
<service
android:name=".ObserverService"
android:enabled="true"
android:exported="true" >
</service>
<receiver android:name=".StartupReceiver" android:enabled="true" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
...
</application>
Also add permissions
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />