9

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!

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
Gypsa
  • 11,230
  • 6
  • 44
  • 82

2 Answers2

4

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.

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
  • 1
    Here is standard Facebook dialog that appears when device is not support multitasking. – SVGreg Jun 02 '11 at 12:13
  • @Simon no my requirement is when I click this button activity indicator gets opened until new dialog gets open. – Gypsa Jun 02 '11 at 12:30
  • @Gypsa, You want to show an activity indicator when user taps the login button? FBConnect already displays an activity indicator, right? – EmptyStack Jun 02 '11 at 12:49
  • no it dont display on clicking login button which is shown in screenshot – Gypsa Jun 02 '11 at 13:01
  • @Gypsa, Ok. You don't want to display an activity indicator when the login button is pressed. What you want to do when the login button is pressed? – EmptyStack Jun 02 '11 at 13:07
  • @Simon: I mean the screenshot in question. – SVGreg Jun 02 '11 at 14:01
  • @Gypsa: as say Simon - you need to use UIWebViewDelegate to catch login action – SVGreg Jun 02 '11 at 14:04
1

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).
SVGreg
  • 2,320
  • 1
  • 13
  • 17
  • 1
    NOTE: if you use "authorize" method from Facebook.h and see this dialog - then you device not support multitasking. – SVGreg Jun 02 '11 at 12:10
  • @Gypsa: as say Simon - you need to use UIWebViewDelegate to catch login action. And I didn't find any other approach. – SVGreg Jun 02 '11 at 14:12