views:

45

answers:

2

Hi All,

I have integrated Facebook connect in my iphone application.

when user clicks on a button i am calling a method which has the following code.

session1 = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
dialog = [[[FBLoginDialog alloc] initWithSession:session1] autorelease];
[dialog show];

when the user login into the Facebook with his username and password, if the user name and password are incorrect it is showing the message correctly.

but when the user enters correct user name and password, the entire face book window is closing without giving any message.

+1  A: 

It works correctly. The facebook window closes mean your user login successfully. You should handle some delegate:

#pragma mark FBSessionDelegate

- (void)session:(FBSession*)session didLogin:(FBUID)uid {

}

- (void)sessionDidNotLogin:(FBSession*)session {

}

- (void)session:(FBSession*)session willLogout:(FBUID)uid {

}

- (void)sessionDidLogout:(FBSession*)session {
//    NCLog(@"FacebookHelper logged out");
}

Then you will know what happens to the login process

vodkhang
hi, thank you for the update it is very helpful to me..further more, is there any reference how to handle these delegates?
Ganesh
I think you can adopt the FBSessionDelegate and then after logging in, you will have a FBUID of the user. Save it for any other uses
vodkhang
+1  A: 

Vodkhang has the right answer, but also know that since Facebook connect stores info in the user defaults, you should insert a

if (![session1 resume]) {

before you invoke the dialog. This will ensure that future uses of the app will not generate the same login dialog.

The didLogin: delegate function will still be invoked when the session is resumed, so you can still do whatever you need with the FBUID. One simple thing you can do is create a hidden Label in Interface Builder and assign the FBUID to that label in the didLogin function. That way you can always pull that label's text if you need the FBUID later.

Ryan Garcia