Comments (22)
did you solve this issue?
from react-native-background-timer.
No I'm still clueless. It simply does not work.
from react-native-background-timer.
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 BackgroundTimer.setInterval
will fire ~5% of the time. In testing I have said interval set to 10 seconds (10000ms) but on the rare occasion when the interval does fire, it kicks off a fetch method who's promise never returns/resolves until I open the app back up. Again everything works without issue in the iOS simulator.
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 1.2.0
from react-native-background-timer.
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.
from react-native-background-timer.
@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.
from react-native-background-timer.
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
from react-native-background-timer.
I have the same problems on iPhone devices.
but it is ok on the Simulator.
RN 0.45
this library v1.2.0
from react-native-background-timer.
So this library is probably never going to work unless they implement a feature similar to react-native-background-geolocation
. For now I'm using this library on Android, and for iOS I'm running the BackgroundGeolocation with an undocumented watcher BackgroundGeolocation.on('heartbeat', this.heartbeat.bind(this));
and in the config
preventSuspend: true,
heartbeatInterval: 15,
so every 15 seconds I'm doing my background tasks.
from react-native-background-timer.
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)
But no timers are fired whatsoever in iOS even when the app is up and running.
react-native v0.47.2
react-native-background-timer v1.2.0
simulator iPhone 6 - iOS 10.3 (14E8301)
from react-native-background-timer.
thanks
from react-native-background-timer.
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.
from react-native-background-timer.
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.
from react-native-background-timer.
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)
from react-native-background-timer.
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?
from react-native-background-timer.
Yeah, this is going to be a problem...
from react-native-background-timer.
Can't I just use react-native-background-timer?
No.
from react-native-background-timer.
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.
from react-native-background-timer.
@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.
from react-native-background-timer.
Fix with workaround added. Timer will work while iOS allows to run background task.
from react-native-background-timer.
180 seconds max in background. That's all iOS will allow a UIBackgroundTaskIdentifier
to live before forcefully executing your expirationHandler.
from react-native-background-timer.
Correction: iOS 11.1 now seems to have decreased the background-time to ~40 seconds.
from react-native-background-timer.
@Jlexyc #66 merged and v2.0.0 released
from react-native-background-timer.
Related Issues (20)
- Can I read and write files?
- The timer works perfectly fine in iOS simulator but not on hardware device HOT 3
- BackgroundTimer stops when app goes to background after Few Sec in IOS React Native IOS HOT 17
- runBackgroundTimer doesn't work on RN 66.3 - Tested on Android HOT 5
- Background service is not working if Background data usage disabled. HOT 1
- Using react-native-background-timer with react-native-web HOT 1
- Terminating app due to uncaught exception NSInternalInconsistencyException HOT 1
- how to get clipboard content on background service
- Testing background timer with useFakeTimers in Jest HOT 4
- Background Action and Graphql HOT 2
- the task is dying out HOT 8
- background task dosen't work when device is in sleep mode. HOT 7
- Is this repo still alive? HOT 5
- BackgroundTimer.clearTimeout does not stop ongoing background task
- Invariant Violation: new NativeEventEmitter() requires a non-null argument., js engine: hermes
- react-native-background-timer not working in android HOT 1
- after upgrading gradle version to 8.2.2 I'm getting this error: Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported. HOT 1
- React Native Background Task Termination on Device Lock in Android OS <= 13 HOT 1
- RangeError in long running timers HOT 1
- Problem build/config with MainApplication.kt
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-background-timer.