Compose and play haptic patterns to customize your app’s feedback.
Use haptics to engage users physically, with tactile feedback that gets attention and reinforces actions.
Your app can play custom haptic patterns crafted from basic building blocks called haptic events (
HapticEvent). Events can be transient, like the feedback you get from toggling a switch, or continuous, like the vibration or sound from a ringtone. You can use transient and continuous patterns independently, or build your pattern from precise combinations of the two.
You should check whether the current device supports the haptic engine by checking the
isSupported property on the
If it is not supported you should fall back to other feedback methods, such as simple vibrations.
Haptic Engine is only supported on iOS currently
Create a player
To create a player call the
createAdvancedPlayer() method passing in your pattern and initial params.
Currently the parameters to this method including the pattern are ignored. A haptic player with a single continuous pattern containing intensity and sharpness parameters will be created.
To start the haptic call the
start() method on the
To stop the player, call the
To update a continuous haptic pattern with new dynamic parameters, call the
sendParameters() method passing in the new dynamic paramaters.
The haptic engine may be stopped at any time due to external factors such as an incoming phone call or the application being minimised.
When this occurs any of your players will become invalid and you should dispose them and recreate them before responding to user feedback again.
Additionally each individual player will complete it's pattern playback after an amount of time. When this occurs the complete event will be dispatched allowing you to start the player again if you wish to continue haptic feedback.
Constructing a Pattern
Not available yet