When thought to write a location manager test app, as usual, wrote the following few lines and tried to test
if(m_foregroundLocationManager == nil)
{
self.m_foregroundLocationManager = [[CLLocationManager alloc]init];
}
self.m_foregroundLocationManager.delegate = self;
[self.m_foregroundLocationManager startUpdatingLocation];
But this resulted in giving the below errors
Googling this around, lead to few interesting facts
Application need to have either of the below two keys in the plist. IF not, the location manager won’t start.
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
This property accepts String value which will be used by the iOS framework when any of the below APIs are called with the intent of
requesting user to grant permission on behalf of user
self.locationManager requestWhenInUseUsageAuthorization
self.locationManager requestWhenAlwaysUsageAuthorization
If the app has the main functionality to do something in the foreground and only some of the secondary functionality in background, then can add both the keys into the plist
Buf if in background location is part of the main functionality, then add request always authorisation.
Below are the location types that needs always allow authorisation permission
- Significant location change
- Boundary crossing
- Background location updates (e.g. Fitness, Navigation apps)
- iBeacons
- Visited Locations (iOS 8.0+)
- Deferred location updates
All these location types have the power to wake up the app from suspended or terminated when a location event occurs. If the application is given only
when in use authorisation, these services will work only when the app is in the background.
However, in iOS 8.0, application can request system to present a local notification to the user when user crosses a set location boundary (geofence). When the user
crosses the boundary, system sends a local notification from the app but without waking up the app. If the user chooses to open the notification, the app will wake up
and can receive the boundary information.
These are the basics of Location changes in the iOS 8.0 version.
References:
No comments:
Post a Comment