How to have a paid and free version of iOS app sha

2020-06-05 01:53发布

问题:

I have a free and a paid version of the same iPhone app. I would like for them to share a Facebook App ID since they are essentially the same app. I thought I could accomplish this by using this method from the Facebook class.

- (void)authorize:(NSArray *)permissions localAppId:(NSString *)localAppId

However, login always fails for one of the apps (in my case the free version) and it would seem that the reason is that the Facebook app created in the web interface asks for an App Bundle ID and App Store ID. Obviously the free version and paid version of my apps cannot have the same bundle id or app id so how can I make this work?

The docs in Facebook.m suggest that it is possible with the authorize method I mention above:

/*
 * ...
 * @param localAppId
 *            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. 
 * ...
 */

Thanks. - Alex

回答1:

You can make it work. Each app must have different url schemes (since that is how Facebook redirects back to your app).

Example url schemes you must support: (Your facebook app id: "fb123456789")

Without setting localAppId: "fb123456789" (localAppId = nil)

Free app url scheme: "fb123456789lite" (localAppId = "lite")

Paid app url scheme: "fb123456789pro" (localAppId = "pro")

From the comments:

localAppId 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 localAppId to "abcd", the Facebook app will expect your application to bind to the following URL scheme: "fb350685531728abcd".