Hello! When I start the application, I immediately get permission to use geolocation, how can I turn it off and trigger this alert in front of the place where I’m really going to use geo?
1 answer
Add the following NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to the * .plist file, depending on how the application works with geolocation (only when the application is used or always).
We import CoreLocation to work with CLLocationManager :
#import <CoreLocation/CoreLocation.h> Add a property to our controller:
@property (strong, nonatomic) CLLocationManager *locationManager; And where necessary, for example, in the viewDidLoad method, viewDidLoad initialize and request one of the permissions to use geolocation:
self.locationManager = [CLLocationManager new]; [self.locationManager requestWhenInUseAuthorization]; //[self.locationManager requestAlwaysAuthorization]; More information:
http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/ https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/
|