From cdb491ed12eeaf5377c7aeeaf31163455fa39941 Mon Sep 17 00:00:00 2001 From: Christian Baroni <7061887+christianbaroni@users.noreply.github.com> Date: Thu, 14 Nov 2024 01:08:53 -0500 Subject: [PATCH] [iOS] Improve haptic engine cleanup --- package/ios/TurboHapticsModule.mm | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/package/ios/TurboHapticsModule.mm b/package/ios/TurboHapticsModule.mm index ab45a88..4c72989 100644 --- a/package/ios/TurboHapticsModule.mm +++ b/package/ios/TurboHapticsModule.mm @@ -25,17 +25,13 @@ - (instancetype)init { if (self = [super init]) { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; [center addObserver:self - selector:@selector(handleAppWillResignActive:) + selector:@selector(handleAppStateChange:) name:UIApplicationWillResignActiveNotification object:nil]; [center addObserver:self - selector:@selector(handleAppDidEnterBackground:) + selector:@selector(handleAppStateChange:) name:UIApplicationDidEnterBackgroundNotification object:nil]; - [center addObserver:self - selector:@selector(handleAppWillEnterForeground:) - name:UIApplicationWillEnterForegroundNotification - object:nil]; } return self; } @@ -44,15 +40,7 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (void)handleAppWillResignActive:(NSNotification *)notification { - TurboHapticsHostObject::cleanup(); -} - -- (void)handleAppDidEnterBackground:(NSNotification *)notification { - TurboHapticsHostObject::cleanup(); -} - -- (void)handleAppWillEnterForeground:(NSNotification *)notification { +- (void)handleAppStateChange:(NSNotification *)notification { TurboHapticsHostObject::cleanup(); }