sharee.bike-App/TINKLib/Services/Permissions/Plugin/Permissions.cs

60 lines
1.7 KiB
C#
Raw Normal View History

2021-12-08 17:57:30 +01:00
using System.Threading.Tasks;
namespace TINK.Services.Permissions.Plugin
{
2022-09-06 16:08:19 +02:00
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();
}
2021-12-08 17:57:30 +01:00
}