Search code examples
iosobjective-cios7uiwebview

Why cant open itms-services protocol inside an UIWebView iOS7.1 app?


I open an UIWebView with the following link:

itms-services://?action=download-manifest&url=https://XXX.plist

The server it's SSL (https) enabled. If I open the page in Safari works right and I can download and install the update, but when I open the equal link inside the App y press the link and nothings happen.

Edit:

Console: Navigation started when state=1


Solution

  • App has to hadle custom schemes by its own. Catch URL in UIWebViewDelegate and open it by UIApplication (if it can handle it):

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
        NSURL *url = request.URL;
        if (!([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"] || [url.scheme isEqualToString:@"about"])) {
            UIApplication *app = [UIApplication sharedApplication];
            if ([app canOpenURL:url]) [app openURL:url];
            return NO;
        }
        return YES;
    }