GPS background service settings to last more than 600 seconds

You must Login before you can answer or comment on any questions.

Hey guys,

So I have tried every way possible to get my iphone gps tracker to run in the background for more than 600 seconds.

The reason it does this is that apple designed it to do this unless you set up your application to be either VOIP, audio or a location service. I added the following to the info.plist:

<key>UIBackgroundModes</key>
    <array>
            <string>location</string>
    </array>
But I still cant get the background service to not timeout.

Has any one worked out how to track a users location for more than 10 minutes in the background yet?

Any help would be amazing,

Thanks,

Alex

2 Answers

Hi Alex, you need to use the iOS Background Service to keep the app alive. If you just create an interval timer in the backgroundservice .js file it should keep your app alive past the 10 minute mark.

I'm working on a sample on how to do this, just isn't ready to share yet. But, all it really will do is show an example of the above.

— answered 2 years ago by Ben Bahrenburg
answer permalink
1 Comment
  • Hi Ben,

    Thanks for your quick answer, I was doing what you mentioned already but did not have the xml nodes in my tiapp.xml as commented below ;(

    So got there in the end! I think adding the below comment to your example will really help others as you need both to get it working!

    — commented 2 years ago by Alex Akass

I figured this out about 10 minutes after posting! Sods law

I originally tried putting the code in the info.plist at the root of my project! Actually to get this working you must have a code block in your tiapp.xml file under the iphone node!

Like so:

<backgroundModes>
          <mode>location</mode>
        </backgroundModes>
Hope that helps some one else out ;)

— answered 2 years ago by Alex Akass
answer permalink
3 Comments
  • Hi Alex, apple might still kill off your app if an event doesn't fire within the 10 minute period. To stop that I've found it best to put in that background interval timer. All it does is keep your app "alive" in the background with hopes Apple will not try to kill it.

    — commented 2 years ago by Ben Bahrenburg

  • Yep dont worry got the following in place in my background service js file ;)

    trackTimerBG = setInterval(locateIt, Titanium.App.Properties.getString("frequency")*1000);
    Thanks for your help Ben!

    — commented 2 years ago by Alex Akass

  • Awesome, glad it is working.

    — commented 2 years ago by Ben Bahrenburg

Your Answer

This question has been locked and cannot accept new answers.