4

I am adding facebook comments to my iPad application using UIWebView and HTML5 code provided by Facebook. When the user is not logged in, the application shows the comments and button "Login to Facebook to Post a Comment".

Comments initial window

Clicking the button takes me through login process. After the login completes the view is redirected with an empty page with "Login complete" message. It is not redirected back to the comments dialog.

enter image description here

Right now I implemented an ugly workaround. Upon receiving webViewDidFinishLoad event, I look at contents of the page and reload it if the page shows this message. Though, it does not seem a clean way to go.

Why doesn't Facebook redirect me back to original comments page?

UrK
  • 2,191
  • 2
  • 26
  • 42

3 Answers3

1

I suspect the problem you're having is related to this issue: Facebook authentication in a UIWebView does not redirect back to original page on my site asking for auth

Specifically, the standard Facebook web login process launches a new browser window dialog, and dispatches a message back to the opener to indicate login success for the redirect to occur.

Quoting a passage in the linked SO, "UIWebView doesn't support multiple windows so it can't postMessage back to your original page since it's no longer loaded."

Community
  • 1
  • 1
Khan
  • 423
  • 4
  • 9
0

I'm also developing an iPad application, and my solution is similar to yours: i drive the user to "https://m.facebook.com", always, to force him to login first, then in "webViewDidFinishLoad" i inspect the returned url and if it matches:

"https://m.facebook.com/login/checkpoint/"

exactly, that is, the url returned upon a successful login, then i call my own method (with reload or anything i want). At this time, the user is authenticated and has a valid FB session, so, redirections are not necessary anymore.

It's definitely not pretty, and may break as soon as FB changes the way it processes the login dialog, but i too cannot find a way to resolve it any better. Even tried using "FB.Event.subscribe('auth.login', function(response) {});" without success, of course, because the code is never reached.

I think a bug is already submitted to FB, but i don't think it's getting the deserved attention...

0

I ran into same issue as this question, but after reading some Facebook official documentation, I'll be redesigning to use the Facebook native SDK.

All iOS and Android apps must (effective October 2, 2013) use our SDKs for iOS and Android for requesting permissions.

Though, I also gather that the "or else" is just a "developer notification"?

Posting this in hopes it will save time for someone using the same approach :)

GraehamF
  • 1,971
  • 24
  • 24