简体   繁体   中英

react native background API calls on iOS

I have an app that do recursive calls to a API after every min or so it is working fine while app is active but not working when it is in background.

I tested the same app on android and even in the background it work fine, but on iOS it stop calling the API.

Am I missing something or what should I do to resolve it?

Any quick help please?

In January 2018 there are better options (hooray for progress!). This can now be done entirely in JS cross platform in react native using react native queue and react native background task .

Here's a walkthrough for setting this up.

However, there are limitations:

  • The smallest interval of time between task execution is ~15 min.
  • The background task has a timeout limit of 30 seconds.
  • The task schedule is approximate. iOS/Android use battery life, current cpu load, etc to determine if a scheduled task can be executed or if execution should be delayed or even cancelled. It will generally run when you want it to, but don't expect the timing to be exact.

As of January 2017, you have a few options, but none are native for iOS right now—it's something they're working on . For Android (although it seems you have this solved) you can use Headless.js .

For iOS you have a few options, depending on your task:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM