din*_*h R 5 ios wkwebview itms-90809
我加载到Wkwebview的网页之一具有以下iTunes应用程序链接
https://itunes.apple.com/gb/app/xx-yy-zz/id435919263?mt=8
Run Code Online (Sandbox Code Playgroud)
当它打开时,我收到以下警报
这是我遇到的错误。
{
"[errorCode]" = 0;
"[errorDescription]" = "Redirection to URL with a scheme that is not HTTP(S)";
"[errordetail]" = "Con:myappxxxx:myorder:webview:networkerror";
"[localizedRecoverySuggestion]" = "";
"[url]" = "itms-appss://apps.apple.com/gb/app/xx-yy-zz/id435919263";
}
Run Code Online (Sandbox Code Playgroud)
当在UIWebview中打开相同的iTunes链接(https://itunes.apple.com/gb/app/xx-yy-zz/id435919263?mt=8)时,我看到URL被重定向到以下URL并在应用商店
itms-appss://itunes.apple.com/gb/app/xx-yy-zz/id435919263?mt=8
Run Code Online (Sandbox Code Playgroud)
而在Wkwebview中,URL被重定向到以下URL
itms-appss://apps.apple.com/gb/app/xx-yy-zz/id435919263
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏
更新资料
为了传输安全,我什至尝试将Arbitrary上传设为true,但问题仍然存在。
错误域=代码= 0“使用非HTTP(S)的方案重定向到URL” UserInfo = {_ WKRecoveryAttempterErrorKey =,NSErrorFailingURLStringKey = itms-appss://apps.apple.com/gb/app/xx-yy-zz /id435919263,NSErrorFailingURLKey=itms-appss://apps.apple.com/gb/app/xx-yy-zz/id435919263,NSLocalizedDescription=使用非HTTP(S)方案重定向到URL}
我认为您可以尝试拦截 wkwebview 的委托方法中的 iTunes 链接并使用 openURL 打开 URL
下面的源代码将在 wkwebview 中打开任何 itms-appss 链接。不要忘记遵守WKNavigationDelegate
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
if ([webURL.scheme isEqualToString:@"itms-appss"])
{
UIApplication *app = [UIApplication sharedApplication];
if ([app canOpenURL:webURL])
{
[self.webviewObj stopLoading];
[app openURL:[NSURL URLWithString:[webURL absoluteString]]];
decisionHandler(WKNavigationActionPolicyCancel);
} else{
decisionHandler(WKNavigationActionPolicyCancel);
}
}
else
{
decisionHandler(WKNavigationActionPolicyAllow);
}
return;
}
Run Code Online (Sandbox Code Playgroud)