Skip to content
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

iOS UIImpactFeedbackGenerator should be used on iOS 17.5 and up #25561

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

jfversluis
Copy link
Member

Description of Change

In #24605 we used some newer iOS APIs, however the gate for the haptic feedback API was too low of a version. It should be iOS 17.5 and up as opposed to 17.4 and up as it was specified now. Causing this API to crash on 17.4.

See https://developer.apple.com/documentation/uikit/uiimpactfeedbackgenerator/4403142-feedbackgeneratorwithstyle

Issues Fixed

Fixes #25560

@jfversluis jfversluis requested a review from a team as a code owner October 28, 2024 19:28
Copy link

@alexanderdibenedetto alexanderdibenedetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please backport!

@jsuarezruiz jsuarezruiz added t/housekeeping ♻︎ area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info labels Oct 29, 2024
@jfversluis jfversluis merged commit 8f0e4d1 into main Oct 29, 2024
109 checks passed
@jfversluis jfversluis deleted the fix-25560 branch October 29, 2024 07:46
@jfversluis
Copy link
Member Author

@alexanderdibenedetto I can't make any promises, but if you need this right now you can basically mimic the same functionality here but in your own app. Something like:

#if IOS
UIImpactFeedbackGenerator impact;

if (OperatingSystem.IsIOSVersionAtLeast(17, 5) || OperatingSystem.IsMacCatalystVersionAtLeast(17, 5))
{
    impact = UIImpactFeedbackGenerator.GetFeedbackGenerator(UIImpactFeedbackStyle.Light, new UIView());
}
else
{
    impact = new UIImpactFeedbackGenerator(UIImpactFeedbackStyle.Light);
}

impact.Prepare();
impact.ImpactOccurred();
impact.Dispose();
#endif

Not ideal, but at least should get you unblocked for the time being. Or of course revert to a previous version of .NET MAUI that does not have this change.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2024
@samhouts samhouts added fixed-in-9.0.10 fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info fixed-in-9.0.10 fixed-in-net8.0-nightly This may be available in a nightly release! t/housekeeping ♻︎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HapticFeedback for iOS crashes on iOS 17.4 since SR2
4 participants