0

I am developing an app which uses CLLocationManager to track user's current location.

As soon as I launch app, it works well till the end of the day, I used to get the user's location till evening 5'o clock.

I want my app to start automatically on the next day morning, without launching the app but my app is running in the background. I just want to work like alarm manager in android. Any suggestions?

I want CLLocationManager to startUpdatingLocation even when the device is rebooted without launching the app [while switching off the device, the app is running in background]

How to implement this?

Sharme
  • 625
  • 4
  • 10
  • 28
  • "startUpdateLocation" method call only if you are between time. – Mike Jun 28 '13 at 09:35
  • @mindfreak Yes, we need to call startUpdatingLocation, but even I reboot the iphone, it should start automatically without launching. Where I should call the method even the app is running in background. – Sharme Jun 28 '13 at 11:37
  • @Daij-Djan yeah sure. I am checking. Thanks – Sharme Jul 02 '13 at 05:28

3 Answers3

2

iOS will relaunch apps that sign up for location changes! This works under ios6 already! BUT to the background only. So that the location can be tracked

see e.g. the 'Moves' app that will track your location

the idea is that you're app wakes to the background mode.

see:

pay attention to:

compare with:

Community
  • 1
  • 1
Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
1

You simply can't do what you want with iOS 6 or lower (app can't launch itself on those iOS versions), workaround would be to alarm user to launch your app with local notifications. But iOS 7 comes with some new features, and allows certain apps to wake at the background to complete tasks.

Fahri Azimov
  • 11,470
  • 2
  • 21
  • 29
  • My question is not about the launching of the app by itself. I want to start tracking location automatically even when the app is in background on next day , or even the device is rebooted without launching the app. – Sharme Jun 29 '13 at 07:19
  • I don't think that without user interaction you can do that. And, I well understood your question. – Fahri Azimov Jun 29 '13 at 07:23
  • Yeah OK Understand. Thank you . – Sharme Jun 29 '13 at 07:32
1

You can not make startUpdatingLocation(didUpdateLocations) automatically run after reboot. You have to 1. use startMonitoringForRegion ; 2. or use a remote notification to invoke startUpdatingLocation.

LiangWang
  • 8,038
  • 8
  • 41
  • 54