Question

This question might be duplicate of many others but I am still asking because I really need to get any solution of it.

For iOS versions prior to 6, for devices other than those having an A7 chip.

I have an application which interacts with the Accelerometer. I am also running it in background by playing a sound file and turning the Audio services ON for background task.

Now If any third application plays music, it takes control of shared Audio Session of device which causes my background thread to call completion handler assuming that background task has been completed.

Now my application is interruptible by iOS and iOS can kill it if it remains in background for a long time after which I couldn't interact with accelerometer.

Is there any way/trick/hack to keep my application running all the time until unless I kill it by my own.

Again, this is a duplicate question but I really wanted to share my problem with you people to help me in this sense.

Was it helpful?

Solution

Apple is very clear on this:

Implementing Long-Running Background Tasks

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:

Apps that play audible content to the user while in the background, such as a 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

Collecting accelerometer data is not listed. Therefore, what you are trying to do is not possible. "Ways, tricks, hacks" tend to get discovered quickly and offending apps removed from the App Store.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top