-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background timer working on Android, but not iOS #54
Comments
did you solve this issue? |
No I'm still clueless. It simply does not work. |
I'm having iOS issues as well, the Background time fires without issue on the Simulator but on a device (iphone 7s ios 10.3) the Not sure what to do here, I'm currently only starting up the BackgroundTask by monitoring the RN AppState, once it's in the background I kick off the BackgroundTimer. I'm on RN 0.47.1 and using this library |
I can't recall my timer firing even once in background mode (iPhone 6s). There are apparently some restrictions when it comes to Apple and background code execution that I've heard from people on stack overflow, but if your timer fires 5% of the time it sounds even weirder. I've given up on the timers for now and will try to use local notifications instead in order to pass information to the user while not having the app open. |
@DigohD - that's actually what I'm attempting to do here, is use local notifications. As soon as the app moves to the background almost all code stops executing after a few seconds making it incredibly difficult to fire local notifications on a given event since the code more or less is dead on an iOS device. The only way I can see this working is with remote notifications if the BackgroundTimer doesn't work. |
I have the same problems. On Android a background process still runs when I minimize the app, but when I minimize the same app on iOS the background process stops working. When I return back to the app the process continues.. Also using RN 0.47.1 and using this library v1.2.0 |
I have the same problems on iPhone devices. but it is ok on the Simulator. RN 0.45 |
So this library is probably never going to work unless they implement a feature similar to
so every 15 seconds I'm doing my background tasks. |
I'm afraid I'm facing even more grave issue: timers won't fire in iOS at all, even when the app is in the foreground. I've just created a sample app (react-native init) and put BackgroundTimer.setInterval() inside componentDidMount(), which works perfectly fine on Android (even in background unless app is killed from recent apps) react-native v0.47.2 |
thanks |
I have the same problem since I upgrade react native to 0.47.2 and this plugin to 1.2.0. the timer work if app is in foreground but not in background. |
It worked before for me... but i've got this bug in regression from QAs... Background timer keep working when app in forground but stops when in background. Strange. Going to check. |
More or less this library won't really ever work again - basically it's going to be less and less reliable as versions of android/ios continue to grow. Explained very well below transistorsoft/react-native-background-geolocation#311 (comment) |
Currently I use react-native-background-geolocation heartbeat for iOS and react-native-background-timer for Android to send the GPS coordinates to a remote server in background mode. However, reading the comments here (and on transistorsoft/react-native-background-geolocation#311 (comment)) I have the feeling my current implementation is not really future proof. Am I correct? What is a future proof solution with React Native to automatically send GPS coordinates in background mode? Could I better invest in a solution using Native Modules? |
Yeah, this is going to be a problem... |
I believe Apple does not support running infinite/long tasks in background mode, even this lib does not work as when the app goes in background mode the iOS seems to stop the background thread. |
@ParthBarot-BoTreeConsulting Precisely. This has been known for years in iOS. Once-upon-a-time, Apple allowed these tasks to last 10 minutes. They've shrunk it down to exactly 180 seconds since iOS 6 or 7 due to app developers abusing this mechanism, killing their customers' device battery. |
Fix with workaround added. Timer will work while iOS allows to run background task. |
180 seconds max in background. That's all iOS will allow a |
Correction: iOS 11.1 now seems to have decreased the background-time to ~40 seconds. |
When running the same app on Android and iOS, it works perfectly on Android, but on iOS the timer pauses when either pressing the home button or the sleep button. What might I be doing wrong?
The text was updated successfully, but these errors were encountered: