Skip to content Skip to sidebar Skip to footer

React Native Headlessjs Task Call With Android Workmanager

I'm creating a React Native background sync task with Android WorkManager. The doWork method in WorkManager class is called periodically, correctly. The problem I'm facing is how t

Solution 1:

You need start your task as a service:

@Nonnull@Overridepublic Result doWork() {
    Intentservice=newIntent(getApplicationContext(), SyncHeadlessTaskService.class);
    Bundlebundle=newBundle();
    bundle.putString("foo", "bar");
    service.putExtras(bundle);
    getApplicationContext().startService(service);
    return Result.success();
}

Don't forget to configure your AndroidManifest:

<serviceandroid:name="your.package.SyncHeadlessTaskService" />

Post a Comment for "React Native Headlessjs Task Call With Android Workmanager"