title: How can I get UIWebView to open Facebook login page in response to the OAuth request on iOS 5 and iOS 6?
body: <p>We have:<br>
  (1) Facebook API-based web application with Facebook OAuth functionality (“the FB web app”)<br>
  (2) <code>UIWebView</code>-based browser on iPad  (“the Browser”)  </p>
  
  <p>Our objective is to open the Facebook Login page to sign in to the FB web app (1) inside the UIWebView-based Browser (2) on iPad.</p>
  
  <p>There is a somewhat similar issue here:<br>
  <a href="http://facebook.stackoverflow.com/questions/11337285/no-longer-able-to-login-to-ios-app-via-oauth-the-page-requested-was-not-found">http://facebook.stackoverflow.com/questions/11337285/no-longer-able-to-login-to-ios-app-via-oauth-the-page-requested-was-not-found</a></p>
  
  <p>However, the issue of that question happens after the user enters login and password into the Facebook form. Our problem is that we cannot get the Facebook login form displayed in the first place. Changing the app type to from “Web” to “Native/Desktop”, as suggested in that question, did not help.</p>
  
  <p>Steps:<br>
  1. Open our web page (simple HTML page) with this <code>UIWebView</code> Browser<br>
  2. Click on “FB web app” launch button on this page<br>
  3. OnClick JavaScript tries to initiate OAuth, which should open the login screen of Facebook to sign in to the FB web app  </p>
  
  <p>Current outcome (issue):<br>
  On iOS 5.+ and iOS 6.+ devices<br>
  - Our web page stays unchanged<br>
  - Facebook login page is NOT shown (our web page is still displayed)<br>
  On iOS 4.3 (works as expected):<br>
  - the Facebook login page is opened in the same <code>UIWebView</code> object of the Browser (replaces our web page)  </p>
  
  <p>Expected outcome:<br>
  - Facebook login page is displayed, and the user can enter Facebook login &amp; password<br>
  - Works on iOS 5.+ and iOS 6.+ if launched in Safari browser on iPad. Facebook login page is opened in a separate tab (in contrast, there are no separate tabs in <code>UIWebView</code>)  </p>
  
  <p>Question: How can I get <code>UIWebView</code> to open Facebook login page in response to the OAuth request on iOS 5+ and iOS 6+?  </p>
  
  <p>More technical details:</p>
  
  <p>We log different <code>NSURLRequest</code> fields from within        </p>
  
  <pre><code>-(BOOL)webView(UIWebView*)webView shouldStartLoadWithRequest(NSURLREquest*)request navigationType:…   
  </code></pre>
  
  <p>And we notice some difference in logs for “correct” and “incorrect” behaviors. Here how execution flows look for me:</p>
  
  <p>Firstly, I press “FB Web App” launch button to initiate OAuth, then some cases go</p>
  
  <p>iOS 4.3, “correct”<br>
      request to www.facebook.com/dialog/oauth?...<br>
      request to fbwebapp.com<br>
      request to m.facebook.com/login.php?....<br>
  --here facebook login appears  </p>
  
  <p>iOS 5.0, “incorrect1”<br>
      request to www.facebook.com/dialog/oauth?...<br>
      request to fbwebapp.com<br>
      request to m.facebook.com/login.php?...    </p>
  
  <p>Then it may be<br>
  --a lot of m.facebook.com/login.php?...with next… in parameters<br>
  followed by sqlite error<br>
  --right now I see “Sorry, something went wrong” page from facebook (it’s a first time at all I encounter it)  </p>
  
  <p>iOS 6.0 “incorrect2”<br>
      request to www.facebook.com/dialog/oauth?...<br>
      request to fbwebapp.com  </p>
  
  <blockquote>
    <p>-(void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error is invoked with error code -999</p>
  </blockquote>
  
  <p>You can see that behavior definitely depends on iOS version. But common case is that error happens on the step of obtaining m.facebook.com/login.php.. URL. But that’s all that we can detect.  </p>
  
  <p>We’re banging our heads against that wall for the whole day looking for solutions. Hopelessly.<br>
  Can you help us get the Facebook Login page opened in the <code>UIWebView</code> in response to OAuth?</p>