Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making periodic network calls when iOS app is in background

Tags:

networking

ios

I'm currently working on an app that should periodically (every minute) perform a network call while the app is backgrounded or killed. This network call will send information to our API.

Is this possible on iOS? How?

like image 728
Steven B. Avatar asked Feb 10 '16 14:02

Steven B.


People also ask

Will iOS terminate the app running in background after a specific time?

At the same time, didReceiveMemoryWarning is invoked for the app. At this point, so that your app continues to run properly, the OS begins terminating apps in the background to free some memory. Once all background apps are terminated, if your app still needs more memory, the OS terminates your app.

How do I keep an app running in the background on iPhone?

For iOS Devices If Background refresh is greyed out in the ON position, go To Settings App - > General - > Background App Refresh - > Turn on the option for the system, and then you can turn on / off by app.

How can we execute code when app is not running?

If you need to execute code when your app isn't running, there are several options open to you depending on what you're trying to do. Background fetch will let your app run in the background for about 30 seconds at scheduled intervals. The goal of this is to fetch data and prepare your UI for when the app runs next.

Does Apple allow apps to run in background?

Helpful answersThe only apps that are really running in the background are music or navigation apps. Go to Settings>General>Background App Refresh and you can see what other apps are allowed to update data in the background. iOS dynamically manages memory without any user intervention. Thank you!


1 Answers

Assuming you want a service like a Social Media app, where it will check in the background every minute for new activity, you should use background execution.

Have a look at this Background Execution tutorial and the Apple Reference for Background Execution.

like image 139
brimstone Avatar answered Oct 29 '22 23:10

brimstone