Commit 138e79f2 authored by 余玠's avatar 余玠

merge hotfix to add new api to allow client control whether flutter boost...

merge hotfix to add new api to allow client control whether flutter boost handle the registration of all plugins
parent 605882d7
...@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
withEngine:(FlutterEngine* _Nullable)engine withEngine:(FlutterEngine* _Nullable)engine
withPluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
- (FlutterViewController *)flutterViewController; - (FlutterViewController *)flutterViewController;
......
...@@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSInteger)pageCount; + (NSInteger)pageCount;
/** /**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中 * 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中。本函数默认需要flutter boost来注册所有插件。
* *
* @param platform 平台层实现FLBPlatform的对象 * @param platform 平台层实现FLBPlatform的对象
* @param callback 启动之后回调 * @param callback 启动之后回调
...@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
/** /**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中 * 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中。本函数默认需要flutter boost来注册所有插件。
* *
* @param platform 平台层实现FLBPlatform的对象 * @param platform 平台层实现FLBPlatform的对象
* @param engine 外部实例化engine后传入 * @param engine 外部实例化engine后传入
...@@ -56,6 +56,17 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -56,6 +56,17 @@ NS_ASSUME_NONNULL_BEGIN
engine:(FlutterEngine* _Nullable)engine engine:(FlutterEngine* _Nullable)engine
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
/**
* 初始化FlutterBoost混合栈环境。应在程序使用混合栈之前调用。如在AppDelegate中。本函数可以控制是否需要flutter boost来注册所有插件
*
* @param platform 平台层实现FLBPlatform的对象
* @param engine 外部实例化engine后传入
* @param callback 启动之后回调
*/
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
engine:(FlutterEngine* _Nullable)engine
pluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine *engine))callback;
#pragma mark - Some properties. #pragma mark - Some properties.
- (BOOL)isRunning; - (BOOL)isRunning;
......
...@@ -119,13 +119,26 @@ ...@@ -119,13 +119,26 @@
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
{ {
[self startFlutterWithPlatform:platform engine:nil onStart:callback]; [self startFlutterWithPlatform:platform
engine:nil
pluginRegisterred:YES
onStart:callback];
} }
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
engine:(FlutterEngine* _Nullable)engine engine:(FlutterEngine* _Nullable)engine
onStart:(void (^)(FlutterEngine *engine))callback; onStart:(void (^)(FlutterEngine *engine))callback;
{ {
[self startFlutterWithPlatform:platform
engine:engine
pluginRegisterred:YES
onStart:callback];
}
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
engine:(FlutterEngine *)engine
pluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine * _Nonnull))callback{
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
__weak __typeof__(self) weakSelf = self; __weak __typeof__(self) weakSelf = self;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
...@@ -134,6 +147,7 @@ ...@@ -134,6 +147,7 @@
self.application = [factory createApplication:platform]; self.application = [factory createApplication:platform];
[self.application startFlutterWithPlatform:platform [self.application startFlutterWithPlatform:platform
withEngine:engine withEngine:engine
withPluginRegisterred:registerPlugin
onStart:callback]; onStart:callback];
}); });
} }
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform - (void)startFlutterWithPlatform:(id<FLBPlatform>)platform
withEngine:(FlutterEngine* _Nullable)engine withEngine:(FlutterEngine* _Nullable)engine
withPluginRegisterred:(BOOL)registerPlugin
onStart:(void (^)(FlutterEngine *engine))callback onStart:(void (^)(FlutterEngine *engine))callback
{ {
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
...@@ -58,6 +59,16 @@ ...@@ -58,6 +59,16 @@
self.platform = platform; self.platform = platform;
self.viewProvider = [[FLBFlutterEngine alloc] initWithPlatform:platform engine:engine]; self.viewProvider = [[FLBFlutterEngine alloc] initWithPlatform:platform engine:engine];
self.isRunning = YES; self.isRunning = YES;
if(registerPlugin){
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
FlutterEngine *myengine = [self.viewProvider engine];
if (clazz && myengine) {
if ([clazz respondsToSelector:NSSelectorFromString(@"registerWithRegistry:")]) {
[clazz performSelector:NSSelectorFromString(@"registerWithRegistry:")
withObject:myengine];
}
}
}
if(callback) callback(self.viewProvider.engine); if(callback) callback(self.viewProvider.engine);
}); });
} }
......
...@@ -57,14 +57,6 @@ ...@@ -57,14 +57,6 @@
nibName:nil nibName:nil
bundle:nil]; bundle:nil];
_dummy.name = kIgnoreMessageWithName; _dummy.name = kIgnoreMessageWithName;
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
if (clazz) {
if ([clazz respondsToSelector:NSSelectorFromString(@"registerWithRegistry:")]) {
[clazz performSelector:NSSelectorFromString(@"registerWithRegistry:")
withObject:_engine];
}
}
} }
return self; return self;
......
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