Skip to content

Commit

Permalink
Facebook iOS SDK 3.22
Browse files Browse the repository at this point in the history
  • Loading branch information
briantkelley committed Jan 6, 2015
2 parents e4d6923 + fa472dc commit ed9b79c
Show file tree
Hide file tree
Showing 64 changed files with 1,426 additions and 518 deletions.
8 changes: 4 additions & 4 deletions Facebook-iOS-SDK.podspec
Expand Up @@ -6,7 +6,7 @@
Pod::Spec.new do |s|

s.name = "Facebook-iOS-SDK"
s.version = "3.21.1"
s.version = "3.22.0"
s.summary = "Official Facebook SDK for iOS to access Facebook Platform with features like Login, Share and Message Dialog, App Links, and Graph API"

s.description = <<-DESC
Expand All @@ -24,8 +24,8 @@ Pod::Spec.new do |s|
s.platform = :ios, "6.0"

s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git",
:tag => "sdk-version-3.21.1" ,
:submodules => true }
:tag => "sdk-version-3.22.0"
}

s.source_files = "src/**/*.{h,m}"
s.exclude_files = "src/**/*Tests.{h,m}", "src/tests/*.{h,m}", "src/*Test*/*.{h,m}"
Expand All @@ -39,7 +39,7 @@ Pod::Spec.new do |s|
s.requires_arc = false

# Note the prepare_command is not run against pods installed with the :path option (i.e., a local pod)
s.prepare_command = "find src -name \\*.png | grep -v @ | grep -v '/tests/' | grep -v 'Tests/' | grep -v -- - | sed -e 's|\\(.*\\)/\\([a-zA-Z0-9]*\\).png|scripts/image_to_code.py -i \\1/\\2.png -c \\2 -o src|' | sh && find src -name \\*.wav | grep -v @ | grep -v -- - | sed -e 's|\\(.*\\)/\\([a-zA-Z0-9]*\\).wav|scripts/audio_to_code.py -i \\1/\\2.wav -c \\2 -o src|' | sh"
s.prepare_command = "find src -name \\*.png | grep -v @ | grep -v '/tests/' | grep -v 'Tests/' | grep -v -- - | sed -e 's|\\(.*\\)/\\([a-zA-Z0-9]*\\).png|scripts/image_to_code.py -i \\1/\\2.png -c \\2 -o src/ImageResources|' | sh && find src -name \\*.wav | grep -v @ | grep -v -- - | sed -e 's|\\(.*\\)/\\([a-zA-Z0-9]*\\).wav|scripts/audio_to_code.py -i \\1/\\2.wav -c \\2 -o src/AudioResources|' | sh"

s.dependency 'Bolts', '~> 1.0'

Expand Down
2 changes: 1 addition & 1 deletion scripts/image_to_code.py
Expand Up @@ -20,7 +20,7 @@
*/
/*
* This is is a generated file during the SDK build process.
* This file is generated during the SDK build process.
* Please do not hand edit this file.
* It can be rebuilt by running
*
Expand Down
2 changes: 1 addition & 1 deletion scripts/package/productbuild_distribution.xml
Expand Up @@ -12,7 +12,7 @@
<pkg-ref id="com.facebook.sdk.pkg"/>
</choice>

<title>Facebook SDK 3.21.1 for iOS</title>
<title>Facebook SDK 3.22.0 for iOS</title>
<conclusion file="README.txt" mime-type="text/plain" />
<readme file="README.txt" mime-type="text/plain" />
<domains enable_currentUserHome="true" />
Expand Down
6 changes: 6 additions & 0 deletions src/Core/FBDynamicFrameworkLoader.h
Expand Up @@ -20,6 +20,7 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <Security/Security.h>
#import <StoreKit/StoreKit.h>

#import "FBSDKMacros.h"

Expand Down Expand Up @@ -216,3 +217,8 @@ NSString *fbdfl_ACFacebookPermissionsKey(void);
#pragma mark Accounts Classes

Class fbdfl_ACAccountStoreClass(void);

#pragma mark StoreKit classes

Class fbdfl_SKPaymentQueueClass(void);
Class fbdfl_SKProductsRequestClass(void);
17 changes: 17 additions & 0 deletions src/Core/FBDynamicFrameworkLoader.m
Expand Up @@ -429,3 +429,20 @@ Class fbdfl_ACAccountStoreClass(void) {
_fbdfl_Accounts_get_c(ACAccountStore);
return c;
}

#pragma mark StoreKit Classes

_fbdfl_load_framework_once_impl_(StoreKit)
_fbdfl_handle_get_impl_(StoreKit)

#define _fbdfl_StoreKit_get_c(SYMBOL) _fbdfl_symbol_get_c(StoreKit, SYMBOL);

Class fbdfl_SKPaymentQueueClass(void) {
_fbdfl_StoreKit_get_c(SKPaymentQueue);
return c;
}

Class fbdfl_SKProductsRequestClass(void) {
_fbdfl_StoreKit_get_c(SKProductsRequest);
return c;
}
5 changes: 3 additions & 2 deletions src/Core/FBFetchedAppSettings.h
Expand Up @@ -17,7 +17,8 @@

typedef NS_OPTIONS(NSUInteger, FBAppEventsFeatureOptions) {
FBAppEventsFeatureOptionsNone = 0,
FBAppEventsFeatureOptionsShouldAccessAdvertisingID = 1 << 0
FBAppEventsFeatureOptionsShouldAccessAdvertisingID = 1 << 0,
FBAppEventsFeatureOptionsLogImplicitPurchaseEvents = 1 << 1,
};

// Internal class holding server side Facebook app settings we fetch once from the
Expand All @@ -26,7 +27,6 @@ typedef NS_OPTIONS(NSUInteger, FBAppEventsFeatureOptions) {
@interface FBFetchedAppSettings : NSObject

@property (copy, nonatomic) NSString *serverAppName;
@property (readwrite) BOOL supportsAttribution;
@property (readwrite) BOOL supportsImplicitSdkLogging;
@property (readwrite) BOOL enableLoginTooltip;
@property (readonly, nonatomic) NSString *appID;
Expand All @@ -37,5 +37,6 @@ typedef NS_OPTIONS(NSUInteger, FBAppEventsFeatureOptions) {
appEventsFeatureOptions:(FBAppEventsFeatureOptions)appEventsFeatureOptions;

- (BOOL)shouldAccessAdvertisingID;
- (BOOL)doesAppLogImplicitPurchaseEvents;

@end
4 changes: 4 additions & 0 deletions src/Core/FBFetchedAppSettings.m
Expand Up @@ -56,4 +56,8 @@ - (BOOL)shouldAccessAdvertisingID {
return (self.appEventsFeatureOptions & FBAppEventsFeatureOptionsShouldAccessAdvertisingID) == FBAppEventsFeatureOptionsShouldAccessAdvertisingID;
}

- (BOOL)doesAppLogImplicitPurchaseEvents {
return (self.appEventsFeatureOptions & FBAppEventsFeatureOptionsLogImplicitPurchaseEvents) == FBAppEventsFeatureOptionsLogImplicitPurchaseEvents;
}

@end
2 changes: 0 additions & 2 deletions src/Core/FBSettings+Internal.h
Expand Up @@ -21,8 +21,6 @@ FBSDK_EXTERN NSString *const FBPLISTUrlSchemeSuffixKey;

@interface FBSettings (Internal)

+ (void)autoPublishInstall:(NSString *)appID;

/*!
@method
Expand Down
63 changes: 9 additions & 54 deletions src/Core/FBSettings.m
Expand Up @@ -62,7 +62,6 @@
@implementation FBSettings

static NSSet *g_loggingBehavior;
static BOOL g_autoPublishInstall = YES;
static dispatch_once_t g_publishInstallOnceToken;
static NSString *g_appVersion;
static NSUInteger g_betaFeatures = 0;
Expand Down Expand Up @@ -279,33 +278,10 @@ + (void)setRestrictedTreatment:(FBRestrictedTreatment)treatment {
}
}

+ (BOOL)shouldAutoPublishInstall {
return g_autoPublishInstall;
}

+ (void)setShouldAutoPublishInstall:(BOOL)newValue {
g_autoPublishInstall = newValue;
}

+ (NSString *)defaultURLSchemeWithAppID:(NSString *)appID urlSchemeSuffix:(NSString *)urlSchemeSuffix {
return [NSString stringWithFormat:@"fb%@%@", appID ?: [self defaultAppID], urlSchemeSuffix ?: [self defaultUrlSchemeSuffix] ?: @""];
}

+ (void)autoPublishInstall:(NSString *)appID {
if ([FBSettings shouldAutoPublishInstall]) {
dispatch_once(&g_publishInstallOnceToken, ^{
// dispatch_once is great, but not re-entrant. Inside publishInstall we use FBRequest, which will
// cause this function to get invoked a second time. By scheduling the work, we can sidestep the problem.
[[FBSettings class] performSelector:@selector(autoPublishInstallImpl:) withObject:appID afterDelay:FBPublishDelay];
});
}
}

+ (void)autoPublishInstallImpl:(NSString *)appID {
[FBSettings publishInstall:appID isAutoPublish:YES];
}


+ (void)enableBetaFeatures:(NSUInteger)betaFeatures {
g_betaFeatures |= betaFeatures;
}
Expand Down Expand Up @@ -343,11 +319,6 @@ + (void)setLimitEventAndDataUsage:(BOOL)limitEventAndDataUsage {
#pragma mark proto-activity publishing code

+ (void)publishInstall:(NSString *)appID {
[FBSettings publishInstall:appID isAutoPublish:NO];
}

+ (void)publishInstall:(NSString *)appID
isAutoPublish:(BOOL)isAutoPublish {
@try {
if (!appID) {
appID = [FBSettings defaultAppID];
Expand All @@ -358,12 +329,6 @@ + (void)publishInstall:(NSString *)appID
return;
}

// We turn off auto-publish, since this was manually called and the expectation
// is that it's only ever necessary to call this once.
if (!isAutoPublish) {
[FBSettings setShouldAutoPublishInstall:NO];
}

// look for a previous ping & grab the facebook app's current attribution id.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *pingKey = [NSString stringWithFormat:FBLastAttributionPing, appID, nil];
Expand Down Expand Up @@ -399,25 +364,15 @@ + (void)publishInstall:(NSString *)appID
callback:^(FBFetchedAppSettings *settings, NSError *error) {
if (!error) {
@try {
if (settings.supportsAttribution) {
// set up the HTTP POST to publish the attribution ID.
NSMutableDictionary<FBGraphObject> *installActivity =
[FBUtility activityParametersDictionaryForEvent:FBMobileInstallEvent
includeAttributionID:YES
implicitEventsOnly:NO
shouldAccessAdvertisingID:settings.shouldAccessAdvertisingID];

[installActivity setObject:[NSNumber numberWithBool:isAutoPublish].stringValue forKey:@"auto_publish"];

NSString *publishPath = [NSString stringWithFormat:FBPublishActivityPath, appID, nil];
FBRequest *publishRequest = [[[FBRequest alloc] initForPostWithSession:nil graphPath:publishPath graphObject:installActivity] autorelease];
[publishRequest startWithCompletionHandler:publishCompletionBlock];
} else {
// the app has turned off install insights. prevent future attempts.
[defaults setObject:[NSDate date] forKey:pingKey];
[defaults setObject:nil forKey:responseKey];
[defaults synchronize];
}
// set up the HTTP POST to publish the attribution ID.
NSMutableDictionary<FBGraphObject> *installActivity =
[FBUtility activityParametersDictionaryForEvent:FBMobileInstallEvent
implicitEventsOnly:NO
shouldAccessAdvertisingID:settings.shouldAccessAdvertisingID];

NSString *publishPath = [NSString stringWithFormat:FBPublishActivityPath, appID, nil];
FBRequest *publishRequest = [[[FBRequest alloc] initForPostWithSession:nil graphPath:publishPath graphObject:installActivity] autorelease];
[publishRequest startWithCompletionHandler:publishCompletionBlock];
} @catch (NSException *ex2) {
NSString *errorMessage = [NSString stringWithFormat:@"Failure during install publish: %@", ex2.reason];
[FBLogger singleShotLogEntry:FBLoggingBehaviorInformational logEntry:errorMessage];
Expand Down
4 changes: 2 additions & 2 deletions src/Core/FBUtility.h
Expand Up @@ -104,10 +104,10 @@ FBSDK_EXTERN BOOL FBCheckObjectIsEqual(NSObject *a, NSObject *b);

+ (NSString *)newUUIDString;
+ (NSString *)attributionID;
+ (NSString *)advertiserOrAnonymousID:(BOOL)accessAdvertisingID;
+ (NSString *)advertiserID;
+ (NSString *)anonymousID;
+ (FBAdvertisingTrackingStatus)advertisingTrackingStatus;
+ (NSMutableDictionary<FBGraphObject> *)activityParametersDictionaryForEvent:(NSString *)eventCategory
includeAttributionID:(BOOL)includeAttributionID
implicitEventsOnly:(BOOL)implicitEventsOnly
shouldAccessAdvertisingID:(BOOL)shouldAccessAdvertisingID;

Expand Down
88 changes: 38 additions & 50 deletions src/Core/FBUtility.m
Expand Up @@ -37,7 +37,6 @@
static NSDate *g_fetchedAppSettingsTimestamp = nil;

static const NSString *kAppSettingsFieldAppName = @"name";
static const NSString *kAppSettingsFieldSupportsAttribution = @"supports_attribution";
static const NSString *kAppSettingsFieldSupportsImplicitLogging = @"supports_implicit_sdk_logging";
static const NSString *kAppSettingsFieldEnableLoginTooltip = @"gdpv4_nux_enabled";
static const NSString *kAppSettingsFieldLoginTooltipContent = @"gdpv4_nux_content";
Expand Down Expand Up @@ -230,7 +229,6 @@ + (void)fetchAppSettings:(NSString *)appID
NSString *pingPath = [NSString stringWithFormat:@"%@?fields=%@",
appID,
[@[kAppSettingsFieldAppName,
kAppSettingsFieldSupportsAttribution,
kAppSettingsFieldSupportsImplicitLogging,
kAppSettingsFieldEnableLoginTooltip,
kAppSettingsFieldLoginTooltipContent,
Expand Down Expand Up @@ -266,7 +264,6 @@ + (void)fetchAppSettings:(NSString *)appID
g_fetchedAppSettingsTimestamp = [[NSDate date] retain];

g_fetchedAppSettings.serverAppName = result[kAppSettingsFieldAppName];
g_fetchedAppSettings.supportsAttribution = [result[kAppSettingsFieldSupportsAttribution] boolValue];
g_fetchedAppSettings.supportsImplicitSdkLogging = [result[kAppSettingsFieldSupportsImplicitLogging] boolValue];
g_fetchedAppSettings.enableLoginTooltip = [result[kAppSettingsFieldEnableLoginTooltip] boolValue];
g_fetchedAppSettings.loginTooltipContent = result[kAppSettingsFieldLoginTooltipContent];
Expand Down Expand Up @@ -337,43 +334,43 @@ + (NSString *)attributionID {
return [[UIPasteboard pasteboardWithName:@"fb_app_attribution" create:NO] string];
}

+ (NSString *)advertiserOrAnonymousID:(BOOL)accessAdvertisingID {
+ (NSString *)advertiserID {

NSString *result = nil;

// Only access the IDFA (advertisingIdentifier) if the app advertises.
if (accessAdvertisingID) {
Class ASIdentifierManagerClass = fbdfl_ASIdentifierManagerClass();
if ([ASIdentifierManagerClass class]) {
ASIdentifierManager *manager = [ASIdentifierManagerClass sharedManager];
result = [[manager advertisingIdentifier] UUIDString];
}
Class ASIdentifierManagerClass = fbdfl_ASIdentifierManagerClass();
if ([ASIdentifierManagerClass class]) {
ASIdentifierManager *manager = [ASIdentifierManagerClass sharedManager];
result = [[manager advertisingIdentifier] UUIDString];
}

return result;
}

+ (NSString *)anonymousID {

// Grab previously written anonymous ID and, if none have been generated, create and
// persist a new one which will remain associated with this app.
NSString *result = [self retrievePersistedAnonymousID];
if (!result) {

// Grab previously written anonymous ID and, if none have been generted, create and
// persist a new one which will remain associated with this app.
result = [self retrievePersistedAnonymousID];
if (!result) {

// Generate a new anonymous ID. Create as a UUID, but then prepend the fairly
// arbitrary 'XZ' to the front so it's easily distinguishable from IDFA's which
// will only contain hex.
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = (NSString *) CFUUIDCreateString(NULL, uuid);

result = [NSString stringWithFormat:@"XZ%@", uuidString];

[self persistAnonymousID:result];
CFRelease(uuid);
[uuidString release];
}
// Generate a new anonymous ID. Create as a UUID, but then prepend the fairly
// arbitrary 'XZ' to the front so it's easily distinguishable from IDFA's which
// will only contain hex.
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *uuidString = (NSString *) CFUUIDCreateString(NULL, uuid);

result = [NSString stringWithFormat:@"XZ%@", uuidString];

[self persistAnonymousID:result];
CFRelease(uuid);
[uuidString release];
}

return result;
}


+ (void)persistAnonymousID:(NSString *)anonymousID {

[FBAppEvents ensureOnMainThread];
Expand Down Expand Up @@ -421,35 +418,25 @@ + (FBAdvertisingTrackingStatus)advertisingTrackingStatus {
}

+ (NSMutableDictionary<FBGraphObject> *)activityParametersDictionaryForEvent:(NSString *)eventCategory
includeAttributionID:(BOOL)includeAttributionID
implicitEventsOnly:(BOOL)implicitEventsOnly
shouldAccessAdvertisingID:(BOOL)shouldAccessAdvertisingID {

NSMutableDictionary<FBGraphObject> *parameters = [FBGraphObject graphObject];
[parameters setObject:eventCategory forKey:@"event"];

NSString *attributionID = nil;
if (includeAttributionID) {
attributionID = [FBUtility attributionID]; // Only present on iOS 6 and below.
if (attributionID) {
[parameters setObject:attributionID forKey:@"attribution"];
}
NSString *attributionID = [FBUtility attributionID]; // Only present on iOS 6 and below.
if (attributionID) {
[parameters setObject:attributionID forKey:@"attribution"];
}

BOOL canGetAdvertisingID = !implicitEventsOnly && shouldAccessAdvertisingID;
if (!(attributionID && !canGetAdvertisingID)) {
NSString *advertiserOrAnonymousID = [FBUtility advertiserOrAnonymousID:canGetAdvertisingID];
if (advertiserOrAnonymousID) {
[parameters setObject:advertiserOrAnonymousID forKey:@"advertiser_id"];
}
}

if (canGetAdvertisingID) {
NSString *oldAnonymousID = [self retrievePersistedAnonymousID];
if (oldAnonymousID) {
[parameters setObject:oldAnonymousID forKey:@"old_anon_id"];

if (!implicitEventsOnly && shouldAccessAdvertisingID) {
NSString *advertiserID = [FBUtility advertiserID];
if (advertiserID) {
[parameters setObject:advertiserID forKey:@"advertiser_id"];
}
}

[parameters setObject:[self anonymousID] forKey:@"anon_id"];

FBAdvertisingTrackingStatus advertisingTrackingStatus = [self advertisingTrackingStatus];
if (advertisingTrackingStatus != AdvertisingTrackingUnspecified) {
Expand Down Expand Up @@ -575,9 +562,10 @@ + (NSDictionary *)dictionaryByParsingURLQueryPart:(NSString *)encodedString {
value = [part substringFromIndex:index.location + index.length];
}

key = [self stringByURLDecodingString:key];
value = [self stringByURLDecodingString:value];
if (key && value) {
[result setObject:[self stringByURLDecodingString:value]
forKey:[self stringByURLDecodingString:key]];
result[key] = value;
}
}
return result;
Expand Down

0 comments on commit ed9b79c

Please sign in to comment.