mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-12 13:36:26 +01:00
59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using System.Threading.Tasks;
|
|
|
|
|
|
namespace TINK.Services.Permissions.Plugin
|
|
{
|
|
using global::Plugin.Permissions;
|
|
|
|
public class Permissions : 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();
|
|
}
|
|
}
|