- update libraries

- change NSLogDebug Marco
This commit is contained in:
giuseppenuc committed 2018-05-02 10:56:06 +02:00
1 parent e93483ea53
commit 78a514ed18
71 files changed
+4640 -3485

No files matched your search

@@ -60,6 +60,12 @@ FBSDK_EXTERN NSString *const FBSDKAccessTokenChangeOldKey;
*/
FBSDK_EXTERN NSString *const FBSDKAccessTokenChangeNewKey;
/*
A key in the notification's userInfo that will be set
if and only if the token has expired.
*/
FBSDK_EXTERN NSString *const FBSDKAccessTokenDidExpire;
/**
Represents an immutable access token for using Facebook services.
@@ -101,6 +107,11 @@ FBSDK_EXTERN NSString *const FBSDKAccessTokenChangeNewKey;
*/
@property (readonly, copy, nonatomic) NSString *userID;
/**
Returns whether the access token is expired by checking its expirationDate property
*/
@property (readonly, assign, nonatomic, getter = isExpired) BOOL expired;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@@ -150,6 +161,12 @@ NS_DESIGNATED_INITIALIZER;
*/
+ (FBSDKAccessToken *)currentAccessToken;
/**
Returns YES if currentAccessToken is not nil AND currentAccessToken is not expired
*/
+ (BOOL)currentAccessTokenIsActive;
/**
Sets the "global" access token that represents the currently logged in user.
- Parameter token: The access token to set.
@@ -27,6 +27,7 @@ NSString *const FBSDKAccessTokenDidChangeNotification = @"com.facebook.sdk.FBSDK
NSString *const FBSDKAccessTokenDidChangeUserID = @"FBSDKAccessTokenDidChangeUserID";
NSString *const FBSDKAccessTokenChangeNewKey = @"FBSDKAccessToken";
NSString *const FBSDKAccessTokenChangeOldKey = @"FBSDKAccessTokenOld";
NSString *const FBSDKAccessTokenDidExpire = @"FBSDKAccessTokenDidExpire";
static FBSDKAccessToken *g_currentAccessToken;
@@ -70,6 +71,11 @@ static FBSDKAccessToken *g_currentAccessToken;
return [self.permissions containsObject:permission];
}
- (BOOL)isExpired
{
return [self.expirationDate compare:NSDate.date] == NSOrderedAscending;
}
+ (FBSDKAccessToken *)currentAccessToken
{
return g_currentAccessToken;
@@ -81,7 +87,8 @@ static FBSDKAccessToken *g_currentAccessToken;
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
[FBSDKInternalUtility dictionary:userInfo setObject:token forKey:FBSDKAccessTokenChangeNewKey];
[FBSDKInternalUtility dictionary:userInfo setObject:g_currentAccessToken forKey:FBSDKAccessTokenChangeOldKey];
if (![g_currentAccessToken.userID isEqualToString:token.userID]) {
// We set this flag also when the current Access Token was not valid, since there might be legacy code relying on it
if (![g_currentAccessToken.userID isEqualToString:token.userID] || ![self currentAccessTokenIsActive]) {
userInfo[FBSDKAccessTokenDidChangeUserID] = @YES;
}
@@ -100,6 +107,12 @@ static FBSDKAccessToken *g_currentAccessToken;
}
}
+ (BOOL)currentAccessTokenIsActive
{
FBSDKAccessToken *currentAccessToken = [self currentAccessToken];
return currentAccessToken != nil && !currentAccessToken.isExpired;
}
+ (void)refreshCurrentAccessToken:(FBSDKGraphRequestHandler)completionHandler
{
if ([FBSDKAccessToken currentAccessToken]) {
@@ -122,6 +122,7 @@ NSString *const FBSDKAppEventNameFBSDKLikeButtonImpression = @"fb_like_bu
NSString *const FBSDKAppEventNameFBSDKLoginButtonImpression = @"fb_login_button_impression";
NSString *const FBSDKAppEventNameFBSDKSendButtonImpression = @"fb_send_button_impression";
NSString *const FBSDKAppEventNameFBSDKShareButtonImpression = @"fb_share_button_impression";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingButtonImpression = @"fb_live_streaming_button_impression";
NSString *const FBSDKAppEventNameFBSDKSmartLoginService = @"fb_smart_login_service";
@@ -129,6 +130,7 @@ NSString *const FBSDKAppEventNameFBSDKLikeButtonDidTap = @"fb_like_button_did_t
NSString *const FBSDKAppEventNameFBSDKLoginButtonDidTap = @"fb_login_button_did_tap";
NSString *const FBSDKAppEventNameFBSDKSendButtonDidTap = @"fb_send_button_did_tap";
NSString *const FBSDKAppEventNameFBSDKShareButtonDidTap = @"fb_share_button_did_tap";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingButtonDidTap = @"fb_live_streaming_button_did_tap";
NSString *const FBSDKAppEventNameFBSDKLikeControlDidDisable = @"fb_like_control_did_disable";
NSString *const FBSDKAppEventNameFBSDKLikeControlDidLike = @"fb_like_control_did_like";
@@ -149,6 +151,16 @@ NSString *const FBSDKAppEventNameFBSDKEventAppInviteShareDialogShow = @"fb_app
NSString *const FBSDKAppEventNameFBSessionFASLoginDialogResult = @"fb_mobile_login_fas_dialog_result";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingStart = @"fb_sdk_live_streaming_start";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingStop = @"fb_sdk_live_streaming_stop";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingPause = @"fb_sdk_live_streaming_pause";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingResume = @"fb_sdk_live_streaming_resume";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingError = @"fb_sdk_live_streaming_error";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingUpdateStatus = @"fb_sdk_live_streaming_update_status";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingVideoID = @"fb_sdk_live_streaming_video_id";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingMic = @"fb_sdk_live_streaming_mic";
NSString *const FBSDKAppEventNameFBSDKLiveStreamingCamera = @"fb_sdk_live_streaming_camera";
// Event Parameters internal to this file
NSString *const FBSDKAppEventParameterDialogOutcome = @"fb_dialog_outcome";
NSString *const FBSDKAppEventParameterDialogErrorMessage = @"fb_dialog_outcome_error_message";
@@ -162,6 +174,13 @@ NSString *const FBSDKAppEventParameterLogTime = @"_logTime";
NSString *const FBSDKAppEventParameterEventName = @"_eventName";
NSString *const FBSDKAppEventParameterImplicitlyLogged = @"_implicitlyLogged";
NSString *const FBSDKAppEventParameterLiveStreamingPrevStatus = @"live_streaming_prev_status";
NSString *const FBSDKAppEventParameterLiveStreamingStatus = @"live_streaming_status";
NSString *const FBSDKAppEventParameterLiveStreamingError = @"live_streaming_error";
NSString *const FBSDKAppEventParameterLiveStreamingVideoID = @"live_streaming_video_id";
NSString *const FBSDKAppEventParameterLiveStreamingMicEnabled = @"live_streaming_mic_enabled";
NSString *const FBSDKAppEventParameterLiveStreamingCameraEnabled = @"live_streaming_camera_enabled";
// Event parameter values internal to this file
NSString *const FBSDKAppEventsDialogOutcomeValue_Completed = @"Completed";
NSString *const FBSDKAppEventsDialogOutcomeValue_Cancelled = @"Cancelled";
@@ -593,6 +612,10 @@ static NSString *g_overrideAppID = nil;
- (void)publishInstall
{
NSString *appID = [self appID];
if ([appID length] == 0) {
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors logEntry:@"Missing [FBSDKAppEvents appID] for [FBSDKAppEvents publishInstall:]"];
return;
}
NSString *lastAttributionPingString = [NSString stringWithFormat:@"com.facebook.sdk:lastAttributionPing%@", appID];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:lastAttributionPingString]) {
@@ -782,9 +805,16 @@ static NSString *g_overrideAppID = nil;
- (void)flushOnMainQueue:(FBSDKAppEventsState *)appEventsState
forReason:(FBSDKAppEventsFlushReason)reason
{
if (appEventsState.events.count == 0) {
return;
}
if ([appEventsState.appID length] == 0) {
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors logEntry:@"Missing [FBSDKAppEvents appEventsState.appID] for [FBSDKAppEvents flushOnMainQueue:]"];
return;
}
[FBSDKAppEventsUtility ensureOnMainThread:NSStringFromSelector(_cmd) className:NSStringFromClass([self class])];
[self fetchServerConfiguration:^(void) {
@@ -864,7 +894,8 @@ static NSString *g_overrideAppID = nil;
// We interpret a 400 coming back from FBRequestConnection as a server error due to improper data being
// sent down. Otherwise we assume no connectivity, or another condition where we could treat it as no connectivity.
flushResult = errorCode == 400 ? FlushResultServerError : FlushResultNoConnectivity;
// Adding 404 as having wrong/missing appID results in 404 and that is not a connectivity issue
flushResult = (errorCode == 400 || errorCode == 404) ? FlushResultServerError : FlushResultNoConnectivity;
}
if (flushResult == FlushResultServerError) {
@@ -44,5 +44,5 @@
#import <FBSDKCoreKit/FBSDKDeviceViewControllerBase.h>
#endif
#define FBSDK_VERSION_STRING @"4.31.1"
#define FBSDK_TARGET_PLATFORM_VERSION @"v2.11"
#define FBSDK_VERSION_STRING @"4.33.0"
#define FBSDK_TARGET_PLATFORM_VERSION @"v3.0"
@@ -60,6 +60,26 @@ static NSTimeInterval g_defaultTimeout = 60.0;
static FBSDKErrorConfiguration *g_errorConfiguration;
#if !TARGET_OS_TV
static FBSDKAccessToken *_CreateExpiredAccessToken(FBSDKAccessToken *accessToken)
{
if (accessToken == nil) {
return nil;
}
if (accessToken.isExpired) {
return accessToken;
}
NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-1];
return [[FBSDKAccessToken alloc] initWithTokenString:accessToken.tokenString
permissions:accessToken.permissions.allObjects
declinedPermissions:accessToken.declinedPermissions.allObjects
appID:accessToken.appID
userID:accessToken.userID
expirationDate:expirationDate
refreshDate:expirationDate];
}
#endif
// ----------------------------------------------------------------------------
// FBSDKGraphRequestConnectionState
@@ -659,7 +679,7 @@ NSURLSessionDataDelegate
error:(NSError **)error
{
id parsed = nil;
if (!(*error)) {
if (!(*error) && [utf8 isKindOfClass:[NSString class]]) {
parsed = [FBSDKInternalUtility objectForJSONString:utf8 error:error];
// if we fail parse we attempt a re-parse of a modified input to support results in the form "foo=bar", "true", etc.
// which is shouldn't be necessary since Graph API v2.1.
@@ -741,10 +761,16 @@ NSURLSessionDataDelegate
};
#if !TARGET_OS_TV
void (^clearToken)(void) = ^{
if (!(metadata.request.flags & FBSDKGraphRequestFlagDoNotInvalidateTokenOnError)) {
void (^clearToken)(NSInteger) = ^(NSInteger errorSubcode){
if (metadata.request.flags & FBSDKGraphRequestFlagDoNotInvalidateTokenOnError) {
return;
}
if (errorSubcode == 493) {
[FBSDKAccessToken setCurrentAccessToken:_CreateExpiredAccessToken([FBSDKAccessToken currentAccessToken])];
} else {
[FBSDKAccessToken setCurrentAccessToken:nil];
}
};
FBSDKSystemAccountStoreAdapter *adapter = [FBSDKSystemAccountStoreAdapter sharedInstance];
@@ -769,14 +795,14 @@ NSURLSessionDataDelegate
[adapter renewSystemAuthorization:^(ACAccountCredentialRenewResult result, NSError *renewError) {
NSOperationQueue *queue = _delegateQueue ?: [NSOperationQueue mainQueue];
[queue addOperationWithBlock:^{
clearToken();
clearToken(errorSubcode);
finishAndInvokeCompletionHandler();
}];
}];
return;
}
}
clearToken();
clearToken(errorSubcode);
} else if (errorCode >= 200 && errorCode < 300) {
// permission error
[adapter renewSystemAuthorization:^(ACAccountCredentialRenewResult result, NSError *renewError) {
@@ -19,6 +19,7 @@
#import "FBSDKSettings+Internal.h"
#import "FBSDKAccessTokenCache.h"
#import "FBSDKAccessTokenExpirer.h"
#import "FBSDKCoreKit.h"
#define FBSDKSETTINGS_PLIST_CONFIGURATION_SETTING_IMPL(TYPE, PLIST_KEY, GETTER, SETTER, DEFAULT_VALUE) \
@@ -52,6 +53,7 @@ static NSString *const FBSDKSettingsLimitEventAndDataUsage = @"com.facebook.sdk:
static BOOL g_disableErrorRecovery;
static NSString *g_userAgentSuffix;
static NSString *g_defaultGraphAPIVersion;
static FBSDKAccessTokenExpirer *g_accessTokenExpirer;
@implementation FBSDKSettings
@@ -59,6 +61,7 @@ static NSString *g_defaultGraphAPIVersion;
{
if (self == [FBSDKSettings class]) {
g_tokenCache = [[FBSDKAccessTokenCache alloc] init];
g_accessTokenExpirer = [[FBSDKAccessTokenExpirer alloc] init];
}
}
@@ -94,6 +94,17 @@ FBSDK_EXTERN NSString *const FBSDKAppEventNameFBDialogsWebLoginCompleted;
/** Use to log the result of the App Switch OS AlertView. Only available on OS >= iOS10 */
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSessionFASLoginDialogResult;
/** Use to log the live streaming events from sdk */
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingStart;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingStop;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingPause;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingResume;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingError;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingUpdateStatus;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingVideoID;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingMic;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingCamera;
/** Use to log the results of a share dialog */
FBSDK_EXTERN NSString *const FBSDLAppEventNameFBSDKEventShareDialogResult;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKEventMessengerShareDialogResult;
@@ -112,6 +123,14 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterDialogShareContentPageID;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterShareTrayActivityName;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterShareTrayResult;
/*! Use to log parameters for live streaming*/
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLiveStreamingPrevStatus;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLiveStreamingStatus;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLiveStreamingError;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLiveStreamingVideoID;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLiveStreamingMicEnabled;
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLiveStreamingCameraEnabled;
// Internally known event parameter values
FBSDK_EXTERN NSString *const FBSDKAppEventsDialogOutcomeValue_Completed;
@@ -147,6 +166,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLikeButtonImpression;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLoginButtonImpression;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKSendButtonImpression;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKShareButtonImpression;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingButtonImpression;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKSmartLoginService;
@@ -154,6 +174,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLikeButtonDidTap;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLoginButtonDidTap;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKSendButtonDidTap;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKShareButtonDidTap;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLiveStreamingButtonDidTap;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLikeControlDidDisable;
FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLikeControlDidLike;
@@ -66,6 +66,7 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
smartLoginOptions:(FBSDKServerConfigurationSmartLoginOptions)smartLoginOptions
smartLoginBookmarkIconURL:(NSURL *)smartLoginBookmarkIconURL
smartLoginMenuIconURL:(NSURL *)smartLoginMenuIconURL
updateMessage:(NSString *)updateMessage
NS_DESIGNATED_INITIALIZER;
@property (nonatomic, assign, readonly, getter=isAdvertisingIDEnabled) BOOL advertisingIDEnabled;
@@ -87,6 +88,7 @@ NS_DESIGNATED_INITIALIZER;
@property (nonatomic, assign, readonly) FBSDKServerConfigurationSmartLoginOptions smartLoginOptions;
@property (nonatomic, copy, readonly) NSURL *smartLoginBookmarkIconURL;
@property (nonatomic, copy, readonly) NSURL *smartLoginMenuIconURL;
@property (nonatomic, copy, readonly) NSString *updateMessage;
@property (nonatomic, readonly) NSInteger version;
- (FBSDKDialogConfiguration *)dialogConfigurationForDialogName:(NSString *)dialogName;
@@ -42,6 +42,7 @@
#define FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_OPTIONS_KEY @"smartLoginEnabled"
#define FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_BOOKMARK_ICON_URL_KEY @"smarstLoginBookmarkIconURL"
#define FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_MENU_ICON_URL_KEY @"smarstLoginBookmarkMenuURL"
#define FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_KEY @"SDKUpdateMessage"
#define FBSDK_SERVER_CONFIGURATION_VERSION_KEY @"version"
#pragma mark - Dialog Names
@@ -101,6 +102,7 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
smartLoginOptions:(FBSDKServerConfigurationSmartLoginOptions)smartLoginOptions
smartLoginBookmarkIconURL:(NSURL *)smartLoginBookmarkIconURL
smartLoginMenuIconURL:(NSURL *)smartLoginMenuIconURL
updateMessage:(NSString *)updateMessage
{
if ((self = [super init])) {
_appID = [appID copy];
@@ -124,6 +126,7 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
_smartLoginOptions = smartLoginOptions;
_smartLoginMenuIconURL = [smartLoginMenuIconURL copy];
_smartLoginBookmarkIconURL = [smartLoginBookmarkIconURL copy];
_updateMessage = [updateMessage copy];
_version = FBSDKServerConfigurationVersion;
}
return self;
@@ -205,6 +208,7 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
NSString *loggingToken = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SERVER_CONFIGURATION_LOGGING_TOKEN];
NSURL *smartLoginBookmarkIconURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_BOOKMARK_ICON_URL_KEY];
NSURL *smartLoginMenuIconURL = [decoder decodeObjectOfClass:[NSURL class] forKey:FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_MENU_ICON_URL_KEY];
NSString *updateMessage = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_KEY];
NSInteger version = [decoder decodeIntegerForKey:FBSDK_SERVER_CONFIGURATION_VERSION_KEY];
FBSDKServerConfiguration *configuration = [self initWithAppID:appID
appName:appName
@@ -227,6 +231,7 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
smartLoginOptions:smartLoginOptions
smartLoginBookmarkIconURL:smartLoginBookmarkIconURL
smartLoginMenuIconURL:smartLoginMenuIconURL
updateMessage:updateMessage
];
configuration->_version = version;
return configuration;
@@ -256,6 +261,7 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
[encoder encodeInteger:_smartLoginOptions forKey:FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_OPTIONS_KEY];
[encoder encodeObject:_smartLoginBookmarkIconURL forKey:FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_BOOKMARK_ICON_URL_KEY];
[encoder encodeObject:_smartLoginMenuIconURL forKey:FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_MENU_ICON_URL_KEY];
[encoder encodeObject:_updateMessage forKey:FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_KEY];
[encoder encodeInteger:_version forKey:FBSDK_SERVER_CONFIGURATION_VERSION_KEY];
}
@@ -50,6 +50,7 @@
#define FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_OPTIONS_FIELD @"seamless_login"
#define FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_BOOKMARK_ICON_URL_FIELD @"smart_login_bookmark_icon_url"
#define FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_MENU_ICON_URL_FIELD @"smart_login_menu_icon_url"
#define FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_FIELD @"sdk_update_message"
@implementation FBSDKServerConfigurationManager
@@ -59,6 +60,7 @@ static FBSDKServerConfiguration *_serverConfiguration;
static NSError *_serverConfigurationError;
static NSDate *_serverConfigurationErrorTimestamp;
static const NSTimeInterval kTimeout = 4.0;
static BOOL _printedUpdateMessage;
typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
{
@@ -191,6 +193,7 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
FBSDKServerConfigurationSmartLoginOptions smartLoginOptions = [FBSDKTypeUtility integerValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_OPTIONS_FIELD]];
NSURL *smartLoginBookmarkIconURL = [FBSDKTypeUtility URLValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_BOOKMARK_ICON_URL_FIELD]];
NSURL *smartLoginMenuIconURL = [FBSDKTypeUtility URLValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_MENU_ICON_URL_FIELD]];
NSString *updateMessage = [FBSDKTypeUtility stringValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_FIELD]];
FBSDKServerConfiguration *serverConfiguration = [[FBSDKServerConfiguration alloc] initWithAppID:appID
appName:appName
loginTooltipEnabled:loginTooltipEnabled
@@ -212,6 +215,7 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
smartLoginOptions:smartLoginOptions
smartLoginBookmarkIconURL:smartLoginBookmarkIconURL
smartLoginMenuIconURL:smartLoginMenuIconURL
updateMessage:updateMessage
];
#if TARGET_OS_TV
// don't download icons more than once a day.
@@ -254,6 +258,9 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
FBSDK_SERVER_CONFIGURATION_SYSTEM_AUTHENTICATION_ENABLED_FIELD,
FBSDK_SERVER_CONFIGURATION_SESSION_TIMEOUT_FIELD,
FBSDK_SERVER_CONFIGURATION_LOGGIN_TOKEN_FIELD
#ifdef DEBUG
,FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_FIELD
#endif
#if TARGET_OS_TV
,FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_OPTIONS_FIELD,
FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_BOOKMARK_ICON_URL_FIELD,
@@ -313,6 +320,7 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
smartLoginOptions:FBSDKServerConfigurationSmartLoginOptionsUnknown
smartLoginBookmarkIconURL:nil
smartLoginMenuIconURL:nil
updateMessage:nil
];
}
return _defaultServerConfiguration;
@@ -342,6 +350,14 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
_serverConfiguration = serverConfiguration;
_serverConfigurationError = nil;
_serverConfigurationErrorTimestamp = nil;
#ifdef DEBUG
NSString *updateMessage = _serverConfiguration.updateMessage;
if (updateMessage && [updateMessage length] > 0 && !_printedUpdateMessage) {
_printedUpdateMessage = YES;
NSLog(@"%@", updateMessage);
}
#endif
}
// update the cached copy in NSUserDefaults
@@ -0,0 +1,23 @@
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy, modify, and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by Facebook.
//
// As with any software that integrates with the Facebook platform, your use of
// this software is subject to the Facebook Developer Principles and Policies
// [http://developers.facebook.com/policy/]. This copyright notice shall be
// included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#import <Foundation/Foundation.h>
@interface FBSDKAccessTokenExpirer : NSObject
@end
@@ -0,0 +1,71 @@
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
//
// You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
// copy, modify, and distribute this software in source code or binary form for use
// in connection with the web services and APIs provided by Facebook.
//
// As with any software that integrates with the Facebook platform, your use of
// this software is subject to the Facebook Developer Principles and Policies
// [http://developers.facebook.com/policy/]. This copyright notice shall be
// included in all copies or substantial portions of the software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#import "FBSDKAccessTokenExpirer.h"
#import "FBSDKAccessToken.h"
#import "FBSDKApplicationDelegate+Internal.h"
#import "FBSDKInternalUtility.h"
@implementation FBSDKAccessTokenExpirer
{
NSTimer *_timer;
}
- (instancetype)init
{
if (self = [super init]) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_checkAccessTokenExpirationDate) name:FBSDKAccessTokenDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_checkAccessTokenExpirationDate) name:FBSDKApplicationDidBecomeActiveNotification object:nil];
[self _checkAccessTokenExpirationDate];
}
return self;
}
- (void)dealloc
{
[_timer invalidate];
_timer = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)_checkAccessTokenExpirationDate
{
[_timer invalidate];
_timer = nil;
FBSDKAccessToken *accessToken = FBSDKAccessToken.currentAccessToken;
if (accessToken == nil || accessToken.isExpired) {
return;
}
_timer = [NSTimer scheduledTimerWithTimeInterval:[accessToken.expirationDate timeIntervalSinceNow] target:self selector:@selector(_timerDidFire) userInfo:nil repeats:NO];
}
- (void)_timerDidFire
{
FBSDKAccessToken *accessToken = FBSDKAccessToken.currentAccessToken;
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
[FBSDKInternalUtility dictionary:userInfo setObject:accessToken forKey:FBSDKAccessTokenChangeNewKey];
[FBSDKInternalUtility dictionary:userInfo setObject:accessToken forKey:FBSDKAccessTokenChangeOldKey];
userInfo[FBSDKAccessTokenDidExpire] = @YES;
[[NSNotificationCenter defaultCenter] postNotificationName:FBSDKAccessTokenDidChangeNotification
object:[FBSDKAccessToken class]
userInfo:userInfo];
}
@end