title: UIWebView load fails with custom URL scheme
body: <p>I have a UIWebView that is handling an OAuth authentication flow in my app. The callback URL that the OAuth service uses points to a custom URL scheme I've set up in my app, let's call it <code>mycustomurlscheme</code>. </p>
  
  <p>So once the user authenticates successfully, the OAuth service redirects them to the URL <strong>mycustomurlscheme://oauth/success?oauth_token=xxxxxxxxxxxxxxxxxxxx&amp;oauth_verifier=xxxxxxxxxxxxxxxxxxxx</strong>. When the UIWebView requests this URL, the app behaves correctly; namely, the <code>application:openURL:sourceApplication:annotation:</code> method in my app delegate gets called, and I dismiss the UIWebView and continue on with the app.</p>
  
  <p>However, I am logging load failures in the UIWebView (using <code>webView:didFailLoadWithError:</code>), and when the above process happens, I see the following in the console:</p>
  
  <pre><code>Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0xa1a4810 {NSErrorFailingURLKey=mycustomurlscheme://oauth/success?oauth_token= xxxxxxxxxxxxxxxxxxxx&amp;oauth_verifier=xxxxxxxxxxxxxxxxxxxx, NSErrorFailingURLStringKey=mycustomurlscheme://oauth/success?oauth_token= xxxxxxxxxxxxxxxxxxxx&amp;oauth_verifier=xxxxxxxxxxxxxxxxxxxx, NSLocalizedDescription=Frame load interrupted}
  </code></pre>
  
  <p>I tried implementing the following UIWebViewDelegate method, thinking that intercepting the request would avoid the error, but the error still happens:</p>
  
  <pre><code>- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request
   navigationType:(UIWebViewNavigationType)navigationType
  {
      if ([request.URL.scheme isEqualToString:@"mycustomurlscheme"]) {
          [[UIApplication sharedApplication] openURL:request.URL];
          return NO;
      } else {
          return YES;
      }
  }
  </code></pre>
  
  <p>This code then causes the following code in my app delegate to run:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application
              openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication
           annotation:(id)annotation
  {
      NSNotification *notification = [NSNotification notificationWithName:kDSApplicationLaunchedWithURLNotification object:nil userInfo:@{kApplicationLaunchOptionsURLKey: url}];
      [[NSNotificationCenter defaultCenter] postNotification:notification];
  
      return YES;
  } 
  </code></pre>
  
  <p>This notification is picked up by the following block that continues the loading &amp; launching of the app, post-authorization:</p>
  
  <pre><code>self.applicationLaunchNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kDSApplicationLaunchedWithURLNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
                      NSURL *url = [notification.userInfo valueForKey:kApplicationLaunchOptionsURLKey];
                      currentRequestToken.verifier = [DSAPIParametersFromQueryString([url query]) valueForKey:@"oauth_verifier"];
  
                      [[DSAPIManager sharedManager] acquireAccessTokenWithRequestToken:currentRequestToken success:^(DSAPIOAuth1Token * accessToken) {
                          [self finishLogin];
                      } failure:^(NSError *error) {
                          [self removeAsObserver];
                          [self showAlert:NSLocalizedString(@"Could not authorize the app. Please try again later.", nil)];
                      }];
                  }];
  </code></pre>
  
  <p>The <code>finishLogin</code> and <code>removeAsObserver</code> methods look like this:</p>
  
  <pre><code>- (void)finishLogin
  {
      [self removeAsObserver];
      [self.navigationController dismissViewControllerAnimated:YES completion:^{
          [self performSegueWithIdentifier:@"PostLoginSegue" sender:self];
      }];
  }
  
  - (void)removeAsObserver
  {
      if (self.applicationLaunchNotificationObserver) {
          [[NSNotificationCenter defaultCenter] removeObserver:self.applicationLaunchNotificationObserver];
          self.applicationLaunchNotificationObserver = nil;
      }
  }
  </code></pre>
  
  <p>Is it safe to ignore this error message? Anyone know why it's happening? My hunch is that the UIWebView thinks the URL has an invalid scheme, but the phone knows it's ok. If that's the case is there any way to tell the UIWebView (or the WebKit engine) that this scheme is valid?</p>