Giter Site home page Giter Site logo

Comments (22)

cinder92 avatar cinder92 commented on June 22, 2024

did you solve this issue?

from react-native-background-timer.

DigohD avatar DigohD commented on June 22, 2024

No I'm still clueless. It simply does not work.

from react-native-background-timer.

Metroninja avatar Metroninja commented on June 22, 2024

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.

DigohD avatar DigohD commented on June 22, 2024

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.

Metroninja avatar Metroninja commented on June 22, 2024

@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.

martijnplaat avatar martijnplaat commented on June 22, 2024

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.

perfecten avatar perfecten commented on June 22, 2024

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.

Metroninja avatar Metroninja commented on June 22, 2024

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.

y2k-shubham avatar y2k-shubham commented on June 22, 2024

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.

martijnplaat avatar martijnplaat commented on June 22, 2024

thanks

from react-native-background-timer.

orisystech avatar orisystech commented on June 22, 2024

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.

Jlexyc avatar Jlexyc commented on June 22, 2024

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.

Metroninja avatar Metroninja commented on June 22, 2024

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.

martijnplaat avatar martijnplaat commented on June 22, 2024

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.

willbattel avatar willbattel commented on June 22, 2024

Yeah, this is going to be a problem...

from react-native-background-timer.

christocracy avatar christocracy commented on June 22, 2024

Can't I just use react-native-background-timer?

No.

from react-native-background-timer.

ParthBarot-BoTreeConsulting avatar ParthBarot-BoTreeConsulting commented on June 22, 2024

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.

christocracy avatar christocracy commented on June 22, 2024

@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.

Jlexyc avatar Jlexyc commented on June 22, 2024

Fix with workaround added. Timer will work while iOS allows to run background task.

from react-native-background-timer.

christocracy avatar christocracy commented on June 22, 2024

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.

christocracy avatar christocracy commented on June 22, 2024

Correction: iOS 11.1 now seems to have decreased the background-time to ~40 seconds.

from react-native-background-timer.

ocetnik avatar ocetnik commented on June 22, 2024

@Jlexyc #66 merged and v2.0.0 released

from react-native-background-timer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.