WKWebView无法唤起第三方授权登录弹窗的问题处理

如题所述

第1个回答  2022-06-04
问题如题,做Macos的第三方授权登录时遇见第三方弹窗无法唤起。解决方案如下:

- (WKWebView*)webView:(WKWebView*)webView

createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration

   forNavigationAction:(WKNavigationAction*)navigationAction

        windowFeatures:(WKWindowFeatures*)windowFeatures

{

    if(navigationAction.targetFrame==nil) {

        // Let's create a new webview on the fly with the provided configuration,

        // set us as the UI delegate and return the handle to the parent webview

        WKWebView * popup =[[WKWebView alloc]initWithFrame:CGRectMake(0, 0, 440, 660) configuration:configuration];

        popup.UIDelegate=self;

        [self addSubview:popup];

        popup.center=self.center;

        return popup;

    }

    return nil;

}

-(void)webViewDidClose:(WKWebView*)webView {

    [webView removeFromSuperview];

}

参考链接:

https://www.coder.work/article/257843