Jessica
Jessica

Reputation: 2067

Geolocator.RequestAccessAsync always returns Denied status

I am following this post to get user location in my UWP app but the following code always returns a Denied status.

var accessStatus = await Geolocator.RequestAccessAsync();

I have already enabled "Location" capability in the app manifest, but still no permission dialog is showing up whatsoever.

What else have I missed?

Upvotes: 2

Views: 747

Answers (1)

Justin XL
Justin XL

Reputation: 39006

You need to not only enable Location capability but also Location service in your Windows 10 settings.

To turn it on, go to Settings > Location Privacy Settings and then turn on the Location service toggle as shown in the picture below.

enter image description here

Note that when this system-wide Location service is on, even if the user denies your app from using his/her location, you can still get an imprecise location by enabling AllowFallbackToConsentlessPositions from Geolocator.

Upvotes: 5

Related Questions