Minimize and run an app in the background - ios

Can an app go into background execution and minimize itself, but execute a code to perform a certain action (recording the screen to be specific) in iOS Swift.

Programming Guide: Background Execution
This should help get you started. But you can't do what you want to do for longer than three minutes and you won't be able to put in on the app store.

Related

How to do a request in background each 5 minutes in iOS

I have an iOS application that communicate with an IoT gadget
And now I need a to do a request for an API each 5 minutes when the iOS app enters in background
I know this is horrible for battery consuming but in this specific case this is irrelevant since my iPhone device will always be connected to charger, and I won’t need this app in the store, so the apple politics is not a problem too
I already tried use Timer and TimerInterval, with the background state activated but none of then execute after the time I defined
Has any way to do this ?
Edit: I all my attempts I already activated background fetch, background music and all background modes
First you need to start background mode in your project. It looks like this:
To get to the background modes capability list you:
Select the project from the Project navigator.
Click the app target.
Select the Capabilities tab.
Turn the Background Modes switch on.
If you want to perform background task then select it from capability.
For more clarity for background fetch you can check below link
https://www.ioscreator.com/tutorials/background-fetch-ios-tutorial

Is iOS Background fetch triggered only in background mode?

I am working on the iOS app, that needs periodic downloads from the server both in active and background mode. I know that for the Background mode there is a possibility to use Background Fetch functionality. However, I did not find if Background Fetch works in active mode as well.
Can some body tell me if it does work?
Or if it doesn't, what is the best solution to get some data periodically on iOS app (basically indefinitely until the app is terminated)?
The way to achieve what you want to do is by using background fetches. (as you are doing).
As the apple documentation saids:
The system wakes the app at opportunistic moments to begin downloading
new content.
That means that your app doesn't needs to be in background mode, it will be waked up.
This method will run over arbitrary intervals, depending on how well your app behaves in terms time consumption and energy usage.

Appending data inside a tableView in the background - iOS

My app works like this - you press an uibutton and it starts appending data inside a tableView with a specific delay, cell by cell. Sometimes it may take hours to append, because of the manually set delay parameter.
The problem is each time i switch it to background - the app gets suspended after several minutes (up to five usually) and the whole process breaks.
Is there any approach to handling this situation?
Thank you.
That's the designed behavior, an app return to background normally only have very short active time, then it will be suspended, but there are some exceptions:
Apps that play audible content to the user while in the background, such as
Music player app
Apps that record audio content while in the background
Apps that keep users informed of their location at all times, such as a navigation app
Apps that support Voice over Internet Protocol (VoIP)
Apps that need to download and process new content regularly
Apps that receive regular updates from external accessories
Basically speaking, if your app need to interact with outside for resource that can not be generated inside your app, you can apply for background running.
Any every app can legally apply a background task to run for a short time when the app enter background mode.
In your case, even if you implemented the background running, your app will possibly be rejected. If your app is doing the adding to table action controlled by a timer, you should be able to simulate the behavior yourself.
save a the system time stamp locally, maybe in UserDefault
when app launch or enter foreground, get the system time, you can calculate the time difference and figure out how many actions you should take and perform that with a batch action.
after that, clear the saved time stamp ensure next time your data won't be messed up.

How and when iOS kills an app which is in background for long time?

I want to know what happens when the app comes to foreground after being in background for long time? How basically iOS works to free up memory and how it kills the app.
Check The App Life Cycle document. Execution States for Apps in particular.

Navigation stops after 15 min in background skobbler

I am using Skobbler sdk in my application for navigation. I need to continuously send data of navigation to other device. But the navigation in background works for only 15 minutes after that it stops navigating in background. I have also tried enabling the following key value pairs in plist :
Required Background modes-
1. App registers for location updates
2. App downloads content from the network
Please suggest some help.
Please test this in a real situation, like actually driving while using the app with navigation type being SKNavigationTypeReal.
Background apps are suspended after some time and only activated when they actually receive GPS location updates. Your app will never resume if the device is not actually moving.
This is an optimization done by Apple to improve battery life.
Some more info about background modes:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
The next release will include an API to disable this behavior.

Resources