Sharme
Sharme

Reputation: 637

CLLocation Manager should start updating location automatically

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?

Upvotes: 0

Views: 871

Answers (3)

LiangWang
LiangWang

Reputation: 8846

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.

Upvotes: 1

Daij-Djan
Daij-Djan

Reputation: 50129

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:

Upvotes: 2

Fahri Azimov
Fahri Azimov

Reputation: 11770

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.

Upvotes: 1

Related Questions