Send AppLifecycleState notifications on FlutterViewController lifecycle events. (flutter/engine#3801)

This commit is contained in:
Sarah Zakarias
2017-06-21 14:39:05 +02:00
committed by GitHub
parent d981e6764e
commit e0d7204728
2 changed files with 10 additions and 1 deletions

View File

@@ -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();
}

View File

@@ -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];
}