gpt4 book ai didi

ios - 如何修复由不允许的用户代理导致的功能受损?

转载 作者:可可西里 更新时间:2023-11-01 03:31:32 25 4
gpt4 key购买 nike

我正在构建网络浏览器,最近我在尝试使用我的 Google 帐户在网站上登录时遇到错误。

Screenshot

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

有什么建议吗?

更新

WKWebView 嵌套在自定义 UIView 树中的 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];

最佳答案

来自谷歌 Modernizing OAuth interactions in Native Apps for Better Usability and Security文章:

On April 20, 2017, we will start blocking OAuth requests using web-views for all OAuth clients on platforms where viable alternatives exist.

因此,Google 现在只允许在普通浏览器中使用 Google 帐户登录,出于安全原因限制在 WebView 中使用,并推荐使用 Google SDK iOSAndroid以此目的。

但是如果你仍然想使用WKWebView,你可以做一些小技巧,在this中建议。 answer,设置customUserAgent使其可以通过验证:

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

关于ios - 如何修复由不允许的用户代理导致的功能受损?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44344720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com