简体   繁体   中英

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.

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.

This is my WKWebView configuration with the google's doc link:

- (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.

Any help will be appreciated, thanks.

PS: Just to be clear none WKWebView delegate is being called.

Apparently, since 2016, Google no longer allows OAuth requests to Google in embedded browsers known as “web-views”, as mentioned here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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