Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 适配 flutter_webview_plugin 插件 #149

Closed
foxsofter opened this issue Jan 9, 2021 · 2 comments
Closed

[fix] 适配 flutter_webview_plugin 插件 #149

foxsofter opened this issue Jan 9, 2021 · 2 comments

Comments

@foxsofter
Copy link
Owner

foxsofter commented Jan 9, 2021

目前引入这个插件会出现两个FlutterEngine在跑,根本原因是 flutter_webview_plugin 中的下面这段代码

+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    channel = [FlutterMethodChannel
               methodChannelWithName:CHANNEL_NAME
               binaryMessenger:[registrar messenger]];

    UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController;
    FlutterWebviewPlugin* instance = [[FlutterWebviewPlugin alloc] initWithViewController:viewController];
    
    [registrar addMethodCallDelegate:instance channel:channel];
}

直接获取 rootViewController 作为默认的 FlutterViewController,太过于简单粗暴,正确的方式应该是从 FlutterEngine 获取

@foxsofter
Copy link
Owner Author

无法适配,需要 flutter_webview_plugin 本身作修改

@foxsofter
Copy link
Owner Author

这个插件看似已经没人维护了,不管了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant