Skip to content

Commit

Permalink
Move the URL scheme suffix parameter from authorize: to init:
Browse files Browse the repository at this point in the history
Summary: Moving the url scheme suffix parameter from authorize: to init:, where
it fits better, as it behaves in a similar way to appId.

Test Plan: Modified the demo app to use the new method signatures. Verified SSO
still worked with and without a url scheme suffix.

Reviewers: lshepard, brent, caabernathy, teck

Reviewed By: brent

CC: brent

Differential Revision: 335813
  • Loading branch information
Yariv Sadan committed Oct 10, 2011
1 parent 22f88dc commit ce2838b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 38 deletions.
11 changes: 7 additions & 4 deletions sample/DemoApp/DemoApp.xcodeproj/project.pbxproj
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -214,8 +214,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0410;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "DemoApp" */;
compatibilityVersion = "Xcode 3.1";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
Expand Down Expand Up @@ -283,6 +286,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = DemoApp_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "DemoApp-Info.plist";
PRODUCT_NAME = DemoApp;
PROVISIONING_PROFILE = "";
Expand All @@ -302,6 +306,7 @@
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = DemoApp_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvmgcc42;
INFOPLIST_FILE = "DemoApp-Info.plist";
PRODUCT_NAME = DemoApp;
PROVISIONING_PROFILE = "";
Expand All @@ -324,7 +329,6 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
ONLY_ACTIVE_ARCH = NO;
PREBINDING = NO;
SDKROOT = iphoneos;
VALID_ARCHS = "armv7 armv6";
};
Expand All @@ -342,7 +346,6 @@
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PREBINDING = NO;
SDKROOT = iphoneos;
VALID_ARCHS = "armv7 armv6";
};
Expand Down
7 changes: 4 additions & 3 deletions src/Facebook.h
Expand Up @@ -45,10 +45,11 @@
- (id)initWithAppId:(NSString *)appId
andDelegate:(id<FBSessionDelegate>)delegate;

- (void)authorize:(NSArray *)permissions;
- (id)initWithAppId:(NSString *)appId
urlSchemeSuffix:(NSString *)urlSchemeSuffix
andDelegate:(id<FBSessionDelegate>)delegate;

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

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

Expand Down
68 changes: 37 additions & 31 deletions src/Facebook.m
Expand Up @@ -36,6 +36,7 @@ @interface Facebook ()

// private properties
@property(nonatomic, retain) NSArray* permissions;
@property(nonatomic, copy) NSString* appId;

@end

Expand All @@ -47,23 +48,54 @@ @implementation Facebook
expirationDate = _expirationDate,
sessionDelegate = _sessionDelegate,
permissions = _permissions,
urlSchemeSuffix = _urlSchemeSuffix;
urlSchemeSuffix = _urlSchemeSuffix,
appId = _appId;


///////////////////////////////////////////////////////////////////////////////////////////////////
// private


- (id)initWithAppId:(NSString *)appId
andDelegate:(id<FBSessionDelegate>)delegate {
self = [self initWithAppId:appId urlSchemeSuffix:nil andDelegate:delegate];
return self;
}

/**
* Initialize the Facebook object with application ID.
*
* @param appId the facebook app id
* @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 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.
* @param delegate the FBSessionDelegate
*/
- (id)initWithAppId:(NSString *)appId
andDelegate:(id<FBSessionDelegate>)delegate {
urlSchemeSuffix:(NSString *)urlSchemeSuffix
andDelegate:(id<FBSessionDelegate>)delegate {

self = [super init];
if (self) {
[_appId release];
_appId = [appId copy];
self.appId = appId;
self.sessionDelegate = delegate;
self.urlSchemeSuffix = urlSchemeSuffix;
}
return self;
}
Expand Down Expand Up @@ -211,11 +243,6 @@ - (NSDictionary*)parseURLParams:(NSString *)query {
///////////////////////////////////////////////////////////////////////////////////////////////////
//public

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

/**
* Starts a dialog which prompts the user to log in to Facebook and grant
* the requested permissions to the application.
Expand Down Expand Up @@ -244,29 +271,8 @@ - (void)authorize:(NSArray *)permissions {
* @param delegate
* Callback interface for notifying the calling application when
* the user has logged in.
* @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 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.
*/
- (void)authorize:(NSArray *)permissions
urlSchemeSuffix:(NSString *)urlSchemeSuffix {
self.urlSchemeSuffix = urlSchemeSuffix;
- (void)authorize:(NSArray *)permissions {
self.permissions = permissions;

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

0 comments on commit ce2838b

Please sign in to comment.