Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use multiple Facebook App IDs in a single iOS Application?

I want an iOS app to switch between a number of Facebook apps during runtime.

I want the user to be able to login and post under different Facebook App IDs depending which part of the iOS app they are using.

The Facebook iOS SDK reads Facebook AppID from the .plist file. Is it possible to change the AppID during runtime and have the user effectively logged into multiple Facebook App at the same time?

like image 580
Yao Y Avatar asked Oct 18 '13 17:10

Yao Y


1 Answers

FBSession has an initializer that can be used to specify an AppID.

FBSession *session = [[FBSession alloc] initWithAppID:@"AN_APP_ID"
                                          permissions:nil
                                      defaultAudience:FBSessionDefaultAudienceNone
                                      urlSchemeSuffix:nil
                                   tokenCacheStrategy:nil];
[session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    // do stuff here
}];

So you can instantiate several FBSessions and use them in different parts of the app.

You just have to change the active session to switch from an app to another

[FBSession setActiveSession:mySession];
like image 180
Gabriele Petronella Avatar answered Oct 04 '22 00:10

Gabriele Petronella