Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Facebook iOS SDK 3.5.2

Summary:
     Bug fixes. See https://developers.facebook.com/ios/change-log-3.x/

Reviewed By: jacl

Test Plan: Release Testing.
  • Loading branch information...
commit 56b40a4e75a5ab30cfbfb4197c69f092470b32f2 1 parent 06effac
@chrisp-fb chrisp-fb authored
View
14 samples/RPSSample/post_app_objects.sh
@@ -15,7 +15,7 @@
# limitations under the License.
#
-# Note: Use of this script requires GNU grep rather than BSD grep
+# Note: Use of this script requires Perl
#
# step 1 - confirm we have an app id and app secret to work with
@@ -41,15 +41,15 @@ echo curling...
ROCK_IMAGE_URI=` \
curl -s -k -X POST https://graph.facebook.com/$APPID/staging_resources -F access_token="$APPID|$APPSECRET" -F 'file=@RPSSample/left-rock-128.png;type=image/png' \
- | grep -Po '(?<="uri":").*(?=")' `
+ | perl -ne '/"uri":"(.*)"}/ && print $1' `
PAPER_IMAGE_URI=` \
curl -s -k -X POST https://graph.facebook.com/$APPID/staging_resources -F access_token="$APPID|$APPSECRET" -F 'file=@RPSSample/left-paper-128.png;type=image/png' \
- | grep -Po '(?<="uri":").*(?=")' `
+ | perl -ne '/"uri":"(.*)"}/ && print $1' `
SCISSORS_IMAGE_URI=` \
curl -s -k -X POST https://graph.facebook.com/$APPID/staging_resources -F access_token="$APPID|$APPSECRET" -F 'file=@RPSSample/left-scissors-128.png;type=image/png' \
- | grep -Po '(?<="uri":").*(?=")' `
+ | perl -ne '/"uri":"(.*)"}/ && print $1' `
echo "created staged resources..."
echo " rock=$ROCK_IMAGE_URI"
@@ -63,17 +63,17 @@ echo " scissors=$SCISSORS_IMAGE_URI"
# rock
ROCK_OBJID=` \
curl -s -X POST -F "object={\"title\":\"Rock\",\"description\":\"Breaks scissors, alas is covered by paper.\",\"image\":\"$ROCK_IMAGE_URI\"}" "https://graph.facebook.com/$APPID/objects/fb_sample_rps:gesture?access_token=$APPID|$APPSECRET" \
- | grep -Po '(?<="id":").*(?=")'`
+ | perl -ne '/"id":"(.*)"}/ && print $1' `
# paper
PAPER_OBJID=` \
curl -s -X POST -F "object={\"title\":\"Paper\",\"description\":\"Covers rock, sadly scissors cut it.\",\"image\":\"$PAPER_IMAGE_URI\"}" "https://graph.facebook.com/$APPID/objects/fb_sample_rps:gesture?access_token=$APPID|$APPSECRET" \
- | grep -Po '(?<="id":").*(?=")'`
+ | perl -ne '/"id":"(.*)"}/ && print $1' `
# scissors
SCISSORS_OBJID=` \
curl -s -X POST -F "object={\"title\":\"Scissors\",\"description\":\"Cuts paper, broken by rock -- bother.\",\"image\":\"$SCISSORS_IMAGE_URI\"}" "https://graph.facebook.com/$APPID/objects/fb_sample_rps:gesture?access_token=$APPID|$APPSECRET" \
- | grep -Po '(?<="id":").*(?=")'`
+ | perl -ne '/"id":"(.*)"}/ && print $1' `
#
# step 4 - echo progress
View
2  scripts/build_distribution.sh
@@ -96,7 +96,7 @@ $PACKAGEMAKER \
--target 10.5 \
--version $FB_SDK_VERSION \
--out $FB_SDK_PKG \
- --title 'Facebook SDK 3.5.1 for iOS' \
+ --title 'Facebook SDK 3.5.2 for iOS' \
|| die "PackageMaker reported error"
if [ ! "$CODE_SIGN_IDENTITY" ]; then
View
2  scripts/build_documentation.sh
@@ -45,7 +45,7 @@ rm -rf $DOCSET
hash $APPLEDOC &>/dev/null
if [ "$?" -eq "0" ]; then
- APPLEDOC_DOCSET_NAME="Facebook SDK 3.5.1 for iOS"
+ APPLEDOC_DOCSET_NAME="Facebook SDK 3.5.2 for iOS"
$APPLEDOC --project-name "$APPLEDOC_DOCSET_NAME" \
--project-company "Facebook" \
--company-id "com.facebook" \
View
35 src/FBAppBridgeTypeToJSONConverter.m
@@ -16,7 +16,9 @@
#import <UIKit/UIKit.h>
#import "FBBase64.h"
+#import "FBError.h"
#import "FBAppBridgeTypeToJSONConverter.h"
+#import "FBSettings+Internal.h"
/*
jsonReadyValue: A representation of the extended type that is safe for JSON serialization.
@@ -93,7 +95,7 @@ - (id)convertedObjectFromObject:(id)object convertingToJSON:(BOOL)convertingToJS
tag:FBAppBridgeTypesTags.data];
} else if ([object isKindOfClass:[UIImage class]]) {
UIImage *image = (UIImage *)object;
- return [self jsonFromData:UIImagePNGRepresentation(image)
+ return [self jsonFromData:UIImageJPEGRepresentation(image, [FBSettings defaultJPEGCompressionQuality])
tag:FBAppBridgeTypesTags.png];
}
}
@@ -144,23 +146,30 @@ - (NSMutableDictionary *)jsonFromData:(NSData *)data tag:(NSString *)tag {
NSMutableDictionary *json = [NSMutableDictionary dictionary];
NSString *jsonReadyValue = nil;
- // If the data is short enough, put it in the URL directly. Otherwise use UIPasteboard
- if (data.length <= PasteboardThreshold) {
+ // If the data is large, put it in a UIPasteboard
+ if (data.length > PasteboardThreshold) {
+ NSString *uniqueSuffix = [[FBUtility newUUIDString] autorelease];
+ NSString *pasteboardName = [FacebookSDKDomain stringByAppendingString:uniqueSuffix];
+ UIPasteboard *board = [UIPasteboard pasteboardWithName:pasteboardName create:YES];
+ if (board) {
+ [board setPersistent:YES];
+ [board setData:data forPasteboardType:FBAppBridgeTypeIdentifier];
+
+ jsonReadyValue = board.name;
+ [self.createdPasteboardNames addObject:board.name];
+
+ json[FBAppBridgeTypesMetadata.isPasteboard] = [NSNumber numberWithBool:YES];
+ }
+ }
+
+ // If a UIPasteboard was not (or could not be) used, put the data directly in the URL.
+ if (!jsonReadyValue) {
jsonReadyValue = FBEncodeBase64(data);
json[FBAppBridgeTypesMetadata.isBase64] = [NSNumber numberWithBool:YES];
- } else {
- UIPasteboard *board = [UIPasteboard pasteboardWithUniqueName];
- [board setPersistent:YES];
- [board setData:data forPasteboardType:FBAppBridgeTypeIdentifier];
-
- jsonReadyValue = board.name;
- [self.createdPasteboardNames addObject:board.name];
-
- json[FBAppBridgeTypesMetadata.isPasteboard] = [NSNumber numberWithBool:YES];
}
json[FBAppBridgeTypesMetadata.tag] = tag ?: @"";
- json[FBAppBridgeTypesMetadata.jsonReadyValue] = jsonReadyValue;
+ json[FBAppBridgeTypesMetadata.jsonReadyValue] = jsonReadyValue ?: @"";
return json;
}
View
53 src/FBDialog.m
@@ -637,25 +637,39 @@ - (void)show {
}
- (void)dismissWithSuccess:(BOOL)success animated:(BOOL)animated {
- if (success) {
- if ([_delegate respondsToSelector:@selector(dialogDidComplete:)]) {
- [_delegate dialogDidComplete:self];
- }
- } else {
- if ([_delegate respondsToSelector:@selector(dialogDidNotComplete:)]) {
- [_delegate dialogDidNotComplete:self];
+ // retain self for the life of this method, in case we are released by a client
+ id me = [self retain];
+
+ @try {
+ if (success) {
+ if ([_delegate respondsToSelector:@selector(dialogDidComplete:)]) {
+ [_delegate dialogDidComplete:self];
+ }
+ } else {
+ if ([_delegate respondsToSelector:@selector(dialogDidNotComplete:)]) {
+ [_delegate dialogDidNotComplete:self];
+ }
}
+
+ [self dismiss:animated];
+ } @finally {
+ [me release];
}
-
- [self dismiss:animated];
}
- (void)dismissWithError:(NSError*)error animated:(BOOL)animated {
- if ([_delegate respondsToSelector:@selector(dialog:didFailWithError:)]) {
- [_delegate dialog:self didFailWithError:error];
- }
+ // retain self for the life of this method, in case we are released by a client
+ id me = [self retain];
- [self dismiss:animated];
+ @try {
+ if ([_delegate respondsToSelector:@selector(dialog:didFailWithError:)]) {
+ [_delegate dialog:self didFailWithError:error];
+ }
+
+ [self dismiss:animated];
+ } @finally {
+ [me release];
+ }
}
- (void)dialogWillAppear {
@@ -681,10 +695,17 @@ - (void)dialogDidSucceed:(NSURL *)url {
}
- (void)dialogDidCancel:(NSURL *)url {
- if ([_delegate respondsToSelector:@selector(dialogDidNotCompleteWithUrl:)]) {
- [_delegate dialogDidNotCompleteWithUrl:url];
+ // retain self for the life of this method, in case we are released by a client
+ id me = [self retain];
+
+ @try {
+ if ([_delegate respondsToSelector:@selector(dialogDidNotCompleteWithUrl:)]) {
+ [_delegate dialogDidNotCompleteWithUrl:url];
+ }
+ [self dismissWithSuccess:NO animated:YES];
+ } @finally {
+ [me release];
}
- [self dismissWithSuccess:NO animated:YES];
}
@end
View
4 src/FBDialogs.h
@@ -420,7 +420,7 @@ NSError *error);
handleOpenURL: method in FBAppCall.
@param action The Open Graph action to be published. May not be nil.
-
+
@param actionType the fully-specified Open Graph action type of the action (e.g.,
my_app_namespace:my_action).
@@ -458,7 +458,7 @@ NSError *error);
handleOpenURL: method in FBAppCall.
@param action The Open Graph action to be published. May not be nil.
-
+
@param actionType the fully-specified Open Graph action type of the action (e.g.,
my_app_namespace:my_action).
View
9 src/FBInsights.m
@@ -841,14 +841,7 @@ - (void)optionallyAppendAttributionAndAdvertiserIDs:(NSMutableDictionary *)postP
[postParameters setObject:advertiserID forKey:@"advertiser_id"];
}
- // Only send this query param if we have a definitive allowed/disallowed on advertising tracking. Otherwise,
- // absence of this parameter is to be interpreted as 'unspecified'.
- FBAdvertisingTrackingStatus advertisingTrackingStatus = [FBUtility advertisingTrackingStatus];
- if (advertisingTrackingStatus != AdvertisingTrackingUnspecified) {
- BOOL allowed = (advertisingTrackingStatus == AdvertisingTrackingAllowed);
- [postParameters setObject:[[NSNumber numberWithBool:allowed] stringValue]
- forKey:@"advertiser_tracking_enabled"];
- }
+ [FBUtility updateParametersWithAdvertisingTrackingStatus:postParameters];
}
- (BOOL)doesSessionHaveUserToken:(FBSession *)session {
View
3  src/FBLoginView.h
@@ -43,7 +43,8 @@
/*!
@abstract
- The read permissions to request if the user logs in via this view.
+ The read permissions to request if the user logs in via this view. The basic_info permission must be explicitly requested at
+ first login, and is no longer inferred, (subject to an active migration.)
@discussion
Note, that if read permissions are specified, then publish permissions should not be specified.
View
9 src/FBOpenGraphActionShareDialogParams.m
@@ -119,7 +119,14 @@ - (id)flattenGraphObjects:(id)dict {
NSMutableDictionary *flattened = [[[NSMutableDictionary alloc] initWithDictionary:dict] autorelease];
for (NSString *key in dict) {
id value = [dict objectForKey:key];
- [flattened setObject:[self flattenObject:value] forKey:key];
+ // Since flattenGraphObjects is only called for the OG action AND image is a special
+ // object with attributes that should NOT be flattened (e.g., "user_generated"),
+ // we should skip flattening the image dictionary.
+ if ([key isEqualToString:@"image"]) {
+ [flattened setObject:value forKey:key];
+ } else {
+ [flattened setObject:[self flattenObject:value] forKey:key];
+ }
}
return flattened;
}
View
2  src/FBRequest.m
@@ -337,7 +337,7 @@ + (FBRequest *)requestForUpdateOpenGraphObjectWithId:(id)objectId
image:image
url:url
description:description];
- object.id = [FBUtility stringFBIDFromObject:objectId];
+ object[@"id"] = [FBUtility stringFBIDFromObject:objectId];
return [FBRequest requestForUpdateOpenGraphObject:object];
}
View
5 src/FBRequestBody.m
@@ -15,6 +15,7 @@
*/
#import "FBRequestBody.h"
+#import "FBSettings+Internal.h"
static NSString *kStringBoundary = @"3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
@@ -83,8 +84,8 @@ - (void)appendWithKey:(NSString *)key
NSString *disposition =
[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", key, key];
[self appendUTF8:disposition];
- [self appendUTF8:@"Content-Type: image/png\r\n\r\n"];
- NSData *data = UIImagePNGRepresentation(image);
+ [self appendUTF8:@"Content-Type: image/jpeg\r\n\r\n"];
+ NSData *data = UIImageJPEGRepresentation(image, [FBSettings defaultJPEGCompressionQuality]);
[self.mutableData appendData:data];
[self appendRecordBoundary];
[logger appendFormat:@"\n %@:\t<Image - %d kB>", key, [data length] / 1024];
View
2  src/FBSDKVersion.h
@@ -1,2 +1,2 @@
-#define FB_IOS_SDK_VERSION_STRING @"3.5.1"
+#define FB_IOS_SDK_VERSION_STRING @"3.5.2"
#define FB_IOS_SDK_MIGRATION_BUNDLE @"fbsdk:20130409"
View
11 src/FBSession.h
@@ -246,7 +246,8 @@ typedef void (^FBSessionRenewSystemCredentialsHandler)(ACAccountCredentialRenewR
default values for parameters to <initWithAppID:permissions:urlSchemeSuffix:tokenCacheStrategy:>.
@param permissions An array of strings representing the permissions to request during the
- authentication flow. A value of nil indicates basic permissions. The default is nil.
+ authentication flow. The basic_info permission must be explicitly requested at first login, and is no
+ longer inferred, (subject to an active migration.) The default is nil.
@discussion
It is required that any single permission request request (including initial log in) represent read-only permissions
@@ -263,7 +264,7 @@ typedef void (^FBSessionRenewSystemCredentialsHandler)(ACAccountCredentialRenewR
defaults when ommitted.
@param permissions An array of strings representing the permissions to request during the
- authentication flow. A value of nil indicates basic permissions. The default is nil.
+ authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer inferred, (subject to an active migration.) The default is nil.
@param appID The Facebook App ID for the session. If nil is passed in the default App ID will be obtained from a call to <[FBSession defaultAppID]>. The default is nil.
@param urlSchemeSuffix The URL Scheme Suffix to be used in scenarious where multiple iOS apps use one Facebook App ID. A value of nil indicates that this information should be pulled from the plist. The default is nil.
@param tokenCachingStrategy Specifies a key name to use for cached token information in NSUserDefaults, nil
@@ -286,7 +287,7 @@ typedef void (^FBSessionRenewSystemCredentialsHandler)(ACAccountCredentialRenewR
defaults when ommitted.
@param permissions An array of strings representing the permissions to request during the
- authentication flow. A value of nil indicates basic permissions. The default is nil.
+ authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer inferred, (subject to an active migration.) The default is nil.
@param defaultAudience Most applications use FBSessionDefaultAudienceNone here, only specifying an audience when using reauthorize to request publish permissions.
@param appID The Facebook App ID for the session. If nil is passed in the default App ID will be obtained from a call to <[FBSession defaultAppID]>. The default is nil.
@param urlSchemeSuffix The URL Scheme Suffix to be used in scenarious where multiple iOS apps use one Facebook App ID. A value of nil indicates that this information should be pulled from the plist. The default is nil.
@@ -605,8 +606,8 @@ __attribute__((deprecated));
used by the application. This session becomes the active session, whether open succeeds or fails.
@param readPermissions An array of strings representing the read permissions to request during the
- authentication flow. A value of nil indicates basic permissions. It is not allowed to pass publish
- permissions to this method.
+ authentication flow. The basic_info permission must be explicitly requested at first login, and is no longer
+ inferred, (subject to an active migration.) It is not allowed to pass publish permissions to this method.
@param allowLoginUI Sometimes it is useful to attempt to open a session, but only if
no login UI will be required to accomplish the operation. For example, at application startup it may not
View
6 src/FBSession.m
@@ -898,6 +898,7 @@ - (void)authorizeWithPermissions:(NSArray*)permissions
if (tryFBAppAuth) {
FBFetchedAppSettings *fetchedSettings = [FBUtility fetchedAppSettings];
if ([FBSettings defaultDisplayName] && // don't autoselect Native Login unless the app has been setup for it,
+ [self.appID isEqualToString:[FBSettings defaultAppID]] && // If the appId has been overridden, then the bridge cannot be used and native login is denied
(fetchedSettings || canFetchAppSettings) && // and we have app-settings available to us, or could fetch if needed
!TEST_DISABLE_FACEBOOKNATIVELOGIN) {
if (!fetchedSettings) {
@@ -1147,9 +1148,8 @@ - (FBSystemAccountStoreAdapter *)getSystemAccountStoreAdapter {
}
- (BOOL)isMultitaskingSupported {
- UIDevice *device = [UIDevice currentDevice];
- return [device respondsToSelector:@selector(isMultitaskingSupported)] &&
- [device isMultitaskingSupported];
+ return [[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] &&
+ [[UIDevice currentDevice] isMultitaskingSupported];
}
- (BOOL)authorizeUsingFacebookNativeLoginWithPermissions:(NSArray*)permissions
View
18 src/FBSettings+Internal.h
@@ -28,4 +28,22 @@
*/
+ (NSString*)defaultURLScheme;
+/*!
+ @method
+
+ @abstract Set the default JPEG Compression Quality used for UIImage uploads. If not specified
+ we use a default value of 0.9
+
+ @param compressionQuality The default url scheme suffix to be used by the SDK.
+ */
++ (void)setdefaultJPEGCompressionQuality:(CGFloat)compressionQuality;
+
+/*!
+ @method
+
+ @abstract Get the default JPEG Compression Quality used for UIImage uploads. This value is the
+ compressionQuality value passed to UIImageJPEGRepresentation
+ */
++ (CGFloat)defaultJPEGCompressionQuality;
+
@end
View
1  src/FBSettings.h
@@ -15,6 +15,7 @@
*/
#import <Foundation/Foundation.h>
+#import <CoreGraphics/CGBase.h>
/*
* Constants defining logging behavior. Use with <[FBSettings setLoggingBehavior]>.
View
12 src/FBSettings.m
@@ -53,6 +53,7 @@ @implementation FBSettings
static NSString *g_defaultDisplayName = nil;
static NSString *g_defaultAppID = nil;
static NSString *g_defaultUrlSchemeSuffix = nil;
+static CGFloat g_defaultJPEGCompressionQuality = 0.9;
static NSUInteger g_betaFeatures = 0;
+ (NSSet *)loggingBehavior {
@@ -127,6 +128,14 @@ + (NSString*)defaultURLScheme {
return [NSString stringWithFormat:@"fb%@%@", [self defaultAppID], [self defaultUrlSchemeSuffix] ?: @""];
}
++ (void)setdefaultJPEGCompressionQuality:(CGFloat)compressionQuality {
+ g_defaultJPEGCompressionQuality = compressionQuality;
+}
+
++ (CGFloat)defaultJPEGCompressionQuality {
+ return g_defaultJPEGCompressionQuality;
+}
+
+ (BOOL)shouldAutoPublishInstall {
return g_autoPublishInstall;
}
@@ -204,7 +213,7 @@ + (void)publishInstall:(NSString *)appID
NSString *attributionID = [FBUtility attributionID];
NSString *advertiserID = [FBUtility advertiserID];
-
+
if (lastPing) {
// Short circuit
if (handler) {
@@ -264,6 +273,7 @@ + (void)publishInstall:(NSString *)appID
if (advertiserID) {
[installActivity setObject:advertiserID forKey:@"advertiser_id"];
}
+ [FBUtility updateParametersWithAdvertisingTrackingStatus:installActivity];
FBRequest *publishRequest = [[[FBRequest alloc] initForPostWithSession:nil graphPath:publishPath graphObject:installActivity] autorelease];
[publishRequest startWithCompletionHandler:publishCompletionBlock];
View
8 src/FBSystemAccountStoreAdapter.m
@@ -171,6 +171,14 @@ - (void)requestAccessToFacebookAccountStore:(NSArray *)permissions
//wrap the request call into a separate block to help with possibly block chaining below.
void(^requestAccessBlock)(void) = ^{
+ if (!self.accountTypeFB) {
+ if (handler) {
+ handler(nil, [session errorLoginFailedWithReason:FBErrorLoginFailedReasonSystemError
+ errorCode:nil
+ innerError:nil]);
+ }
+ return;
+ }
// we will attempt an iOS integrated facebook login
[self.accountStore
requestAccessToAccountsWithType:self.accountTypeFB
View
1  src/FBUtility.h
@@ -63,6 +63,7 @@ typedef enum FBAdvertisingTrackingStatus {
+ (NSString *)attributionID;
+ (NSString *)advertiserID;
+ (FBAdvertisingTrackingStatus)advertisingTrackingStatus;
++ (void)updateParametersWithAdvertisingTrackingStatus:(NSMutableDictionary *)parameters;
// Encode a data structure in JSON, any errors will just be logged.
+ (NSString *)simpleJSONEncode:(id)data;
View
24 src/FBUtility.m
@@ -318,6 +318,18 @@ + (FBAdvertisingTrackingStatus)advertisingTrackingStatus {
return status;
}
+// Only add this param if we have a definitive allowed/disallowed on advertising tracking. Otherwise,
+// absence of this parameter is to be interpreted as 'unspecified'.
++ (void)updateParametersWithAdvertisingTrackingStatus:(NSMutableDictionary *)parameters {
+
+ FBAdvertisingTrackingStatus advertisingTrackingStatus = [FBUtility advertisingTrackingStatus];
+ if (advertisingTrackingStatus != AdvertisingTrackingUnspecified) {
+ BOOL allowed = (advertisingTrackingStatus == AdvertisingTrackingAllowed);
+ [parameters setObject:[[NSNumber numberWithBool:allowed] stringValue]
+ forKey:@"advertiser_tracking_enabled"];
+ }
+}
+
+ (NSString *)simpleJSONEncode:(id)data {
return [FBUtility simpleJSONEncode:data
error:nil];
@@ -375,12 +387,18 @@ + (NSString *)newUUIDString {
+ (BOOL)isRegisteredURLScheme:(NSString *)urlScheme {
static dispatch_once_t fetchBundleOnce;
- static NSArray *urlSchemes = nil;
+ static NSArray *urlTypes = nil;
dispatch_once(&fetchBundleOnce, ^{
- urlSchemes = [[[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleURLTypes"] objectAtIndex:0] valueForKey:@"CFBundleURLSchemes"];
+ urlTypes = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleURLTypes"];
});
- return [urlSchemes containsObject:urlScheme];
+ for (NSDictionary *urlType in urlTypes) {
+ NSArray *urlSchemes = [urlType valueForKey:@"CFBundleURLSchemes"];
+ if ([urlSchemes containsObject:urlScheme]) {
+ return YES;
+ }
+ }
+ return NO;
}
@end
View
16 src/FBWebDialogs.m
@@ -26,6 +26,8 @@
#import "FBFrictionlessDialogSupportDelegate.h"
#import "FBFrictionlessRequestSettings.h"
#import "FBFrictionlessRecipientCache.h"
+#import "FBSettings.h"
+#import "FBLogger.h"
static NSString* dialogBaseURL = @"https://m." FB_BASE_URL "/dialog/";
@@ -73,6 +75,11 @@ - (void)dealloc {
[super dealloc];
}
+// The SDK 3.* and greater maintains compatibility with the 2.0 SDKs, in order to simplify migration
+// for customers moving to 3.*. Due to this, there are a few ugly bits where we have to hack to keep
+// the legacy code working, without letting its anti-patterns bleed into the newer (and hopefully
+// cleaner) 3.* API, and customer app. The self-retention madness in this class is an example of this.
+// So without further ado...
- (void)goRetainYourself {
if (!_isSelfRetained) {
[self retain];
@@ -192,6 +199,7 @@ + (void)presentDialogModallyWithSession:(FBSession *)session
[parametersImpl setObject:@"touch" forKey:@"display"];
[parametersImpl setObject:FB_IOS_SDK_VERSION_STRING forKey:@"sdk"];
[parametersImpl setObject:@"fbconnect://success" forKey:@"redirect_uri"];
+ [parametersImpl setObject:[FBSettings defaultAppID] ? : @"" forKey:@"app_id"];
// then roll in developer provided parameters
if (parameters) {
@@ -207,12 +215,18 @@ + (void)presentDialogModallyWithSession:(FBSession *)session
// caller must pass parameters to meet the requirements of the dialog
if (session) {
// set access_token and app_id
- [parametersImpl setValue:session.accessTokenData.accessToken ? : @""
+ [parametersImpl setObject:session.accessTokenData.accessToken ? : @""
forKey:@"access_token"];
[parametersImpl setObject:session.appID ? : @""
forKey:@"app_id"];
}
+ NSString *app_id = [parametersImpl objectForKey:@"app_id"];
+ if ([app_id length] == 0) {
+ [FBLogger singleShotLogEntry:FBLoggingBehaviorDeveloperErrors
+ logEntry:@"You must specify an app_id via an FBSession, the parameters, or the plist"];
+ }
+
BOOL isViewInvisible = NO;
FBFrictionlessRequestSettings *frictionlessSettings = nil;
View
14 src/tests/FBAuthenticationTests.m
@@ -20,6 +20,7 @@
#import "FBRequest.h"
#import "FBSessionTokenCachingStrategy.h"
#import "FBTestBlocker.h"
+#import "FBUtility.h"
NSString *const kAuthenticationTestValidToken = @"AToken";
NSString *const kAuthenticationTestAppId = @"AnAppid";
@@ -48,6 +49,10 @@ + (NSString *)serializeURL:(NSString *)baseUrl
@end
+@interface FBAuthenticationTests() {
+ id _mockFBUtility;
+}
+@end
@implementation FBAuthenticationTests
@@ -61,6 +66,12 @@ - (void)setUp {
FBSession.activeSession = nil;
_blocker = [[FBTestBlocker alloc] initWithExpectedSignalCount:1];
+
+ // Before every authentication test, set up a fake FBFetchedAppSettings
+ // to prevent fetching app settings during FBSession authorizeWithPermissions
+ _mockFBUtility = [[OCMockObject mockForClass:[FBUtility class]] retain];
+ FBFetchedAppSettings *dummyFBFetchedAppSettings = [[[FBFetchedAppSettings alloc] init] autorelease];
+ [[[_mockFBUtility stub] andReturn:dummyFBFetchedAppSettings] fetchedAppSettings];
}
- (void)tearDown {
@@ -68,6 +79,9 @@ - (void)tearDown {
[_blocker release];
_blocker = nil;
+
+ [_mockFBUtility release];
+ _mockFBUtility = nil;
}
- (void)mockSuccessRequestAccessToFacebookAccountStore:(NSArray *)permissions
View
3  src/tests/FBSessionTests.m
@@ -26,6 +26,7 @@
#import "FBAccessTokenData+Internal.h"
#import "FBError.h"
#import "FBUtility.h"
+#import "FBSettings.h"
#import <objc/objc-runtime.h>
static NSString *kURLSchemeSuffix = @"URLSuffix";
@@ -873,6 +874,8 @@ - (void)testHandleDidBecomeActiveDoesNothingInCreatedState {
[[(id)mockSession reject] close];
[[(id)mockSession reject] callReauthorizeHandlerAndClearState:[OCMArg any]];
+ [FBSettings setDefaultAppID:kTestAppId];
+
[session handleDidBecomeActive];
assertThatInt(session.state, equalToInt(FBSessionStateCreated));
Please sign in to comment.
Something went wrong with that request. Please try again.