Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two iOS apps using the same Facebook app ID - is it possible?

I'm using the latest facebook iOS SDK (supporting SSO) to connect my iPhone app with facebook. So far so good..

Since my current app is free with ads, I would like to create another version without ads (which i will charge for). I prefer not to use the in-app purchase approach.

The problem i'm facing is that with the facebook SSO, I need to bind the iOS application to a URL which is based on the facebook app ID. Since I have only one facebook app to be used by both of the iphone apps, the two iOS apps are binded to the same URL and therefore when both of them are installed on a device the callback from facebook to my app does not work (or opens the other app instead).

Is there a solution for that besides creating another facebook app dedicated to the new version of the iphone app?

Thanks.

like image 911
Amir Naor Avatar asked May 13 '11 15:05

Amir Naor


2 Answers

I had to use FBLoginView in my app, and none of this solutions worked. The only missing thing was that i needed to add a new entry in the plist file: FacebookUrlSchemeSuffix (documented here, in the Step 2).

Suppose that your App ID is 123456, what i had to do was:

1) In your facebook app, add a URL Scheme Suffix in the iOS section:

enter image description here

2) In both of your applications, go to the app's .plist, and add the following entry:

enter image description here

Note that the Value must be one of the URL Scheme Suffixes added.

3) Also change your URL Scheme for Facebook in the .plist file to fb. For example, fb123456client

enter image description here

like image 101
lucaslt89 Avatar answered Nov 03 '22 13:11

lucaslt89


In the latest Facebook iOS SDK on Github there's a method called authorize:delegate:localAppId: initWithAppId:urlSchemeSuffix:andDelegate:. You can use the localAppId urlSchemeSuffix parameter to distinguish multiple iOS Apps that use the same Facebook application id. The method documentation says:

urlSchemeSuffix is a string of lowercase letters that is appended to the base URL scheme used for SSO. For example, if your facebook ID is "350685531728" and you set urlSchemeSuffix to "abcd", the Facebook app will expect your application to bind to the following URL scheme: "fb350685531728abcd". This is useful if your have multiple iOS applications that share a single Facebook application id (for example, if you have a free and a paid version on the same app) and you want to use SSO with both apps. Giving both apps different urlSchemeSuffix values will allow the Facebook app to disambiguate their URL schemes and always redirect the user back to the correct app, even if both the free and the app is installed on the device.

urlSchemeSuffix is supported on version 3.4.1 and above of the Facebook app. If the user has an older version of the Facebook app installed and your app uses urlSchemeSuffix parameter, the SDK will proceed as if the Facebook app isn't installed on the device and redirect the user to Safari.

like image 21
Zargony Avatar answered Nov 03 '22 13:11

Zargony