Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
Flip order of NSLocation Usage Description checks
Browse files Browse the repository at this point in the history
Starting in iOS10, showing the user's location on a map requires the NSLocationWhenInUseDescription, even if NSLocationAlwaysInUseDescription is already present in info.plist. There are probably other location features with similar problems. 

It is better to check for the Always In Use description first, because that will enable all location features in an app that contains both descriptions, whereas requesting and enabling on When In Use will only provide a subset. This is especially important because iOS will only present the request dialog the first time an authorization request is made after the app is installed.
  • Loading branch information
jcmanke committed Dec 22, 2016
1 parent ee4d5eb commit f18dfde
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ Task<PermissionStatus> RequestLocationPermission()


var info = NSBundle.MainBundle.InfoDictionary;
if (info.ContainsKey(new NSString("NSLocationWhenInUseUsageDescription")))
locationManager.RequestWhenInUseAuthorization();
else if (info.ContainsKey(new NSString("NSLocationAlwaysUsageDescription")))
if (info.ContainsKey(new NSString("NSLocationAlwaysUsageDescription")))
locationManager.RequestAlwaysAuthorization();
else if (info.ContainsKey(new NSString("NSLocationWhenInUseUsageDescription")))
locationManager.RequestWhenInUseAuthorization();
else
throw new UnauthorizedAccessException("On iOS 8.0 and higher you must set either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your Info.plist file to enable Authorization Requests for Location updates!");

Expand Down Expand Up @@ -507,4 +507,4 @@ public bool OpenAppSettings()
}
}
}
}
}

0 comments on commit f18dfde

Please sign in to comment.