Skip to content

Instantly share code, notes, and snippets.

@nthState
Created February 15, 2021 09:43
Show Gist options
  • Save nthState/f022f6c73b6e06f40b99b6260d44db99 to your computer and use it in GitHub Desktop.
Save nthState/f022f6c73b6e06f40b99b6260d44db99 to your computer and use it in GitHub Desktop.
import CoreHaptics
func playHapticsFile() {
guard let url = Bundle.main.url(forResource: "myfile", withExtension: "ahap") else {
print("could not load file")
return
}
do {
let engine = try? CHHapticEngine()
try engine?.playPattern(from: url)
} catch {
print("play error: \(error)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment