I'm trying to create background service in Android Oreo using react-native-background-job
but when I'll start the service is call success but Showing crash dialog service is stopped. please provide a solution for this problem.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(starter);
}
else {
context.startService(starter);
}
You are not allowed to start background service using
startForegroundService
- if service doesn't elevate itself into the foreground withstartForeground
and notification within 5 seconds, it will be killed by the system.Take a look at related question and answers.
I got the solution in for
react-native-background-job
android/src/main/java/com/pilloxa/backgroundjob/ReactNativeEventStarter.java