views:

24

answers:

0

Hi

I am trying to make FBConnect a bit easier to use different places in my app by wrapping it in a UIViewController that I can instantiate and use.

The meat of it looks like this:

@implementation ISFacebookViewController

@synthesize facebookSession;
@synthesize delegate;

- (void)viewDidLoad {

    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor clearColor]];
}

- (void) publishContentToFacebook:(NSString*) content {

    [self setDataToPublish:content];

    facebookSession = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];   

    if ([facebookSession resume]) {

        ISLog(@"Allready authenticated");
        [self publishFeed:self.dataToPublish];

    } else {

        FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:facebookSession] autorelease];
        [dialog show];
    }
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// FB Delegate methods...

My intention is that I can call the [publishContentToFacebook:content]; from "anywhere" by instantiating my ISFacebookController and from there on have FBConnect handle displaying the different dialogs as needed.

My problem is now that if I instantiate the ISFacebookController and add its view manually with addSubview [self.view addSubView:[facebookCOntroller view]], or if I use [self presentModalViewController:facebookController]; it will seem to work, but pressing skip or cancel it turns out that the FB pop up for login or publish has been added twice, i.e. there are two pop ups on top of each other and the user needs to press skip/cancel twice for them both to go away.

My instantiation goes through a custom button and not by adding the FBConnect login button;

Can this be the reason?

In tutorials I only see people add the actual login button and it just works (seems the login button adds the pop up), never seen anyone trying to add the controller holding the session:

Is there a wrapper that can do this or how should I go about wrapping the core functionality and all the FB delegate methods in a separate Controller?