From ce2838b15c550bef54f9c1e12ff0ddb418509450 Mon Sep 17 00:00:00 2001 From: Yariv Sadan Date: Thu, 29 Sep 2011 16:56:45 -0700 Subject: [PATCH] Move the URL scheme suffix parameter from authorize: to init: 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 --- .../DemoApp/DemoApp.xcodeproj/project.pbxproj | 11 +-- src/Facebook.h | 7 +- src/Facebook.m | 68 ++++++++++--------- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/sample/DemoApp/DemoApp.xcodeproj/project.pbxproj b/sample/DemoApp/DemoApp.xcodeproj/project.pbxproj index 375cc51527..cc3de0a693 100755 --- a/sample/DemoApp/DemoApp.xcodeproj/project.pbxproj +++ b/sample/DemoApp/DemoApp.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -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 = ( @@ -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 = ""; @@ -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 = ""; @@ -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"; }; @@ -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"; }; diff --git a/src/Facebook.h b/src/Facebook.h index 6a3c1b96ff..70e01346dd 100644 --- a/src/Facebook.h +++ b/src/Facebook.h @@ -45,10 +45,11 @@ - (id)initWithAppId:(NSString *)appId andDelegate:(id)delegate; -- (void)authorize:(NSArray *)permissions; +- (id)initWithAppId:(NSString *)appId + urlSchemeSuffix:(NSString *)urlSchemeSuffix + andDelegate:(id)delegate; -- (void)authorize:(NSArray *)permissions - urlSchemeSuffix:(NSString *)urlSchemeSuffix; +- (void)authorize:(NSArray *)permissions; - (BOOL)handleOpenURL:(NSURL *)url; diff --git a/src/Facebook.m b/src/Facebook.m index 77abcb5488..639d67716f 100644 --- a/src/Facebook.m +++ b/src/Facebook.m @@ -36,6 +36,7 @@ @interface Facebook () // private properties @property(nonatomic, retain) NSArray* permissions; +@property(nonatomic, copy) NSString* appId; @end @@ -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)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)delegate { + urlSchemeSuffix:(NSString *)urlSchemeSuffix + andDelegate:(id)delegate { + self = [super init]; if (self) { - [_appId release]; - _appId = [appId copy]; + self.appId = appId; self.sessionDelegate = delegate; + self.urlSchemeSuffix = urlSchemeSuffix; } return self; } @@ -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. @@ -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];