Share via


Geolocator.RequestAccessAsync Method

Definition

Requests permission to access location data.

Important

Location consent is now required for Wi-Fi BSSID access. For details on how this affects apps using Wi-Fi or location APIs, see Changes to API behavior for Wi-Fi access and location.

public:
 static IAsyncOperation<GeolocationAccessStatus> ^ RequestAccessAsync();
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<GeolocationAccessStatus> RequestAccessAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<GeolocationAccessStatus> RequestAccessAsync();
function requestAccessAsync()
Public Shared Function RequestAccessAsync () As IAsyncOperation(Of GeolocationAccessStatus)

Returns

A GeolocationAccessStatus that indicates if permission to location data has been granted.

Attributes

Windows requirements

App capabilities
location

Remarks

Call RequestAccessAsync before accessing the user's location. At that time, your app must be in the foreground and RequestAccessAsync must be called from the UI thread. Until the user grants your app permission to their location, your app can't access location data.

You must call this method on the UI thread, otherwise an exception will occur.

When you first call this method, it prompts the user to give permission. The prompt is displayed for each app (per app). After the first time they grant or deny permission, this method no longer prompts for permission. Provide an in-app link to the device's location privacy settings so users can revisit their choice later. When the user has given the app any level of location permission, your app can work as intended.

Applies to

See also

  • <xref:Windows.Devices.Geolocation.GeolocationAccessStatus%0a%0a%23%23%23+Version+history%0a%0a%7c+Windows+version+%7c+SDK+version+%7c+Value+added+%7c%0a%7c+--+%7c+--+%7c+--+%7c%0a%7c+1507+%7c+10240+%7c+RequestAccessAsync+%7c%0a%7c+24H2+%7c+26100+%7c+Location+consent+required+for+Wi-Fi+BSSIDs+%7c>