简体   繁体   English

WKWebView iOS 中的 Google 登录按钮没有响应

[英]Google Sign-In button in WKWebView iOS not responding

In my app the login page is in a WKWebView with an option to login using Google Auth:https://developers.google.com/identity/sign-in/web/build-button but the button doesn't respond.在我的应用程序中,登录页面位于 WKWebView 中,可以选择使用 Google Auth 登录:https://developers.google.com/identity/sign-in/web/build-button但按钮没有响应。

Moreover, I've tried to switch the login URL with the URL above (google docs) because it containts an example for a Google login button and the button doesn't respond as well.此外,我尝试将登录 URL 与上面的 URL (谷歌文档)切换,因为它包含谷歌登录按钮的示例,并且该按钮也没有响应。

This is my WKWebView configuration with the google's doc link:这是我的 WKWebView 配置,带有 google 的文档链接:

- (void)initWebView {
    WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero];
    [self.contentView addSubview:webView];
    [webView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [[webView.topAnchor constraintEqualToAnchor:self.contentView.topAnchor constant:0] setActive:YES];
    [[webView.leadingAnchor constraintEqualToAnchor:self.contentView.leadingAnchor constant:0] setActive:YES];
    [[webView.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor constant:0] setActive:YES];
    [[webView.bottomAnchor constraintEqualToAnchor:self.contentView.bottomAnchor constant:0] setActive:YES];
    self.webView = webView;
    webView.navigationDelegate = self;
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://developers.google.com/identity/sign-in/web/build-button"]];
    [request setValue:[self getUserAgent] forHTTPHeaderField:@"User-Agent"];
    [self.webView loadRequest:request];
}

When I'm trying to click the button with the safary's web inspector open I don't see any respond as well.当我尝试在 safary 的 web 检查器打开的情况下单击按钮时,我也没有看到任何响应。

Any help will be appreciated, thanks.任何帮助将不胜感激,谢谢。

PS: Just to be clear none WKWebView delegate is being called. PS:为了清楚起见,没有调用 WKWebView 委托。

Apparently, since 2016, Google no longer allows OAuth requests to Google in embedded browsers known as “web-views”, as mentioned here .显然,自 2016 年以来,谷歌不再允许在称为“网络视图”的嵌入式浏览器中向谷歌发出 OAuth 请求,如此所述。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM