From a4ea737ae1773e7fd49969ae20b962bdd7481b37 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 11 Sep 2023 05:17:15 -0700 Subject: [PATCH] =?UTF-8?q?=E3=80=90iOS=E3=80=91Fix=20timer=20background?= =?UTF-8?q?=20state=20when=20App=20is=20launched=20from=20background=20(#3?= =?UTF-8?q?9347)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes https://github.com/facebook/react-native/issues/38711 ## Changelog: [IOS] [FIXED] - Fix timer background state when App is launched from background Pull Request resolved: https://github.com/facebook/react-native/pull/39347 Test Plan: Please see https://github.com/facebook/react-native/issues/38711 Reviewed By: cipolleschi Differential Revision: D49101979 Pulled By: dmytrorykun fbshipit-source-id: e25b182539f39e4465fa40e51288d88c68967b31 --- packages/react-native/React/CoreModules/RCTTiming.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-native/React/CoreModules/RCTTiming.mm b/packages/react-native/React/CoreModules/RCTTiming.mm index 6065006b8eb281..5158741724194b 100644 --- a/packages/react-native/React/CoreModules/RCTTiming.mm +++ b/packages/react-native/React/CoreModules/RCTTiming.mm @@ -128,6 +128,11 @@ - (void)setup _paused = YES; _timers = [NSMutableDictionary new]; _inBackground = NO; + RCTExecuteOnMainQueue(^{ + if (!self->_inBackground && [RCTSharedApplication() applicationState] == UIApplicationStateBackground) { + [self appDidMoveToBackground]; + } + }); for (NSString *name in @[ UIApplicationWillResignActiveNotification,