Skip to content

Commit

Permalink
Facebook iOS SDK 4.20
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhuowen committed Mar 2, 2017
2 parents 0bbd6b5 + dc1e598 commit f257b9a
Show file tree
Hide file tree
Showing 60 changed files with 840 additions and 392 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test/UnitTest/UnitTest.xcodeproj/*.pbxuser
test/UnitTest/UnitTest.xcodeproj/*.mode*
test/UnitTest/build/
project.xcworkspace
ios-sdk.xcodeproj
xcuserdata
.arcbuildbootstrap
TestAppIdAndSecret.xcconfig
Expand Down
33 changes: 17 additions & 16 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
[submodule "vendor/OHHTTPStubs"]
path = vendor/OHHTTPStubs
url = https://github.com/AliSoftware/OHHTTPStubs.git
path = vendor/OHHTTPStubs
url = https://github.com/AliSoftware/OHHTTPStubs.git
[submodule "vendor/OCMock"]
path = vendor/OCMock
url = https://github.com/erikdoe/ocmock
path = vendor/OCMock
url = https://github.com/erikdoe/ocmock
[submodule "vendor/appledoc"]
path = vendor/appledoc
url = https://github.com/tomaz/appledoc.git
path = vendor/appledoc
url = https://github.com/tomaz/appledoc.git
[submodule "Bolts-IOS"]
path = Bolts-IOS
url = https://github.com/BoltsFramework/Bolts-iOS.git
path = Bolts-IOS
url = https://github.com/BoltsFramework/Bolts-iOS.git
[submodule "vendor/ios-snapshot-test-case"]
path = vendor/ios-snapshot-test-case
url = https://github.com/facebook/ios-snapshot-test-case.git
path = vendor/ios-snapshot-test-case
url = https://github.com/facebook/ios-snapshot-test-case.git
[submodule "vendor/xctool"]
path = vendor/xctool
url = https://github.com/facebook/xctool.git
path = vendor/xctool
url = https://github.com/facebook/xctool.git
[submodule "FBNotifications"]
path = FBNotifications
url = https://github.com/facebook/FBNotifications.git
path = FBNotifications
url = https://github.com/facebook/FBNotifications.git
[submodule "vendor/FBTweak"]
path = vendor/FBTweak
url = https://github.com/facebook/Tweaks.git
path = vendor/FBTweak
url = https://github.com/facebook/Tweaks.git

2 changes: 1 addition & 1 deletion Configurations/Version.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// The versions for FBSDK and Messenger SDK.
FBSDK_PROJECT_VERSION=4.19.0
FBSDK_PROJECT_VERSION=4.20.0
MNSDK_PROJECT_VERSION=TODO_SUPPORT_MNSDK

4 changes: 2 additions & 2 deletions FBSDKCoreKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Pod::Spec.new do |s|

s.name = "FBSDKCoreKit"
s.version = "4.19.0"
s.version = "4.20.0"
s.summary = "Official Facebook SDK for iOS to access Facebook Platform's core features"

s.description = <<-DESC
Expand All @@ -22,7 +22,7 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = '9.0'

s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git",
:tag => "sdk-version-4.19.0"
:tag => "sdk-version-4.20.0"
}

s.ios.weak_frameworks = 'Accounts', 'CoreLocation', 'Social', 'Security', 'QuartzCore', 'CoreGraphics', 'UIKit', 'Foundation', 'AudioToolbox'
Expand Down
4 changes: 2 additions & 2 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAppEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,11 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
*/

/**
Sets a device token to register the current application installation for push notifications.
Sets and sends device token to register the current application for push notifications.
Sets a device token from `NSData` representation that you get from `UIApplicationDelegate.-application:didRegisterForRemoteNotificationsWithDeviceToken:`.
Sets and sends a device token from `NSData` representation that you get from `UIApplicationDelegate.-application:didRegisterForRemoteNotificationsWithDeviceToken:`.
- Parameter deviceToken: Device token data.
*/
Expand Down
23 changes: 20 additions & 3 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAppEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
NSString *const FBSDKAppEventNameSearched = @"fb_mobile_search";
NSString *const FBSDKAppEventNameRated = @"fb_mobile_rate";
NSString *const FBSDKAppEventNameCompletedTutorial = @"fb_mobile_tutorial_completion";
NSString *const FBSDKAppEventParameterLaunchSource = @"fb_mobile_launch_source";
NSString *const FBSDKAppEventParameterLaunchSource = @"fb_mobile_launch_source";

// Ecommerce related
NSString *const FBSDKAppEventNameAddedToCart = @"fb_mobile_add_to_cart";
Expand Down Expand Up @@ -185,9 +185,11 @@

//
// Push Notifications
//
// Activities Endpoint Parameter
static NSString *const FBSDKActivitesParameterPushDeviceToken = @"device_token";
// Event Name
// Event Names
static NSString *const FBSDKAppEventNamePushTokenObtained = @"fb_mobile_obtain_push_token";
static NSString *const FBSDKAppEventNamePushOpened = @"fb_mobile_push_opened";
// Event Parameter
static NSString *const FBSDKAppEventParameterPushCampaign = @"fb_push_campaign";
Expand Down Expand Up @@ -423,7 +425,22 @@ + (void)activateApp

+ (void)setPushNotificationsDeviceToken:(NSData *)deviceToken
{
[FBSDKAppEvents singleton].pushNotificationsDeviceTokenString = [FBSDKInternalUtility hexadecimalStringFromData:deviceToken];
NSString *deviceTokenString = [FBSDKInternalUtility hexadecimalStringFromData:deviceToken];
if (deviceTokenString == nil) {
[FBSDKAppEvents singleton].pushNotificationsDeviceTokenString = nil;
return;
}

if (![deviceTokenString isEqualToString:([FBSDKAppEvents singleton].pushNotificationsDeviceTokenString)]) {
[FBSDKAppEvents singleton].pushNotificationsDeviceTokenString = deviceTokenString;

[FBSDKAppEvents logEvent:FBSDKAppEventNamePushTokenObtained];

// Unless the behavior is set to only allow explicit flushing, we go ahead and flush the event
if ([FBSDKAppEvents flushBehavior] != FBSDKAppEventsFlushBehaviorExplicitOnly) {
[[FBSDKAppEvents singleton] flushForReason:FBSDKAppEventsFlushReasonEagerlyFlushingEvent];
}
}
}

+ (FBSDKAppEventsFlushBehavior)flushBehavior
Expand Down
2 changes: 1 addition & 1 deletion FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
#import <FBSDKCoreKit/FBSDKDeviceViewControllerBase.h>
#endif

#define FBSDK_VERSION_STRING @"4.19.0"
#define FBSDK_VERSION_STRING @"4.20.0"
#define FBSDK_TARGET_PLATFORM_VERSION @"v2.8"
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

#import "FBSDKCoreKit+Internal.h"

// don't download icons more than once a day.
static const NSTimeInterval kSmartLoginIconsTTL = 60 * 60 * 24;

@implementation FBSDKSmartDeviceDialogView
{
UIActivityIndicatorView *_spinner;
Expand All @@ -32,7 +29,7 @@ @implementation FBSDKSmartDeviceDialogView
- (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame])) {
[self _prepareImageCache];
[self _buildView];
}
return self;
}
Expand Down Expand Up @@ -61,50 +58,11 @@ - (void)buildView

#pragma mark - Helpers

- (void)_prepareImageCache
{
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *error) {
if ((serverConfiguration.smartLoginOptions & FBSDKServerConfigurationSmartLoginOptionsEnabled) &&
serverConfiguration.smartLoginMenuIconURL &&
serverConfiguration.smartLoginBookmarkIconURL) {
__block UIImage *bookmarkIconImage;
__block UIImage *menuIconImage;
__block NSUInteger count = 0;
void(^buildViewBlock)(void) = ^{
count++;
if (count >= 2){
dispatch_async(dispatch_get_main_queue(), ^{
[self _buildViewWithBookmarkIcon:bookmarkIconImage
menuIcon:menuIconImage];
[self setNeedsLayout];
});
}
};
[[FBSDKImageDownloader sharedInstance] downloadImageWithURL:serverConfiguration.smartLoginBookmarkIconURL
ttl:kSmartLoginIconsTTL
completion:^(UIImage *image) {
bookmarkIconImage = image;
buildViewBlock();
}];
[[FBSDKImageDownloader sharedInstance] downloadImageWithURL:serverConfiguration.smartLoginMenuIconURL
ttl:kSmartLoginIconsTTL
completion:^(UIImage *image) {
menuIconImage = image;
buildViewBlock();
}];
} else {
[self _buildViewWithBookmarkIcon:nil menuIcon:nil];
}
}];
}

- (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
menuIcon:(UIImage *)menuIcon
- (void)_buildView
{
// This is a "static" view with just a cancel button so add all the constraints here
// rather than properly override `updateConstraints`.
const CGFloat kWidth = 1080;
const CGFloat kHeight = 820;
const CGFloat kVerticalSpaceBetweenHeaderViewAndInstructionLabel = 50;
const CGFloat kDialogHeaderViewHeight = 250;
const CGFloat kLogoSize = 44;
Expand All @@ -125,7 +83,6 @@ - (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
[NSLayoutConstraint constraintWithItem:dialogView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0].active = YES;;
[NSLayoutConstraint constraintWithItem:dialogView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0].active = YES;
[dialogView.widthAnchor constraintEqualToConstant:kWidth].active = YES;
[dialogView.heightAnchor constraintEqualToConstant:kHeight].active = YES;

// build the header container view (which will contain the logo and code).
UIView *dialogHeaderView = [[UIView alloc] init];
Expand Down Expand Up @@ -175,43 +132,16 @@ - (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
// build the smartlogin instructions
UILabel *smartInstructionLabel = [[UILabel alloc] init];
smartInstructionLabel.translatesAutoresizingMaskIntoConstraints = NO;
NSString *smartInstructionsStep0 = NSLocalizedStringWithDefaultValue(@"DeviceLogin.SmartLogInStep0",
@"FacebookSDK",
[FBSDKInternalUtility bundleForStrings],
@"Confirm your code on Facebook.",
@"The string for smart login instructions");
NSString *smartInstructionsStep1 = NSLocalizedStringWithDefaultValue(@"DeviceLogin.SmartLogInStep1",
@"FacebookSDK",
[FBSDKInternalUtility bundleForStrings],
@"\n1. Go to the Menu ",
@"The string for smart login instructions");
NSString *smartInstructionsStep2 = NSLocalizedStringWithDefaultValue(@"DeviceLogin.SmartLogInStep2",
NSString *smartInstructionString = NSLocalizedStringWithDefaultValue(@"DeviceLogin.SmartLogInPrompt",
@"FacebookSDK",
[FBSDKInternalUtility bundleForStrings],
@"\n2. Select Device Requests ",
@"The string for smart login instructions");
NSString *smartInstructionsStep3 = NSLocalizedStringWithDefaultValue(@"DeviceLogin.SmartLogInStep3",
@"FacebookSDK",
[FBSDKInternalUtility bundleForStrings],
@"\n3. Confirm code.",
@"The string for smart login instructions");
NSTextAttachment *bookmarkAttachment = [[NSTextAttachment alloc] init];
bookmarkAttachment.image = bookmarkIcon;
NSAttributedString *attributedBookmarkString = [NSAttributedString attributedStringWithAttachment:bookmarkAttachment];

NSTextAttachment *menuAttachment = [[NSTextAttachment alloc] init];
menuAttachment.image = menuIcon;
NSAttributedString *attributedMenuString = [NSAttributedString attributedStringWithAttachment:menuAttachment];
@"To connect your account, open the Facebook app on your mobile device and check for notifications.",
@"Instructions telling the user to open their Facebook app on a mobile device and check for a login notification.");

NSMutableParagraphStyle *instructionLabelParagraphStyle = [[NSMutableParagraphStyle alloc] init];
instructionLabelParagraphStyle.lineHeightMultiple = 1.3;
NSMutableAttributedString *attributedSmartString = [[NSMutableAttributedString alloc] initWithString:smartInstructionsStep0
NSMutableAttributedString *attributedSmartString = [[NSMutableAttributedString alloc] initWithString:smartInstructionString
attributes:@{ NSParagraphStyleAttributeName : instructionLabelParagraphStyle }];
[attributedSmartString appendAttributedString:[[NSAttributedString alloc] initWithString:smartInstructionsStep1]];
[attributedSmartString appendAttributedString:attributedMenuString];
[attributedSmartString appendAttributedString:[[NSAttributedString alloc] initWithString:smartInstructionsStep2]];
[attributedSmartString appendAttributedString:attributedBookmarkString];
[attributedSmartString appendAttributedString:[[NSAttributedString alloc] initWithString:smartInstructionsStep3]];

UIFont *instructionFont = [UIFont systemFontOfSize:kInstructionFontSize weight:UIFontWeightLight];
smartInstructionLabel.font = instructionFont;
Expand All @@ -220,12 +150,6 @@ - (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
smartInstructionLabel.textAlignment = NSTextAlignmentCenter;
[smartInstructionLabel sizeToFit];

// resize the icons to fit with the font, and also vertically align them
// so that they start at the cap height. Annoyingly, the menu bookmark has some extra padding
// in the image so we offset that by an additional 2 points.
menuAttachment.bounds = CGRectMake(0, -(instructionFont.ascender - instructionFont.capHeight)+2, kInstructionFontSize, kInstructionFontSize);
bookmarkAttachment.bounds = CGRectMake(0, -(instructionFont.ascender - instructionFont.capHeight), kInstructionFontSize, kInstructionFontSize);

smartInstructionLabel.textColor = [UIColor colorWithWhite:kFontColorValue alpha:1.0];
[dialogView addSubview:smartInstructionLabel];
[smartInstructionLabel.topAnchor constraintEqualToAnchor:dialogHeaderView.bottomAnchor
Expand All @@ -247,8 +171,7 @@ - (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
[orInstructionLabel sizeToFit];
orInstructionLabel.textColor = [UIColor colorWithWhite:kFontColorValue alpha:1.0];
[dialogView addSubview:orInstructionLabel];
[orInstructionLabel.topAnchor constraintGreaterThanOrEqualToAnchor:smartInstructionLabel.bottomAnchor
constant:kVerticalMarginOrLabel].active = YES;
[orInstructionLabel.topAnchor constraintEqualToAnchor:smartInstructionLabel.bottomAnchor constant:kVerticalMarginOrLabel].active = YES;

[orInstructionLabel.leadingAnchor constraintEqualToAnchor:dialogView.leadingAnchor constant:kInstructionTextHorizontalMargin].active = YES;
[dialogView.trailingAnchor constraintEqualToAnchor:orInstructionLabel.trailingAnchor constant:kInstructionTextHorizontalMargin].active = YES;
Expand All @@ -259,7 +182,7 @@ - (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
NSString *localizedFormatString = NSLocalizedStringWithDefaultValue(@"DeviceLogin.LogInPrompt",
@"FacebookSDK",
[FBSDKInternalUtility bundleForStrings],
@"Visit %@ and enter your code.",
@"Visit %@ and enter the code shown above.",
@"The format string for device login instructions");

NSString *const deviceLoginURLString = @"facebook.com/device";
Expand Down Expand Up @@ -292,6 +215,8 @@ - (void)_buildViewWithBookmarkIcon:(UIImage *)bookmarkIcon
constant:400].active = YES;
[buttonContainerView.topAnchor constraintEqualToAnchor:instructionLabel.bottomAnchor
constant:kVerticalMarginOrLabel].active = YES;
[dialogView.bottomAnchor constraintEqualToAnchor:buttonContainerView.bottomAnchor
constant:kVerticalMarginOrLabel].active = YES;

// build the cancel button.
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
Expand Down
4 changes: 2 additions & 2 deletions FBSDKLoginKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Pod::Spec.new do |s|

s.name = "FBSDKLoginKit"
s.version = "4.19.0"
s.version = "4.20.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 @@ -21,7 +21,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "7.0"

s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git",
:tag => "sdk-version-4.19.0"
:tag => "sdk-version-4.20.0"
}

s.weak_frameworks = "Accounts", "CoreLocation", "Social", "Security", "QuartzCore", "CoreGraphics", "UIKit", "Foundation", "AudioToolbox"
Expand Down
4 changes: 2 additions & 2 deletions FBSDKShareKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Pod::Spec.new do |s|

s.name = "FBSDKShareKit"
s.version = "4.19.0"
s.version = "4.20.0"
s.summary = "Official Facebook SDK for iOS to access Facebook Platform's Sharing Features"

s.description = <<-DESC
Expand All @@ -22,7 +22,7 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = '9.0'

s.source = { :git => "https://github.com/facebook/facebook-ios-sdk.git",
:tag => "sdk-version-4.19.0"
:tag => "sdk-version-4.20.0"
}

s.ios.weak_frameworks = 'Accounts', 'AudioToolbox', 'CoreGraphics', 'CoreLocation', 'Foundation', 'QuartzCore', 'Security', 'Social', 'UIKit'
Expand Down
4 changes: 2 additions & 2 deletions FBSDKTVOSKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Pod::Spec.new do |s|

s.name = 'FBSDKTVOSKit'
s.version = '4.19.0'
s.version = '4.20.0'
s.summary = 'Official Facebook SDK for tvOS to access Facebook Platform with features like Login and Graph API.'

s.description = <<-DESC
Expand All @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = '9.0'

s.source = { :git => 'https://github.com/facebook/facebook-ios-sdk.git',
:tag => 'sdk-version-4.19.0' }
:tag => 'sdk-version-4.20.0' }

s.source_files = 'FBSDKTVOSKit/FBSDKTVOSKit/**/*.{h,m}'
s.public_header_files = 'FBSDKTVOSKit/FBSDKTVOSKit/*.h'
Expand Down
Loading

0 comments on commit f257b9a

Please sign in to comment.