diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 17ca2900ad392a..bab5da758a037d 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -99,6 +99,14 @@ - (instancetype)initWithContextContainer:(ContextContainer::Shared)contextContai _observers = [NSMutableArray array]; _scheduler = [self _createScheduler]; + + auto reactNativeConfig = _contextContainer->at>("ReactNativeConfig"); + if (reactNativeConfig->getBool("react_native_new_architecture:suspend_before_app_termination")) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(_applicationWillTerminate) + name:UIApplicationWillTerminateNotification + object:nil]; + } } return self; @@ -327,6 +335,11 @@ - (void)_stopAllSurfacesWithScheduler:(RCTScheduler *)scheduler }]; } +- (void)_applicationWillTerminate +{ + [self suspend]; +} + #pragma mark - RCTSchedulerDelegate - (void)schedulerDidFinishTransaction:(MountingCoordinator::Shared const &)mountingCoordinator