Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button Action on login Button click in FBConnect API

I am using fbconnect api in my project.When the login dialog gets opened where we entered our credentials ,when I click on login button there is something performed and it is redirected to the publish page. My problem is I am not getting which action is performed on that login button so that I can put an indicator over there.

I have attached a screenshot to specify which button I am talking about. enter image description here

Any suggestions will be highly appreciated!

like image 241
Gypsa Avatar asked Jun 02 '11 11:06

Gypsa


2 Answers

Do you want to steal others' Facebook passwords? :)

It seems, FBConnect uses UIWebView to load the pages from web. Those form elements are not created from the code. So you can not have the access to those methods/actions.


Tracking the login button action using UIWebViewDelegate:

In webView:shouldStartLoadWithRequest:navigationType: delegate method in FBDialog.m, you can see the request which are sent from the login view.

You can read the URL by using [request.URL absoluteString]. Check if that URL contains the string https://www.facebook.com/login.php?m=m. If it is YES then probably a login request is being sent. You can do your action there.

Note: I am not sure this will always work. You can do further research to find a better solution.

like image 170
EmptyStack Avatar answered Nov 12 '22 19:11

EmptyStack


When you push login button - the login request will send to FB server only. To get answer you need to implement FBSessionDelegate protocol:

/**
 * Called when the user successfully logged in.
 */
- (void)fbDidLogin;

/**
 * Called when the user dismissed the dialog without logging in.
 */
- (void)fbDidNotLogin:(BOOL)cancelled;

/**
 * Called when the user logged out.
 */
- (void)fbDidLogout;

Read also comments in Facebook.m:

  • Starts a dialog which prompts the user to log in to Facebook and grant
  • the requested permissions to the application. *
  • If the device supports multitasking, we use fast app switching to show
  • the dialog in the Facebook app or, if the Facebook app isn't installed,
  • in Safari (this enables single sign-on by allowing multiple apps on
  • the device to share the same user session).
  • When the user grants or denies the permissions, the app that
  • showed the dialog (the Facebook app or Safari) redirects back to
  • the calling application, passing in the URL the access token
  • and/or any other parameters the Facebook backend includes in
  • the result (such as an error code if an error occurs).
like image 33
SVGreg Avatar answered Nov 12 '22 20:11

SVGreg