One of the webpage I load into Wkwebview has the following iTunes app link
https://itunes.apple.com/gb/app/xx-yy-zz/id435919263?mt=8
when it's opened I'm getting the following alert
and here's the error that I've got.
{
"[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";
}
When the same iTunes link ( https://itunes.apple.com/gb/app/xx-yy-zz/id435919263?mt=8 ) is opened in UIWebview , I saw that URL gets redirected to following URL and app opens in appstore
itms-appss://itunes.apple.com/gb/app/xx-yy-zz/id435919263?mt=8
Whereas in Wkwebview , the URL gets redirected to following URL
itms-appss://apps.apple.com/gb/app/xx-yy-zz/id435919263
Any help is appreciated
Update
I even tried Arbitrary uploads to true for transport security and the problem is still there.
Error Domain= Code=0 "Redirection to URL with a scheme that is not HTTP(S)" 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=Redirection to URL with a scheme that is not HTTP(S)}
WKWebView - This view allows developers to embed web content in your app. You can think of WKWebView as a stripped-down version of Safari. It is responsible to load a URL request and display the web content. WKWebView has the benefit of the Nitro JavaScript engine and offers more features.
Unlike UIWebView, which does not support server authentication challenges, WKWebView does. In practical terms, this means that when using WKWebView, you can enter site credentials for password-protected websites.
As of iOS 12.0, 'UIWebView' has been explicitly marked as deprecated. Apple is encouraging developers to adopt WKWebView instead, which was introduced in iOS 8.0.
A WKWebView object is a platform-native view that you use to incorporate web content seamlessly into your app's UI. A web view supports a full web-browsing experience, and presents HTML, CSS, and JavaScript content alongside your app's native views.
I think you could try to intercept the itunes link in wkwebview's delegate methods and open the URL using openURL
The below source code will open any itms-appss links in wkwebview. Don't forget to conform to 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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With