iOS, Swift/Tip, Bug, Swift Error
Swift ) com.apple.CoreHaptics Code=-4805 - EEYatHo iOS
EEYatHo
2022. 10. 28. 16:11
반응형
HapticEngine 으로 진동을 구현했었다. 구현 포스팅
그런데 백그라운드로 갔다가 포그라운드로 돌아온 후, 진동을 켜면
com.apple.CoreHaptics Code=-4805 에러가 발생했다.
CHHapticError 정의 를 보니, 엔진이 켜져있지 않다고 한다.
Solution
HapticEngine 은 앱이 백그라운드 상태로 가면 꺼진다.
따라서 포그라운드 진입시, HapticEngine 을 다시 start 시켜 해결했다.
/// in AppDelegate
override func applicationWillEnterForeground(_ application: UIApplication) {
do {
try VibrationManager.shared?.hapticEngine.start()
} catch {
print("Fail to hapticEngine Start: \(error)")
}
}