-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add haptic notifications support. #177721
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
Add haptic notifications support. #177721
Conversation
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.
Code Review
This pull request adds support for success, warning, and error haptic notifications on Android, iOS, and web platforms. The changes are well-implemented on the Dart, Android, and web sides, including appropriate tests. However, the iOS implementation is missing tests for the new notification haptics, which I've highlighted as a medium-severity issue to ensure full test coverage and maintainability.
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm
Show resolved
Hide resolved
reidbaker
left a comment
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.
Android code looks good! Thank you for this contribution. I am going to do some work on our side to see of flutter team members have opinions on the default android behavior.
...e/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java
Outdated
Show resolved
Hide resolved
...e/src/flutter/shell/platform/android/test/io/flutter/plugin/platform/PlatformPluginTest.java
Outdated
Show resolved
Hide resolved
| /// On iOS, this uses a `UINotificationFeedbackGenerator` with | ||
| /// `UINotificationFeedbackTypeWarning`. | ||
| /// | ||
| /// On Android, this uses `HapticFeedbackConstants.KEYBOARD_TAP`. |
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.
@mboetger looking for your thoughts here. Android does not have the concept of warning haptic. This addition is a new api so it will be up to callers to decide if they want warning behaviors but flutter is now making a design statement about warnings and on api 30 and below warnings would have haptics and errors would not. On the other hand intentionally skewing androids behavior from iOS doesnt feel like the right call either.
Here is the best documentation I have found about haptics. https://developer.android.com/develop/ui/views/haptics/haptic-feedback
Do you think flutter should have haptics for warnings on android?
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.
I'm ok with parity between iOS and Android here - but I think I have a more difficult time with warnings having haptics when errors do not. Especially since the only reason warnings DO exist below API 30 is the arbitrary choice of the HapticFeedbackConstants.KEYBOARD_TAP to represent the warnings. If another constant was chosen, a different API condition would exist.
I would prefer only turning on warnings for API 30 and beyond. Otherwise, it's going to feel strange to the user when it happens in some cases and not others.
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.
@reidbaker @mboetger thanks a lot for your review!
I totally agree with your statements and applied the feedback in the latest commit. Could you please take a look again?
mboetger
left a comment
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.
Android looks good to me.
hellohuanlin
left a comment
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.
iOS looks good
|
@mboetger @hellohuanlin thanks a lot for your review! |
mdebbar
left a comment
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.
web changes look good!
|
@ksokolovskyi looks like you have approvals from all platforms, is this ready to land? |
dkwingsmt
left a comment
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.
LGTM
|
Thanks a lot everyone for the review! |
…10408) Manual roll requested by [email protected] flutter/flutter@31a8481...ee23168 2025-11-07 [email protected] Roll Packages from f13bad3 to 3caa48b (5 revisions) (flutter/flutter#178164) 2025-11-07 [email protected] Fix text input actions in DropdownMenu. (flutter/flutter#177313) 2025-11-07 [email protected] Roll Skia from f838c4b31edb to 581d1ecd5029 (1 revision) (flutter/flutter#178157) 2025-11-07 [email protected] Roll Skia from eb3c5b280ae6 to f838c4b31edb (3 revisions) (flutter/flutter#178149) 2025-11-07 [email protected] Roll Skia from 360fe72b5bf4 to eb3c5b280ae6 (1 revision) (flutter/flutter#178147) 2025-11-07 [email protected] Roll Skia from 116f237bb39d to 360fe72b5bf4 (4 revisions) (flutter/flutter#178146) 2025-11-07 [email protected] Roll Fuchsia Linux SDK from cm88aTLui5yorSGYQ... to qDVe2mrpSgQdxra7p... (flutter/flutter#178144) 2025-11-07 [email protected] fix: findChildIndexCallback to take seperators into account for seperated named constructor in ListView and SliverList (flutter/flutter#174491) 2025-11-06 [email protected] [web] Remove unnecessary android_sdk dep (flutter/flutter#178078) 2025-11-06 [email protected] Add haptic notifications support. (flutter/flutter#177721) 2025-11-06 [email protected] Allow label to be used to compute InputDecorator Intrinsic width (flutter/flutter#178101) 2025-11-06 [email protected] Respect product flavor abiFilters by adding a `disable-abi-filtering` Android project flag. (flutter/flutter#177753) 2025-11-06 [email protected] Use aria-hidden attribute for platform view accessibility on web (flutter/flutter#177969) 2025-11-06 [email protected] [tool] Fix IP parsing by using Uri constructor (flutter/flutter#178083) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Closes flutter#150029 ### Description - Adds `successNotification`, `warningNotification` and `errorNotification` haptics to the framework - Adds `UINotificationFeedbackTypeSuccess`, `UINotificationFeedbackTypeWarning` and `UINotificationFeedbackTypeError` haptics support on iOS - Adds `HapticFeedbackConstants.CONFIRM` and `HapticFeedbackConstants.REJECT` haptics support on Android - Adds tests | iOS | Android | Web | |:-:|:-:|:-:| | UINotificationFeedbackTypeSuccess | HapticFeedbackConstants.CONFIRM | 20ms vibration | | UINotificationFeedbackTypeWarning | HapticFeedbackConstants.KEYBOARD_TAP | 20ms vibration | | UINotificationFeedbackTypeError | HapticFeedbackConstants.REJECT | 30ms vibration | ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Closes flutter#150029 ### Description - Adds `successNotification`, `warningNotification` and `errorNotification` haptics to the framework - Adds `UINotificationFeedbackTypeSuccess`, `UINotificationFeedbackTypeWarning` and `UINotificationFeedbackTypeError` haptics support on iOS - Adds `HapticFeedbackConstants.CONFIRM` and `HapticFeedbackConstants.REJECT` haptics support on Android - Adds tests | iOS | Android | Web | |:-:|:-:|:-:| | UINotificationFeedbackTypeSuccess | HapticFeedbackConstants.CONFIRM | 20ms vibration | | UINotificationFeedbackTypeWarning | HapticFeedbackConstants.KEYBOARD_TAP | 20ms vibration | | UINotificationFeedbackTypeError | HapticFeedbackConstants.REJECT | 30ms vibration | ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [X] I listed at least one issue that this PR fixes in the description above. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Closes #150029
Description
successNotification,warningNotificationanderrorNotificationhaptics to the frameworkUINotificationFeedbackTypeSuccess,UINotificationFeedbackTypeWarningandUINotificationFeedbackTypeErrorhaptics support on iOSHapticFeedbackConstants.CONFIRMandHapticFeedbackConstants.REJECThaptics support on AndroidPre-launch Checklist
///).