UIWebView / Facebook OAuth Dialog - Says "Not Logged In"

Problem

In my iOS app, users access Facebook via UIWebView. Sometimes instead of the Facebook login page, the message "Not logged in" is displayed:

enter image description here

I can reproduce the problem every time with several lines of code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIWebView* web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)]; [self.window addSubview:web]; NSString* url = @"https://m.facebook.com/dialog/oauth?client_id=9999999999999999&redirect_uri=https%3A%2F%2Fmysite.com%2FApp%2FFacebookLogin%2FCallback&response_type=code&scope=read_stream%2Cuser_about_me%2Coffline_access%2Cpublish_actions%2Cpublish_stream%2Cemail"; [web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]; } 

What i tried

If I open the same URL in mobile safari using [[UIApplication sharedApplication] openUrl:...] then it will work. It shows the login page without any problems.

If I change the scope to email, it will work in the web view without any problems. If I change it by adding an element, it will still break.

I tried cleaning cookies and cache for UIWebView, and I uninstalled the application and reinstall it to try to clear everything. None of this works.

If I change the URL by adding &state=abcd to force the browser to reload the request, it still breaks. It does not affect.

If I use the domain www.facebook.com instead of m.facebook.com , then it works.

If I write shouldstartloadwithrequest to a UIWebView, it will show that the url is loading, then it is loading again. In other words, facebook seems to be redirecting to itself.

Also, I have a bug with Facebook ( https://developers.facebook.com/bugs/452609994811240 ), and they ported it to "medium", so this might just be a bug in their system.

Any idea how I can get the login page to show without messing with the area?

+4
source share

All Articles