I am writing a switch case that will return a user friendly message to the user informing them what location permissions have been given to my IOS application (which completely relies on the location). So far I have created the following switch case. It does not quite work properly as I would like it to identify which setting the user has selected and respond with the correct message. Currently it will only detect whether the user has selected 'Always' or 'Never' and not be able to identify the other 2 options. The options that I ould like it to identify are - Allow Location Access - 'Never', 'Ask Next Time', 'Whilst Using the App' and 'Always'.
private void CheckPermissions(bool enabled)
{
MainThread.BeginInvokeOnMainThread(() =>
{
PermissionStatus alwaysAllowLocationPermission = default;
if (alwaysAllowLocationPermission)
switch (enabled)
case alwaysAllowLocationPermission = PermissionStatus.Granted:
{
var okAlertController = UIAlertController.Create("Permissions good", $"You have not given permission to 'always' use location.", UIAlertControllerStyle.Alert);
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(okAlertController, true, null);
}
break;
case alwaysAllowLocationPermission = PermissionStatus.Denied:
{
var okAlertController = UIAlertController.Create("Permission denied", $"You have not given permission to 'always' use location.", UIAlertControllerStyle.Alert);
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(okAlertController, true, null);
}
break;
case alwaysAllowLocationPermission = PermissionStatus.Restricted:
{
var okAlertController = UIAlertController.Create("Permission restricted", $"You have not given permission to 'always' use location.", UIAlertControllerStyle.Alert);
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(okAlertController, true, null);
}
break;
default:
break;
}
}
} else
{
var okAlertController = UIAlertController.Create("Missing Permissions”, $"You have not given permission to 'always' use location.", UIAlertControllerStyle.Alert);
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
PresentViewController(okAlertController, true, null);
}
};
};