Can't simulate background fetch event multiple times - just once
See original GitHub issueYour Environment
- Plugin version: 2.4.3
- Platform: Android
- OS version: 7, 8
- React Native version (
react-native -v
): 0.52.1 - Plugin config Inside App.js
async componentDidMount() {
BackgroundFetch.configure({
enableHeadless: true,
minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed)
stopOnTerminate: false, // <-- Android-only,
startOnBoot: true // <-- Android-only
}, async () => {console.log("BF: APP.JS");
await someAsyncFunction();
BackgroundFetch.finish(BackgroundFetch.FETCH_RESULT_NEW_DATA);
}, (error) => {
console.log("RNBackgroundFetch failed to start");
});
Expected Behavior
To simulate background fetch event on device with command:
adb shell cmd jobscheduler run -f com.scoutsssag.app 999
multiple times
Actual Behavior
I run adb shell cmd jobscheduler run -f com.scoutsssag.app 999
once
and after 1min I try again nothing happens.
Is this normal or should be possible?
This is log when I simulate first time:
$ adb logcat *:S ReactNative:V ReactNativeJS:V TSBackgroundFetch:V
--------- beginning of crash
--------- beginning of system
--------- beginning of main
09-19 11:10:04.493 27409 27409 D TSBackgroundFetch: - onStopJob
09-19 11:12:13.821 27409 27409 D TSBackgroundFetch: - Background Fetch event received
When I execute same command again nothing in logs.
In this logs you can see at 11:34:43 I get onStopJob and then I was able to execute simulate command again but I got only received log my code is not executed.
--------- beginning of main
09-19 11:10:04.493 27409 27409 D TSBackgroundFetch: - onStopJob
09-19 11:12:13.821 27409 27409 D TSBackgroundFetch: - Background Fetch event received
09-19 11:22:13.840 27409 27409 D TSBackgroundFetch: - onStopJob
09-19 11:24:43.088 27409 27409 D TSBackgroundFetch: - Background Fetch event received
09-19 11:34:43.118 27409 27409 D TSBackgroundFetch: - onStopJob
09-19 11:35:14.352 27409 27409 D TSBackgroundFetch: - Background Fetch event received
Here are logs I left the phone still not touching app. You can see that in a first background fetch it entered function and executed code “TOTAL: 30” but see logs after it, I don’t understand what could be cause of this:
09-19 11:53:28.116 5471 5471 D TSBackgroundFetch: - Background Fetch event received
09-19 11:53:28.128 5471 5560 I ReactNativeJS: ENTERED APP.JS
09-19 11:53:28.132 5471 5560 I ReactNativeJS: INSIDE FUNCTION IN APP.JS
09-19 11:53:32.991 5471 5560 I ReactNativeJS: 'TOTAL: ', 30
09-19 12:03:28.125 5471 5471 D TSBackgroundFetch: - onStopJob
09-19 12:03:58.244 5471 5471 D TSBackgroundFetch: - Background Fetch event received
09-19 12:03:58.248 5471 5560 I ReactNativeJS: BF: APP.JS
09-19 12:03:58.249 5471 5560 I ReactNativeJS: INSIDE FUNCTION
09-19 12:13:58.252 5471 5471 D TSBackgroundFetch: - onStopJob
09-19 12:14:58.361 5471 5471 D TSBackgroundFetch: - Background Fetch event received
09-19 12:14:58.365 5471 5560 I ReactNativeJS: BF: APP.JS
09-19 12:14:58.365 5471 5560 I ReactNativeJS: INSIDE FUNCTION
09-19 12:24:58.368 5471 5471 D TSBackgroundFetch: - onStopJob
09-19 12:28:11.661 5471 5471 D TSBackgroundFetch: - Background Fetch event received
09-19 12:28:11.694 5471 5560 I ReactNativeJS: BF: APP.JS
09-19 12:28:11.695 5471 5560 I ReactNativeJS: INSIDE FUNCTION
09-19 12:38:11.700 5471 5471 D TSBackgroundFetch: - onStopJob
09-19 12:42:01.618 5471 5560 I ReactNativeJS: remote-redux-devtools: Socket connection errors are being suppressed.
09-19 12:42:01.618 5471 5560 I ReactNativeJS: This can be disabled by setting suppressConnectErrors to 'false'.
09-19 12:42:01.620 5471 5560 I ReactNativeJS: [SocketProtocolError: Socket closed without status code]
09-19 12:43:11.702 5471 5471 D TSBackgroundFetch: - Background Fetch event received
09-19 12:43:11.704 5471 5560 I ReactNativeJS: BF: APP.JS
09-19 12:43:11.705 5471 5560 I ReactNativeJS: INSIDE FUNCTION
09-19 12:53:11.711 5471 5471 D TSBackgroundFetch: - onStopJob
09-19 13:02:45.730 5471 5471 D TSBackgroundFetch: - Background Fetch event received
09-19 13:02:45.741 5471 5560 I ReactNativeJS: BF: APP.JS
09-19 13:02:45.741 5471 5560 I ReactNativeJS: INSIDE FUNCTION
09-19 13:12:45.745 5471 5471 D TSBackgroundFetch: - onStopJob
I noticed that I can simulate call again when I receive onStopJob in log. But again then it doesn’t complete function like first time.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
News on what? This issue is closed.
I have no idea.