Geolocator.RequestAccessAsync Method

Definition

Note

Some information relates to pre-released product, which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Important

This API will be affected by upcoming changes to operating system behavior, planned for fall 2024. For more info, see Changes to API behavior for Wi-Fi access and location.

Requests permission to access location data.

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

The RequestAccessAsync method prompts the user for permission to access their location. The user is only prompted once (per app). After the first time they grant or deny permission, this method no longer prompts for permission. To help the user change location permissions after they've been prompted, we recommend providing a link to the location settings on their device. When the user has given the app some kind of location permissions, your app can work as intended; to determine which type of location tracking is being used, query the PositionSource property of a retrieved Geocoordinate object.

Tip

To link to location settings from your app, call the LaunchUriAsync method with the URI ms-settings:privacy-location. For more info, see Launch the Windows Settings app.

Applies to

See also