Open RustamG opened 5 years ago
same problem: Fix by add this line
public static final String ON_ENTER = "onEnter";
public static final String ON_EXIT = "onExit";
final Handler handler = new Handler();
public BoundaryEventJobIntentService() {
super();
}
boolean workSuccessful = true;
....
private void sendEvent(final Context context, final String event,final ArrayList<String> params) {
if(workSuccessful) {
workSuccessful= false;
final Intent intent = new Intent(RNBoundaryModule.GEOFENCE_DATA_TO_EMIT);
intent.putExtra("event", event);
intent.putExtra("params", params);
Bundle bundle = new Bundle();
bundle.putString("event", event);
bundle.putStringArrayList("ids", intent.getStringArrayListExtra("params"));
Intent headlessBoundaryIntent = new Intent(context, BoundaryEventHeadlessTaskService.class);
headlessBoundaryIntent.putExtras(bundle);
context.startService(headlessBoundaryIntent);
HeadlessJsTaskService.acquireWakeLockNow(context);
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForeground(1, new Notification());
}
workSuccessful = true;
}
}, 6000);
}
}
@Override
public void onCreate() {
super.onCreate();
startForeground(1, new Notification());
}
you should create another file to replace this file using : postinstall: cp BoundaryEventJobIntentService.java /node_modules/...
Workarround: https://stackoverflow.com/questions/44425584/context-startforegroundservice-did-not-then-call-service-startforeground
With the fork: https://github.com/woffu/react-native-boundary And the proposal of pull request (https://github.com/eddieowens/react-native-boundary/pull/46) there is a fix for this issue using the startForegroundService() with a notification
Any news on this topic? Will the PR be merged?
Hey @woffu. Your fix worked fine for me. Thanks a lot! But I still have issues with the Headless event. It seems like my callback is registered AFTER the Headless event is fired. I tried to explain it more in #55. You seem to have a decent understanding of this project. Could you maybe help me out? It would be very much appreciated!!
Hi @eddieowens,
In Android 8 and up it's not possible to start services when your app is in background. Proof
If you try to do so, you get an error. Here is a log with stack trace:
So the cause is this line.
Is this something we might hope to get fixed? And what would be ETA?
Thanks.
EDIT: targetSdkVersion should be 26 or higher