User Location not working in iOS 8


Within a text editor: Open up your Info.plist and add the following:

<key>NSLocationWhenInUseUsageDescription</key>
<string>You are about to use location!</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>This will be called if location is used behind the scenes</string>

And within the MainViewController.cs you need to call the following:

iPhoneLocationManager.RequestWhenInUseAuthorization ();

EX:

if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
iPhoneLocationManager.RequestWhenInUseAuthorization ();
iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
UpdateLocation (mainScreen, e.Locations [e.Locations.Length - 1]);
};
} else {
// this won't be called on iOS 6 (deprecated)
iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
UpdateLocation (mainScreen, e.NewLocation);
};
}

Last Updated: Oct 21, 2016 06:14PM EDT