My goal is to make an apprequest button in my app that invites friends.
The problem is that it asks me to log-in. This would not normally be a problem but in this context, the users have already input their login information to facebook in order to perform another feature within the app. That feature was written by somebody else who is not currently available.
What ends up happening is that the user has to log-in twice. Once to use the other person’s feature, once to use the apprequest dialog. I need to somehow share the credentials/authorization/session such that I do not prompt the user to login twice.
I don’t see any parameters to be passed in the standard app request dialog code to pre-authorize the attempt. I assume there’s something I can do with the Facebook object. Also, I’m very new to Objective C so my understanding of the delegate stuff is really weak. I’ve been looking at it but I’ve no idea what kind of function the facebook object would want as a delegate. My understanding is that facebook can callback to the delegate, essentially giving a asynchronous ack or req or something of the sort. But how am I supposed to know what kind of a delegate it expects? What parameters will it pass? Etc..
Anyways, here’s the very basic block of code for my app request. I’ve no idea where to go from here to prevent that login box from popping up twice.
Facebook *facebook = [[Facebook alloc] initWithAppId:<#(NSString *)#> andDelegate:<#(id<FBSessionDelegate>)#>];
// I realize I have to fill in my own AppID, which I have but I'm not entirely sure about the delegate
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Come check out my app.", @"message",
nil];
[self.facebook dialog:@"apprequests" andParams:params andDelegate:nil];
You’ll need to set the
accessTokenandexpirationDateproperties on yourFacebookinstance in order to reuse the session created by the other feature. You can persist these values usingNSUserDefaultsor a similar mechanism.Note that there’s a new version of the Facebook SDK (3.0) that has much better automatic session handling. At some point in the future, it’s likely to be mandatory, so you should switch to it when you get the chance.