Skip to content

How to stop the headless task? #24

Open
@ajaykumar97

Description

@ajaykumar97

I have successfully implemented the react-native-sync-adapter and is working fine for the foreground and background sync. But the main issue is, I want to stop the sync interval task after single sync. I want to sync the data only once when user taps on the sync button in the application. Can anyone help me how to achieve that?

I am registering the task like:

const TASK_ID = 'TASK_SYNC_ADAPTER';

AppRegistry.registerComponent(appName, () => SyncAdapterExample);
AppRegistry.registerCancellableHeadlessTask(
    TASK_ID,
    () => TestTask,
    () => {},
);

And canceling the task after my operation has been completed in TestTask.js file like:

const TASK_ID = 'TASK_SYNC_ADAPTER';
AppRegistry.cancelHeadlessTask(TASK_ID, TASK_ID);

But I am getting an error while canceling the task:

TypeError: taskCancelProvider() is not a function. (In 'taskCancelProvider()()', 'taskCancelProvider()' is undefined)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions