using System.Threading.Tasks;
namespace ShareeBike.Services.Permissions.Plugin
{
using global::Plugin.Permissions;
public class LocationPermissions : ILocationPermission
{
/// Checks the permission status.
public async Task CheckStatusAsync()
{
switch (await CrossPermissions.Current.CheckPermissionStatusAsync())
{
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;
}
}
/// Requests location permission.
/// Permission status after request.
public async Task RequestAsync()
{
switch (await CrossPermissions.Current.RequestPermissionAsync())
{
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;
}
}
/// Opens app settings dialog.
public bool OpenAppSettings()
=> CrossPermissions.Current.OpenAppSettings();
}
}