From a87d15d62ebef22f3fe6fa529a3dc1a0e6497d05 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Wed, 21 Jun 2017 14:39:05 +0200 Subject: [PATCH] Send AppLifecycleState notifications on FlutterViewController lifecycle events. (#3801) --- shell/common/engine.cc | 2 +- .../darwin/ios/framework/Source/FlutterViewController.mm | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/common/engine.cc b/shell/common/engine.cc index a85b1c651d..d12de04517 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -323,7 +323,7 @@ bool Engine::HandleLifecyclePlatformMessage(blink::PlatformMessage* message) { activity_running_ = false; StopAnimator(); } else if (state == "AppLifecycleState.resumed" || - state == "AppLifecycle.inactive") { + state == "AppLifecycleState.inactive") { activity_running_ = true; StartAnimatorIfPossible(); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 1007f0b56a..5838df5edb 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -273,11 +273,19 @@ class PlatformMessageResponseDarwin : public blink::PlatformMessageResponse { [view release]; } +#pragma mark - UIViewController lifecycle notifications + - (void)viewWillAppear:(BOOL)animated { [self connectToEngineAndLoad]; [super viewWillAppear:animated]; } +- (void)viewDidDisappear:(BOOL)animated { + [_lifecycleChannel.get() sendMessage:@"AppLifecycleState.paused"]; + + [super viewDidDisappear]; +} + #pragma mark - Application lifecycle notifications - (void)applicationBecameActive:(NSNotification*)notification { @@ -533,6 +541,7 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(UITouc [self surfaceUpdated:YES]; [self onLocaleUpdated:nil]; [self onVoiceOverChanged:nil]; + [_lifecycleChannel.get() sendMessage:@"AppLifecycleState.resumed"]; [super viewDidAppear:animated]; } -- GitLab