Search code examples
iphoneactionscript-3uikitflash-builder

UIBackgroundModes location timeout


In Flash Builder I have an app for ios which will get Latitude and longitude using Geolocation every minute. I would like to run this in the background so I've added this to my Info.plist:

<key>UIBackgroundModes</key>
    <array>
        <string>location</string>
    </array>

This works, but only for 16 minutes every time. After that it just goes into suspension. When I unlock the phone the app runs again as it's supposed to, but it hasn't got the data after 16 minutes until the unlock.

http://blogs.adobe.com/airodynamics/2012/05/04/air-ios-background-behavior/

This link gave me some ideas. I added:

NativeApplication.nativeApplication.executeInBackground = true;

to my initial function, but no difference. Then I tried this:

<key>UIApplicationExitsOnSuspend</key>
       <false/>

but yet again no change.

My last possible idea is that this app is running on the device in development mode, not as distribution. Could that effect the background mode as the app has not been checked over by Apple?

Thanks

EDIT:

I have now tested my app in testFlight and it does the same thing, suspending after 16 minutes.


Solution

  • So the reason for this is due to not moving while testing. Ran my app while I went for a 30 minute walk with the phone locked and it worked the whole time.

    To change this you would need to access the CLLocation manager and change pausesLocationUpdatesAutomatically to false. Unfortunately I haven't found a way to change this within flash builder.