---
title: CHHapticEngine
framework: corehaptics
role: symbol
role_heading: Class
path: corehaptics/chhapticengine
---

# CHHapticEngine

An object that represents the connection to the haptic server.

## Declaration

```swift
class CHHapticEngine
```

## Mentioned in

Playing a single-tap haptic pattern Preparing your app to play haptics

## Overview

Overview 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 a haptic engine instance. Maintain a strong reference to it so it doesn’t go out of scope while the haptic is playing. Call the haptic engine’s start(completionHandler:) for an asynchronous start, or start() to start the engine synchronously (immediately). Stop the engine by calling stop(completionHandler:) when your app finishes haptic playback. Although it’s possible to create content—CHHapticPattern instances—independent of a CHHapticEngine, your app must use an engine to play that content.

## Topics

### Initializing a Haptic Engine

- [init()](corehaptics/chhapticengine/init().md)
- [init(audioSession:)](corehaptics/chhapticengine/init(audiosession:).md)

### Starting and Stopping the Haptic Engine

- [start()](corehaptics/chhapticengine/start().md)
- [start(completionHandler:)](corehaptics/chhapticengine/start(completionhandler:).md)
- [stop(completionHandler:)](corehaptics/chhapticengine/stop(completionhandler:).md)
- [CHHapticEngine.CompletionHandler](corehaptics/chhapticengine/completionhandler.md)

### Creating Haptic Pattern Players

- [makePlayer(with:)](corehaptics/chhapticengine/makeplayer(with:).md)
- [makeAdvancedPlayer(with:)](corehaptics/chhapticengine/makeadvancedplayer(with:).md)

### Modifying Playback Properties

- [playsAudioOnly](corehaptics/chhapticengine/playsaudioonly.md)
- [playsHapticsOnly](corehaptics/chhapticengine/playshapticsonly.md)
- [isMutedForAudio](corehaptics/chhapticengine/ismutedforaudio.md)
- [isMutedForHaptics](corehaptics/chhapticengine/ismutedforhaptics.md)

### Playing a Pattern

- [playPattern(from:)](corehaptics/chhapticengine/playpattern(from:)-6m9m5.md)
- [playPattern(from:)](corehaptics/chhapticengine/playpattern(from:)-7u8se.md)

### Registering Audio Resources

- [registerAudioResource(_:options:)](corehaptics/chhapticengine/registeraudioresource(_:options:).md)
- [unregisterAudioResource(_:)](corehaptics/chhapticengine/unregisteraudioresource(_:).md)
- [CHHapticAudioResourceID](corehaptics/chhapticaudioresourceid.md)

### Monitoring Finished Playback

- [notifyWhenPlayersFinished(finishedHandler:)](corehaptics/chhapticengine/notifywhenplayersfinished(finishedhandler:).md)
- [CHHapticEngine.FinishedHandler](corehaptics/chhapticengine/finishedhandler.md)
- [CHHapticEngine.FinishedAction](corehaptics/chhapticengine/finishedaction.md)

### Handling Haptic Engine Resets

- [resetHandler](corehaptics/chhapticengine/resethandler-swift.property.md)
- [CHHapticEngine.ResetHandler](corehaptics/chhapticengine/resethandler-swift.typealias.md)

### Handling Haptic Engine Stoppages

- [stoppedHandler](corehaptics/chhapticengine/stoppedhandler-swift.property.md)
- [CHHapticEngine.StoppedHandler](corehaptics/chhapticengine/stoppedhandler-swift.typealias.md)
- [CHHapticEngine.StoppedReason](corehaptics/chhapticengine/stoppedreason.md)

### Getting the Current Media Time

- [currentTime](corehaptics/chhapticengine/currenttime.md)
- [CHHapticTimeImmediate](corehaptics/chhaptictimeimmediate.md)

### Querying System Capabilities

- [capabilitiesForHardware()](corehaptics/chhapticengine/capabilitiesforhardware().md)
- [CHHapticDeviceCapability](corehaptics/chhapticdevicecapability.md)
- [CHHapticParameterAttributes](corehaptics/chhapticparameterattributes.md)
- [attributes(forDynamicParameter:)](corehaptics/chhapticdevicecapability/attributes(fordynamicparameter:).md)

### Managing Power

- [isAutoShutdownEnabled](corehaptics/chhapticengine/isautoshutdownenabled.md)

### Initializers

- [init(andReturnError:)](corehaptics/chhapticengine/init(andreturnerror:).md)

### Instance Properties

- [intendedSpatialExperience](corehaptics/chhapticengine/intendedspatialexperience-55ca0.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Essentials

- [Preparing your app to play haptics](corehaptics/preparing-your-app-to-play-haptics.md)
- [Playing a single-tap haptic pattern](corehaptics/playing-a-single-tap-haptic-pattern.md)
- [CHHapticPattern](corehaptics/chhapticpattern.md)
- [CHHapticPatternPlayer](corehaptics/chhapticpatternplayer.md)
- [CHHapticAdvancedPatternPlayer](corehaptics/chhapticadvancedpatternplayer.md)
