mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-16 15:16:34 +01:00
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
|
|||
|
namespace TINK.Services.Permissions.Plugin
|
|||
|
{
|
|||
|
using global::Plugin.Permissions;
|
|||
|
|
|||
|
public class LocationPermissions : ILocationPermission
|
|||
|
{
|
|||
|
/// <summary> Checks the permission status.</summary>
|
|||
|
public async Task<Status> CheckStatusAsync()
|
|||
|
{
|
|||
|
switch (await CrossPermissions.Current.CheckPermissionStatusAsync<LocationPermission>())
|
|||
|
{
|
|||
|
case global::Plugin.Permissions.Abstractions.PermissionStatus.Denied:
|
|||
|
return Status.Denied;
|
|||
|
|
|||
|
case global::Plugin.Permissions.Abstractions.PermissionStatus.Granted:
|
|||
|
return Status.Granted;
|
|||
|
|
|||
|
case global::Plugin.Permissions.Abstractions.PermissionStatus.Unknown:
|
|||
|
return Status.Unknown;
|
|||
|
|
|||
|
default:
|
|||
|
// Comprises
|
|||
|
// - PermissionStatus.Disabled and
|
|||
|
// - PermissionStatus.Restricted.
|
|||
|
return Status.DeniedRequiresSettingsUI;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Requests location permission.</summary>
|
|||
|
/// <returns>Permission status after request.</returns>
|
|||
|
public async Task<Status> RequestAsync()
|
|||
|
{
|
|||
|
switch (await CrossPermissions.Current.RequestPermissionAsync<LocationPermission>())
|
|||
|
{
|
|||
|
case global::Plugin.Permissions.Abstractions.PermissionStatus.Denied:
|
|||
|
return Status.Denied;
|
|||
|
|
|||
|
case global::Plugin.Permissions.Abstractions.PermissionStatus.Granted:
|
|||
|
return Status.Granted;
|
|||
|
|
|||
|
case global::Plugin.Permissions.Abstractions.PermissionStatus.Unknown:
|
|||
|
return Status.Unknown;
|
|||
|
|
|||
|
default:
|
|||
|
// Comprises
|
|||
|
// - PermissionStatus.Disabled and
|
|||
|
// - PermissionStatus.Restricted.
|
|||
|
return Status.DeniedRequiresSettingsUI;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary> Opens app settings dialog.</summary>
|
|||
|
public bool OpenAppSettings()
|
|||
|
=> CrossPermissions.Current.OpenAppSettings();
|
|||
|
}
|
|||
|
}
|