Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook & iOS: Share an app ID across multiple apps

I'm having problems implementing this functionality after following Facebook's tutorial: https://developers.facebook.com/docs/howtos/share-appid-across-multiple-apps-ios-sdk/

Basically, I have 2 targets under the same project - one for the free version and one for the premium. I have created and set up a single Facebook app for this and added 2 url scheme suffixes:

two URL scheme suffices

Also, I've added the suffixes within the respective plist files. For example, the premium app is defined with:

screenshot of info.plist file

Where the "xxxxx..." is just my Facebook app ID.

After all this, I still can't log in to the application on iOS 5.0 and 6.0 (using native FB dialog or the SDK dialog within Safari). This is what I get when I log in via Safari:

alert with message "cannot open page, safari cannot open the page because the address is invalid"

The code doing the login is:

NSArray *permissions = kInitialPermissions;

BOOL result = NO;
FBSession *session = [[FBSession alloc] initWithAppID:@"xxxxxxxxxxx"
                                          permissions:@[]
                                      urlSchemeSuffix:@"premium"
                                   tokenCacheStrategy:nil];

if (allowLoginUI ||
    (session.state == FBSessionStateCreatedTokenLoaded)) {
    [FBSession setActiveSession:session];
}

result = [FBSession openActiveSessionWithReadPermissions:permissions
                                                allowLoginUI:allowLoginUI
                                           completionHandler:completion];
return result;

Any ideas will be appreciated. Thanks!

like image 434
Stavash Avatar asked Feb 18 '13 13:02

Stavash


1 Answers

As well as adding the fbxxxxxxxxxxpremium URL Scheme to the the URL Types array in the plist file (which you seem to be doing), add a new key/value:

key = FacebookUrlSchemeSuffix
value = premium

So in the plist file itself:

<key>FacebookUrlSchemeSuffix</key>
<string>premium</string>

This fixed it for me. The Facebook docs make reference to this but don't make it clear IMO.

like image 180
Dunc Avatar answered Oct 14 '22 20:10

Dunc