jamesisaac / react-native-background-task

Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.
MIT License
1.1k stars 111 forks source link

Nothing happened when job is finished #72

Open rafalkowalewski opened 5 years ago

rafalkowalewski commented 5 years ago

When I run my taskts and look for any console response, I see only this:

06-09 23:27:06.986 25351 25351 D BackgroundTask: Committing job schedule 06-09 23:34:37.407 25351 26893 D BackgroundTask: Job is running

and nothing happened. AsyncStorage is empty, console log were not triggered...

Any idea?

Android 9, `"dependencies": { "haversine": "^1.1.1", "lottie-react-native": "^2.6.1", "native-base": "^2.12.1", "react": "16.8.3", "react-native": "0.59.8", "react-native-background-task": "^0.2.1", "react-native-camera": "^2.9.0", "react-native-gesture-handler": "^1.2.1", "react-native-maps": "^0.24.2", "react-native-push-notification": "3.1.1", "react-native-queue": "^1.2.1", "react-navigation": "^3.11.0", "react-redux": "^7.0.3", "redux": "^4.0.1", "redux-persist": "^5.10.0", "redux-thunk": "^2.3.0" },

alexCarb commented 5 years ago

the same

rafalkowalewski commented 5 years ago

I added this permission and it started working :) <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

rayjadore commented 5 years ago

didnt work for me even after adding the permission, so the thing is that the define() method is never triggered.

qlerebours commented 4 years ago

For those facing this issue, there is a PR that fixed this for Android 8.0+ https://github.com/jamesisaac/react-native-background-task/pull/64

mathiasmoeller commented 4 years ago

The fix in #64 did not solve the issue for me. I am still seeing this behavior.

03-06 13:58:27.010 27548 27641 D BackgroundTask: Initializing
03-06 13:58:27.017 27548 27548 D BackgroundTask: Setting foreground true
03-06 13:58:29.370 27548 27641 D BackgroundTask: @ReactMethod BackgroundTask.schedule
03-06 13:58:50.199 27548 27548 D BackgroundTask: Setting foreground false
03-06 13:58:50.199 27548 27548 D BackgroundTask: Committing job schedule
03-06 14:06:42.622 30274 30326 D BackgroundTask: Job is running
03-06 14:07:14.506 30515 30585 D BackgroundTask: Job is running
03-06 14:08:26.622 30623 30675 D BackgroundTask: Job is running

I call BackgroundTask.define directly in index.js on root level and BackgroundTask.schedule from inside a Compontent. The job should save a dummy value in AsyncStorage. Which it doesn't. Any ideas or any progress on that?

Ravi828rk commented 2 years ago

any solution?