ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.96k stars 13.51k forks source link

Feature suggestion: auto-provide haptic feedback on iPhone 7 #8183

Closed EddyVerbruggen closed 8 years ago

EddyVerbruggen commented 8 years ago

Hi friends,

While I was playing with an iPhone 7 yesterday I noticed the very cool haptic feedback (various types of little vibrations) it provides through the 'Taptic Engine'. Browsing the iOS 10 SDK changelog I was glad to discover there's a programmatic (and official) way to tap into the engine to produce exactly the same feedback for your own app.

The phone gives you feedback when for instance scrolling a list (probably also works with HTML<select> since it's a native control), when changing a slider/range, when flipping a switch/toggle, etc.

Soon iPhone 7 users will expect all their apps to provide the same, consistent, feedback and luckily all native apps will out of the box. The same is true for "JavaScript Native" frameworks like React Native and NativeScript since they render a native UI as well.

So what about Ionic, I wondered this morning? There's for instance the ion-toggle control that won't be auto-enhanced since it's a (beautifully crafted) HTML/CSS widget.

I propose to tap into a plugin that's triggered whenever an HTML widget (that mimicks a native UI widget) is triggered and provide the same feedback. IMO that will greatly enhance the experience of Ionic based apps and make them blend in nicely.

So wherever the toggle changes state, we could do (pseudo code):

function onToggleStateChange () {
  if (window.TapticEngine) {
    TapticEngine.selection()
}

Note that you don't need to care about callbacks from the plugin as Apple advises developers to let the system bother about supported hardware instead of you - so users with an iPhone 5 simply don't feel any feedback like in all their other apps.

This way developers get to choose whether or not to add haptic feedback, or it could even be part of a template project so everyone's new app is auto-enhanced with this sweet little feature.

The biggest plus is of course that developers don't need to worry about it as their favorite framework will do the hard work for them!

Bouzmine commented 8 years ago

I just opened this issue on ionic-native for that plugin to be included (driftyco/ionic-native#571). I think this is a good idea.

dylanvdmerwe commented 8 years ago

Related https://github.com/driftyco/ionic/issues/8198

mlynch commented 8 years ago

Added in 713e2a1a33ded9dd238a3babe16db72c2f751741