Repository navigation
[iOS] Permissions.RequestAsync<Permissions.Sensors> does not return a value on iOS16+ - fix #30733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -199,19 +199,7 @@ internal static PermissionStatus GetSensorPermissionStatus() | |||||||||||
|
|
||||||||||||
| if (OperatingSystem.IsIOSVersionAtLeast(11, 0) || OperatingSystem.IsWatchOSVersionAtLeast(4, 0)) | ||||||||||||
| { | ||||||||||||
| #pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619 | ||||||||||||
| switch (CMMotionActivityManager.AuthorizationStatus) | ||||||||||||
| { | ||||||||||||
| case CMAuthorizationStatus.Authorized: | ||||||||||||
| return PermissionStatus.Granted; | ||||||||||||
| case CMAuthorizationStatus.Denied: | ||||||||||||
| return PermissionStatus.Denied; | ||||||||||||
| case CMAuthorizationStatus.NotDetermined: | ||||||||||||
| return PermissionStatus.Unknown; | ||||||||||||
| case CMAuthorizationStatus.Restricted: | ||||||||||||
| return PermissionStatus.Restricted; | ||||||||||||
| } | ||||||||||||
| #pragma warning restore CA1416 | ||||||||||||
| return ConvertAuthorizationStatus(CMMotionActivityManager.AuthorizationStatus); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return PermissionStatus.Unknown; | ||||||||||||
|
|
@@ -230,11 +218,24 @@ internal static async Task<PermissionStatus> RequestSensorPermission() | |||||||||||
| catch (Exception ex) | ||||||||||||
| { | ||||||||||||
| Debug.WriteLine("Unable to query activity manager: " + ex.Message); | ||||||||||||
| return PermissionStatus.Denied; | ||||||||||||
| // Fall back to checking the authorization status directly | ||||||||||||
|
||||||||||||
| // Fall back to checking the authorization status directly | |
| // Fall back to checking the authorization status directly because querying the activity manager | |
| // may fail due to platform-specific limitations or exceptions. For example, on iOS 16+, | |
| // certain permissions or system behaviors might prevent successful queries. This fallback | |
| // ensures that we can still determine the permission status reliably. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you expand the comment adding more details?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we catch a specific exception to Han die the fall back ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure and done