Commit e0e6620a authored by 余玠's avatar 余玠

let the boost container support the observer to app's enter background and...

let the boost container support the observer to app's enter background and will enter foreground notification.
parent 68c9957d
...@@ -76,13 +76,24 @@ ...@@ -76,13 +76,24 @@
_manager = [FLB2FlutterContainerManager new]; _manager = [FLB2FlutterContainerManager new];
_pageResultCallbacks = NSMutableDictionary.new; _pageResultCallbacks = NSMutableDictionary.new;
_callbackCache = NSMutableDictionary.new; _callbackCache = NSMutableDictionary.new;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
} }
return self; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
} }
- (UIView *)flutterView - (UIView *)flutterView
...@@ -90,6 +101,13 @@ ...@@ -90,6 +101,13 @@
return [self flutterViewController].view; return [self flutterViewController].view;
} }
- (void)applicationDidEnterBackground:(UIApplication *)application {
[self.viewProvider didEnterBackground];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[self.viewProvider willEnterForeground];
}
- (BOOL)contains:(id<FLBFlutterContainer>)vc - (BOOL)contains:(id<FLBFlutterContainer>)vc
{ {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#import "FLB2FlutterEngine.h" #import "FLB2FlutterEngine.h"
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
#import "FLB2FlutterViewContainer.h" #import "FLB2FlutterViewContainer.h"
#import "BoostMessageChannel.h"
@interface FLB2FlutterEngine() @interface FLB2FlutterEngine()
...@@ -87,6 +88,17 @@ ...@@ -87,6 +88,17 @@
} }
- (void)didEnterBackground
{
[BoostMessageChannel sendEvent:@"background"
arguments:nil];
}
- (void)willEnterForeground
{
[BoostMessageChannel sendEvent:@"foreground"
arguments:nil];
}
- (FlutterEngine *)engine - (FlutterEngine *)engine
{ {
......
...@@ -37,5 +37,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -37,5 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)pause; - (void)pause;
- (void)resume; - (void)resume;
- (void)inactive; - (void)inactive;
- (void)didEnterBackground;
- (void)willEnterForeground;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment