Skip to content

Commit

Permalink
rename localAppId to urlSchemeSuffix
Browse files Browse the repository at this point in the history
Summary: urlSchemeSuffix is more descriptive and easier to grok than
localAppId.

Warning: This changes breaks compatibility with the previous version of the SDK. Please update your code to use the latest method signature.

Test Plan: compiled and ran the demo app with a urlSchemeSuffix configured

Reviewers: brent, lshepard, teck

Reviewed By: lshepard

CC: brent, lshepard

Differential Revision: 334704

Task ID: 737701
  • Loading branch information
Yariv Sadan committed Sep 28, 2011
1 parent f6755fe commit 22f88dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/Facebook.h
Expand Up @@ -33,22 +33,22 @@
FBDialog* _loginDialog;
FBDialog* _fbDialog;
NSString* _appId;
NSString* _localAppId;
NSString* _urlSchemeSuffix;
NSArray* _permissions;
}

@property(nonatomic, copy) NSString* accessToken;
@property(nonatomic, copy) NSDate* expirationDate;
@property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate;
@property(nonatomic, copy) NSString* localAppId;
@property(nonatomic, copy) NSString* urlSchemeSuffix;

- (id)initWithAppId:(NSString *)appId
andDelegate:(id<FBSessionDelegate>)delegate;

- (void)authorize:(NSArray *)permissions;

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

- (BOOL)handleOpenURL:(NSURL *)url;

Expand Down
32 changes: 16 additions & 16 deletions src/Facebook.m
Expand Up @@ -47,7 +47,7 @@ @implementation Facebook
expirationDate = _expirationDate,
sessionDelegate = _sessionDelegate,
permissions = _permissions,
localAppId = _localAppId;
urlSchemeSuffix = _urlSchemeSuffix;


///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -79,7 +79,7 @@ - (void)dealloc {
[_fbDialog release];
[_appId release];
[_permissions release];
[_localAppId release];
[_urlSchemeSuffix release];
[super dealloc];
}

Expand Down Expand Up @@ -123,7 +123,7 @@ - (FBRequest*)openUrl:(NSString *)url
- (NSString *)getOwnBaseUrl {
return [NSString stringWithFormat:@"fb%@%@://authorize",
_appId,
_localAppId ? _localAppId : @""];
_urlSchemeSuffix ? _urlSchemeSuffix : @""];
}

/**
Expand All @@ -136,7 +136,7 @@ - (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
@"user_agent", @"type",
kRedirectURL, @"redirect_uri",
@"touch", @"display",
kSDKVersion, @"sdk",
kSDK, @"sdk",
nil];

NSString *loginDialogURL = [kDialogBaseURL stringByAppendingString:kLogin];
Expand All @@ -146,8 +146,8 @@ - (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
[params setValue:scope forKey:@"scope"];
}

if (_localAppId) {
[params setValue:_localAppId forKey:@"local_client_id"];
if (_urlSchemeSuffix) {
[params setValue:_urlSchemeSuffix forKey:@"local_client_id"];
}

// If the device is running a version of iOS that supports multitasking,
Expand All @@ -162,7 +162,7 @@ - (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
if ([device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported]) {
if (tryFBAppAuth) {
NSString *scheme = kFBAppAuthURLScheme;
if (_localAppId) {
if (_urlSchemeSuffix) {
scheme = [scheme stringByAppendingString:@"2"];
}
NSString *urlPrefix = [NSString stringWithFormat:@"%@://%@", scheme, kFBAppAuthURLPath];
Expand Down Expand Up @@ -213,7 +213,7 @@ - (NSDictionary*)parseURLParams:(NSString *)query {

- (void)authorize:(NSArray *)permissions {
[self authorize:permissions
localAppId:nil];
urlSchemeSuffix:nil];
}

/**
Expand Down Expand Up @@ -244,29 +244,29 @@ - (void)authorize:(NSArray *)permissions {
* @param delegate
* Callback interface for notifying the calling application when
* the user has logged in.
* @param localAppId
* localAppId is a string of lowercase letters that is
* @param urlSchemeSuffix
* 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 localAppId to
* 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
* localAppId values will allow the Facebook app to disambiguate
* 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.
* localAppId is supported on version 3.4.1 and above of the Facebook
* 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 localAppId parameter, the SDK will
* 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.
*/
- (void)authorize:(NSArray *)permissions
localAppId:(NSString *)localAppId {
self.localAppId = localAppId;
urlSchemeSuffix:(NSString *)urlSchemeSuffix {
self.urlSchemeSuffix = urlSchemeSuffix;
self.permissions = permissions;

[self authorizeWithFBAppAuth:YES safariAuth:YES];
Expand Down

0 comments on commit 22f88dc

Please sign in to comment.