An object that manages your app's requests to play haptic patterns.
- iOS 13.0+
- Mac Catalyst 13.0+
- Core Haptics
If you want your app to play custom haptics, you need to create a haptic engine. The haptic engine establishes the connection between your app and the underlying device hardware. Even though you can define a haptic pattern without an engine, you need the engine to play that pattern.
Even though your app makes a request through the haptic engine, the operating system could still override the request with system services, like haptics from system notifications.
Prepare Your App To Play Haptics
To prepare your app to play haptics, follow these steps, as demonstrated in the code below:
Create an instance of a haptic engine and maintain ownership through an instance variable or strong property, so it doesn't go out of scope while the haptic is playing.
Stop the engine by calling
stop(completionwhen your app finishes haptic playback.
Although it's possible to create content—
CHHaptic instances—independent of a
CHHaptic, your app must use an engine to play that content.