Reputation: 2014
We are building an IOS app with a webview control. Webview loads a react application hosted on a webserver. React application(from webview) has a short internal polling api calls to hit api server every 20 seconds to get latest data.
However, currently when the app goes to background, webview and the polling network calls are suspended. When i bring the app to foreground, it logs as network error.
How do we allow the webview to keep making polling calls even when the app goes to background?
Upvotes: 1
Views: 2002
Reputation: 2103
Polling from the background, especially at 20s is not only a bad practice, but will probably get your app rejected. What you should do:
This workflow will work with quick background/foreground switches as your Interval is deleted and re-created asap.
Upvotes: 0
Reputation: 639
For this, you will have to allow the background processing of the data. In your Xcode under signing and capabilities, you will have to add background capability.
Upvotes: 1