Yao Y
Yao Y

Reputation: 51

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?

Upvotes: 5

Views: 2149

Answers (1)

Gabriele Petronella
Gabriele Petronella

Reputation: 108169

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];

Upvotes: 8

Related Questions