Skip to content

Commit

Permalink
feat: Throw appropriate exception when obtaining location without per…
Browse files Browse the repository at this point in the history
…mission
  • Loading branch information
juliecantin committed Aug 26, 2020
1 parent 9cec3e1 commit 92af4f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SamplesApp/SamplesApp.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,9 @@
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>TODO NSLocationWhenInUseUsageDescription</string>
<key>NSLocationUsageDescription</key>
<string>TODO NSLocationUsageDescription</string>
</dict>
</plist>
5 changes: 5 additions & 0 deletions src/Uno.UWP/Devices/Geolocation/Geolocator.iOSmacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public IAsyncOperation<Geoposition> GetGeopositionAsync()
{
BroadcastStatus(PositionStatus.Initializing);
var location = _locationManager.Location;
if (location == null)
{
throw new InvalidOperationException("Could not obtain the location. Please make sure that NSLocationWhenInUseUsageDescription and NSLocationUsageDescription are set in info.plist.");
}

BroadcastStatus(PositionStatus.Ready);
#if __IOS__
return ToGeoposition(location);
Expand Down

0 comments on commit 92af4f2

Please sign in to comment.