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:
Also, I've added the suffixes within the respective plist files. For example, the premium app is defined with:
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:
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!
Your issue is that the custom URL scheme is not being recognized by iOS. Here are some possible causes:
I see that you've correctly set the CFBundleURLSchemes
key in your plist to an array of supported schemes. You also need to set CFBundleURLName
to something like com.myApp.MyURLScheme. Have you done this?
After calling will and did finish launching methods, iOS will call your app delegate's - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
method. You must also implement this method and it must return YES
. Have you?
Make sure your URL format is correct. fbxxxxxxpremium://foo=bar
won't work, but fbxxxxxxpremium://?foo=bar
will (the ?
is mandatory).
Please note that the delegate methods will be slightly different if you are targeting iOS 4.1 or earlier.
For more info and sample code, see the Communicating with Other Apps section of Advanced App Tricks in the iOS SDK documentation.