我怎样才能修复由于不允许useragent引起的function受损?

我最近build立了一个networking浏览器,当我尝试在网站上使用我的Google帐户login时遇到错误。

截图

这很奇怪,因为我检查了我的应用程序和Safari的用户代理,它们都是相同的。

有什么build议么?

UPDATE

WKWebView在自定义的UIViews树中嵌套3层。

这是初始化代码:

_webView = [[WKWebView alloc] init]; _webView.allowsBackForwardNavigationGestures = NO; _webView.allowsLinkPreview = NO; _webView.navigationDelegate = self; _webView.UIDelegate = self; _webView.frame = CGRectMake(0.0, 0.0, self.contentView.frame.size.width, self.contentView.frame.size.height); [self.contentView addSubview:_webView]; 

来自Google 现代化本机应用程序中的OAuth交互以提高可用性和安全性文章:

2017年4月20日,我们将开始使用networking视图为所有可用备选平台上的所有OAuth客户端屏蔽OAuth请求。

因此,Google现在只允许在普通浏览器中使用Google帐户login,并且出于安全原因在networking视图中对其进行限制,并为此推荐适用于iOS和Android的 Google SDK。

但是如果你仍然想使用WKWebView你可以做一些小技巧,在这个答案中build议设置customUserAgent这样它就可以通过validation:

 // Check for selector availability, as it is available only on iOS 9+ if ([_webView respondsToSelector:@selector(setCustomUserAgent:)]) { _webView.customUserAgent = @"MyCustomUserAgent"; }