-
Notifications
You must be signed in to change notification settings - Fork 194
Description
#85 Your Environment
- Plugin version:3.1.0
- Platform: Android
- OS version: 8.1
- Device manufacturer / model: Xiaomi Redmi 6A
- React Native version (
react-native -v
): 0.61.5 - Plugin config
BackgroundFetch.configure(
{
minimumFetchInterval: 15,
enableHeadless: true,
stopOnTerminate: false,
startOnBoot: true,
forceAlarmManager: false,
requiredNetworkType: BackgroundFetch.NETWORK_TYPE_NONE,
},
async taskId => {
await this.sendRemainigData();
BackgroundFetch.finish(taskId);
},
error => {
console.log('[js] RNBackgroundFetch failed to start');
}
);
Expected Behavior
Headless task should execute.
Actual Behavior
Headless task is not executing.
Steps to Reproduce
- In index.js (Project level) i have defined -
let MyHeadlessTask = async ({ taskId }) => {
let response = await doRequest({
method: REQUEST_TYPE.POST,
url: '/initial-data',
data: { ...data },
});
let responseJson = await response.json();
BackgroundFetch.finish(taskId);
};
BackgroundFetch.registerHeadlessTask(MyHeadlessTask);
- In home component I'm defining BackgroundFetch.configure as code above in componentDidMount of Home page of app.
- If app is opened or in background task is executed after every 15 minutes. After i close my app. I am not able to hit the api in background via headless task.
- Also in xiomi phone i have remove the app from battery optimization list as well.
Context
Send an API call even after app is closed every 15 minutes.
Debug logs
07-29 15:23:26.668 17363 17363 D ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
07-29 15:23:26.670 17363 17363 D ReactNative: ReactInstanceManager.recreateReactContextInBackground()
07-29 15:23:26.670 17363 17363 D ReactNative: ReactInstanceManager.runCreateReactContextOnNewThread()
07-29 15:23:26.670 17363 17363 D ReactNative: ReactInstanceManager.tearDownReactContext()
07-29 15:23:26.685 17363 17363 D ReactNative: CatalystInstanceImpl.destroy() start
07-29 15:23:26.690 17363 18958 D ReactNative: ReactInstanceManager.createReactContext()
07-29 15:23:26.692 17363 17745 I ReactNative: [GESTURE HANDLER] Tearing down gesture handler registered for root view com.facebook.react.ReactRootView{8517d19 V.E...... ......ID 0,0-720,1294}
07-29 15:23:26.742 17363 18958 D ReactNative: Initializing React Xplat Bridge.
07-29 15:23:26.746 17363 18958 D ReactNative: Initializing React Xplat Bridge before initializeBridge
07-29 15:23:26.754 17363 18958 D ReactNative: Initializing React Xplat Bridge after initializeBridge
07-29 15:23:26.754 17363 18958 D ReactNative: CatalystInstanceImpl.runJSBundle()
07-29 15:23:26.757 17363 18961 D ReactNative: ReactInstanceManager.setupReactContext()
07-29 15:23:26.758 17363 18961 D ReactNative: CatalystInstanceImpl.initialize()
07-29 15:23:26.762 17363 18961 D ReactNative: ReactInstanceManager.attachRootViewToInstance()
07-29 15:23:27.054 17363 17497 D ReactNative: CatalystInstanceImpl.destroy() end
07-29 15:23:29.533 17363 18960 I ReactNativeJS: Running "rexxar" with {"rootTag":11}
07-29 15:23:29.705 17363 18960 I ReactNativeJS: BackgroundFetch is enabled
07-29 15:23:29.856 17363 18961 D TSBackgroundFetch: - configure
07-29 15:23:29.857 17363 18961 D TSBackgroundFetch: - start
07-29 15:23:29.857 17363 18961 D TSBackgroundFetch: - registerTask: react-native-background-fetch
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: {
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "taskId": "react-native-background-fetch",
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "isFetchTask": true,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "minimumFetchInterval": 15,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "stopOnTerminate": false,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "requiredNetworkType": 0,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "requiresBatteryNotLow": false,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "requiresCharging": false,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "requiresDeviceIdle": false,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "requiresStorageNotLow": false,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "startOnBoot": true,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "jobService": "com.transistorsoft.rnbackgroundfetch.HeadlessTask",
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "forceAlarmManager": false,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "periodic": true,
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: "delay": -1
07-29 15:23:29.859 17363 18961 D TSBackgroundFetch: }
07-29 15:23:29.897 17363 17363 D TSBackgroundFetch: - Background Fetch event received
07-29 15:23:31.389 17363 17363 I ReactNative: [GESTURE HANDLER] Initialize gesture handler for root view com.facebook.react.ReactRootView{8517d19 V.E...... ......ID 0,0-720,1294 #b}
07-29 15:23:31.432 17363 18961 D TSBackgroundFetch: - finish: react-native-background-fetch
07-29 15:23:31.432 17363 18961 D TSBackgroundFetch: - jobFinished
07-29 15:23:33.641 17363 18960 I ReactNativeJS: 'response ---', { status: true, data: {}, message: 'feed saved' }