- add - (BOOL) removeObjectsWithClass:(Class _Nonnull) class
- fix - (id _Nonnull) saveLocally:(id _Nonnull) object - upgrade libraries
This commit is contained in:
parent
874707e958
commit
99e06e67db
@ -1,18 +1,18 @@
|
||||
PODS:
|
||||
- AFNetworking (3.2.0):
|
||||
- AFNetworking/NSURLSession (= 3.2.0)
|
||||
- AFNetworking/Reachability (= 3.2.0)
|
||||
- AFNetworking/Security (= 3.2.0)
|
||||
- AFNetworking/Serialization (= 3.2.0)
|
||||
- AFNetworking/UIKit (= 3.2.0)
|
||||
- AFNetworking/NSURLSession (3.2.0):
|
||||
- AFNetworking (3.2.1):
|
||||
- AFNetworking/NSURLSession (= 3.2.1)
|
||||
- AFNetworking/Reachability (= 3.2.1)
|
||||
- AFNetworking/Security (= 3.2.1)
|
||||
- AFNetworking/Serialization (= 3.2.1)
|
||||
- AFNetworking/UIKit (= 3.2.1)
|
||||
- AFNetworking/NSURLSession (3.2.1):
|
||||
- AFNetworking/Reachability
|
||||
- AFNetworking/Security
|
||||
- AFNetworking/Serialization
|
||||
- AFNetworking/Reachability (3.2.0)
|
||||
- AFNetworking/Security (3.2.0)
|
||||
- AFNetworking/Serialization (3.2.0)
|
||||
- AFNetworking/UIKit (3.2.0):
|
||||
- AFNetworking/Reachability (3.2.1)
|
||||
- AFNetworking/Security (3.2.1)
|
||||
- AFNetworking/Serialization (3.2.1)
|
||||
- AFNetworking/UIKit (3.2.1):
|
||||
- AFNetworking/NSURLSession
|
||||
- Bolts (1.9.0):
|
||||
- Bolts/AppLinks (= 1.9.0)
|
||||
@ -26,19 +26,19 @@ PODS:
|
||||
- DJLocalization/Core (= 1.2.2)
|
||||
- DJLocalization/Core (1.2.2)
|
||||
- Expecta (1.0.6)
|
||||
- FBSDKCoreKit (4.33.0):
|
||||
- FBSDKCoreKit (4.37.0):
|
||||
- Bolts (~> 1.7)
|
||||
- FBSDKLoginKit (4.33.0):
|
||||
- FBSDKLoginKit (4.37.0):
|
||||
- FBSDKCoreKit
|
||||
- FBSDKShareKit (4.33.0):
|
||||
- FBSDKCoreKit (~> 4.33.0)
|
||||
- FBSDKShareKit (4.37.0):
|
||||
- FBSDKCoreKit (~> 4.37.0)
|
||||
- NSDataAES (0.2.2)
|
||||
- NSDate_Utils (1.1.0):
|
||||
- DJLocalization
|
||||
- NSString-Helper (1.1.0)
|
||||
- NSString-Helper (1.2.0)
|
||||
- nv-ios-http-status (0.0.1)
|
||||
- PEAR-FileManager-iOS (1.3.1)
|
||||
- PNObject (2.5.7):
|
||||
- PNObject (2.6.0):
|
||||
- AFNetworking
|
||||
- CodFis-Helper
|
||||
- DDDKeychainWrapper
|
||||
@ -54,11 +54,11 @@ PODS:
|
||||
- RZDataBinding
|
||||
- StrongestPasswordValidator
|
||||
- UIDevice-Utils
|
||||
- PureLayout (3.0.2)
|
||||
- RZDataBinding (2.1.0)
|
||||
- PureLayout (3.1.2)
|
||||
- RZDataBinding (2.1.1)
|
||||
- Specta (1.0.7)
|
||||
- StrongestPasswordValidator (0.1.2)
|
||||
- UIDevice-Utils (1.0.8)
|
||||
- UIDevice-Utils (1.0.9)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Expecta
|
||||
@ -67,7 +67,7 @@ DEPENDENCIES:
|
||||
- Specta
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/CocoaPods/Specs.git:
|
||||
https://github.com/cocoapods/specs.git:
|
||||
- AFNetworking
|
||||
- Bolts
|
||||
- CodFis-Helper
|
||||
@ -93,27 +93,27 @@ EXTERNAL SOURCES:
|
||||
:path: "../"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
AFNetworking: 8ac6017b94ea105479f7776e5288e48ae9c59bb4
|
||||
AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
|
||||
Bolts: ac6567323eac61e203f6a9763667d0f711be34c8
|
||||
CodFis-Helper: 28be4c74d7202542459d72354f59b1215871de87
|
||||
DDDKeychainWrapper: e681a4daba6448786fa83b4941f58102a33b1897
|
||||
DJLocalization: 0c84029af375647d4104a42ae36be87194c46c47
|
||||
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
|
||||
FBSDKCoreKit: 572b047a7e029bc44542bcf8a59414e7ff2b543e
|
||||
FBSDKLoginKit: 88cb456349cfb3b554427ce4f8b43729d85dfb40
|
||||
FBSDKShareKit: b7b5002833a4104fbecad75e8e4e082e91c7a08a
|
||||
FBSDKCoreKit: fe5f3474499a81963e11e3f3a5c753d0a95ca2b4
|
||||
FBSDKLoginKit: 2f7249686d1e30ce8a5ef5400eedf50b3e3df332
|
||||
FBSDKShareKit: 52e0083222c38e930eb6878007478326599195c3
|
||||
NSDataAES: 967ea3337476a80e9838a533c25d570a06855ed0
|
||||
NSDate_Utils: c858a89da6e204ecf53aca48dbccb4da4d25bc9e
|
||||
NSString-Helper: 645162758421206f509cb46cbd10023eab7594ed
|
||||
NSString-Helper: 1c259caa6c845e79e0bb45ee25e34f95d86d2317
|
||||
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
|
||||
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
|
||||
PNObject: 524a8d655fb150c0da2f262441bbbe24dd9bd8b9
|
||||
PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd
|
||||
RZDataBinding: 6981e90ddaae2f5e02028323b1043f8c31013109
|
||||
PNObject: d92d660eb43b9385e7148e42598b8a7d3a785834
|
||||
PureLayout: 4634d0b61e3b5021166e8ec7c18e9e0ca0720c8b
|
||||
RZDataBinding: 289e2fbdce8b9585afef69def83425c5d380ffbd
|
||||
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66
|
||||
StrongestPasswordValidator: 921e42615bdf353513c6f925bffd4fc29865dbd7
|
||||
UIDevice-Utils: a629b53a88c1429cfb4bdff35b18287feebd164a
|
||||
UIDevice-Utils: 6ba44475416a1e823f214a8ed26fc9a0761db096
|
||||
|
||||
PODFILE CHECKSUM: eec9c921f7aee591fd1fdea1fd3e5a191b74a436
|
||||
|
||||
COCOAPODS: 1.5.0
|
||||
COCOAPODS: 1.5.3
|
||||
|
||||
37
Example/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h
generated
Normal file
37
Example/Pods/AFNetworking/AFNetworking/AFCompatibilityMacros.h
generated
Normal file
@ -0,0 +1,37 @@
|
||||
// AFCompatibilityMacros.h
|
||||
// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ )
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission 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.
|
||||
|
||||
#ifndef AFCompatibilityMacros_h
|
||||
#define AFCompatibilityMacros_h
|
||||
|
||||
#ifdef API_UNAVAILABLE
|
||||
#define AF_API_UNAVAILABLE(x) API_UNAVAILABLE(x)
|
||||
#else
|
||||
#define AF_API_UNAVAILABLE(x)
|
||||
#endif // API_UNAVAILABLE
|
||||
|
||||
#if __has_warning("-Wunguarded-availability-new")
|
||||
#define AF_CAN_USE_AT_AVAILABLE 1
|
||||
#else
|
||||
#define AF_CAN_USE_AT_AVAILABLE 0
|
||||
#endif
|
||||
|
||||
#endif /* AFCompatibilityMacros_h */
|
||||
@ -108,11 +108,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
* Initializes an instance of a network reachability manager
|
||||
*
|
||||
* @return nil as this method is unavailable
|
||||
* Unavailable initializer
|
||||
*/
|
||||
- (nullable instancetype)init NS_UNAVAILABLE;
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* Unavailable initializer
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
///--------------------------------------------------
|
||||
/// @name Starting & Stopping Reachability Monitoring
|
||||
|
||||
@ -170,8 +170,11 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE
|
||||
- (instancetype)init
|
||||
{
|
||||
@throw [NSException exceptionWithName:NSGenericException
|
||||
reason:@"`-init` unavailable. Use `-initWithReachability:` instead"
|
||||
userInfo:nil];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#import "AFURLResponseSerialization.h"
|
||||
#import "AFURLRequestSerialization.h"
|
||||
#import "AFSecurityPolicy.h"
|
||||
#import "AFCompatibilityMacros.h"
|
||||
#if !TARGET_OS_WATCH
|
||||
#import "AFNetworkReachabilityManager.h"
|
||||
#endif
|
||||
@ -414,7 +415,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session.
|
||||
*/
|
||||
- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block;
|
||||
- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block AF_API_UNAVAILABLE(macos);
|
||||
|
||||
///-----------------------------------------------
|
||||
/// @name Setting Download Task Delegate Callbacks
|
||||
|
||||
@ -148,15 +148,17 @@ typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id re
|
||||
progress.pausingHandler = ^{
|
||||
[weakTask suspend];
|
||||
};
|
||||
#if __has_warning("-Wunguarded-availability-new")
|
||||
if (@available(iOS 9, macOS 10.11, *)) {
|
||||
#if AF_CAN_USE_AT_AVAILABLE
|
||||
if (@available(iOS 9, macOS 10.11, *))
|
||||
#else
|
||||
if ([progress respondsToSelector:@selector(setResumingHandler:)]) {
|
||||
if ([progress respondsToSelector:@selector(setResumingHandler:)])
|
||||
#endif
|
||||
{
|
||||
progress.resumingHandler = ^{
|
||||
[weakTask resume];
|
||||
};
|
||||
}
|
||||
|
||||
[progress addObserver:self
|
||||
forKeyPath:NSStringFromSelector(@selector(fractionCompleted))
|
||||
options:NSKeyValueObservingOptionNew
|
||||
@ -452,7 +454,7 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
@property (readwrite, nonatomic, strong) NSLock *lock;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession AF_API_UNAVAILABLE(macos);
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge;
|
||||
@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream;
|
||||
@ -839,9 +841,11 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
self.sessionDidReceiveAuthenticationChallenge = block;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_OSX
|
||||
- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block {
|
||||
self.didFinishEventsForBackgroundURLSession = block;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@ -910,9 +914,12 @@ static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofi
|
||||
return self.dataTaskDidReceiveResponse != nil;
|
||||
} else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) {
|
||||
return self.dataTaskWillCacheResponse != nil;
|
||||
} else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) {
|
||||
}
|
||||
#if !TARGET_OS_OSX
|
||||
else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) {
|
||||
return self.didFinishEventsForBackgroundURLSession != nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
return [[self class] instancesRespondToSelector:selector];
|
||||
}
|
||||
@ -1130,6 +1137,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
|
||||
}
|
||||
}
|
||||
|
||||
#if !TARGET_OS_OSX
|
||||
- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session {
|
||||
if (self.didFinishEventsForBackgroundURLSession) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@ -1137,6 +1145,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask
|
||||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark - NSURLSessionDownloadDelegate
|
||||
|
||||
|
||||
@ -75,17 +75,20 @@
|
||||
success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success
|
||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure
|
||||
{
|
||||
|
||||
|
||||
if ([urlRequest URL] == nil) {
|
||||
[self cancelImageDownloadTask];
|
||||
self.image = placeholderImage;
|
||||
if (failure) {
|
||||
NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil];
|
||||
failure(urlRequest, nil, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
[self cancelImageDownloadTask];
|
||||
|
||||
AFImageDownloader *downloader = [[self class] sharedImageDownloader];
|
||||
|
||||
@ -77,6 +77,11 @@ FBSDK_EXTERN NSString *const FBSDKAccessTokenDidExpire;
|
||||
*/
|
||||
@property (readonly, copy, nonatomic) NSString *appID;
|
||||
|
||||
/**
|
||||
Returns the expiration date for data access
|
||||
*/
|
||||
@property (readonly, copy, nonatomic) NSDate *dataAccessExpirationDate;
|
||||
|
||||
/**
|
||||
Returns the known declined permissions.
|
||||
*/
|
||||
@ -112,20 +117,51 @@ FBSDK_EXTERN NSString *const FBSDKAccessTokenDidExpire;
|
||||
*/
|
||||
@property (readonly, assign, nonatomic, getter = isExpired) BOOL expired;
|
||||
|
||||
/**
|
||||
Returns whether user data access is still active for the given access token
|
||||
*/
|
||||
@property (readonly, assign, nonatomic, getter = isDataAccessExpired) BOOL dataAccessExpired;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
Initializes a new instance.
|
||||
@param tokenString the opaque token string.
|
||||
@param permissions the granted permissions. Note this is converted to NSSet and is only
|
||||
an NSArray for the convenience of literal syntax.
|
||||
@param declinedPermissions the declined permissions. Note this is converted to NSSet and is only
|
||||
an NSArray for the convenience of literal syntax.
|
||||
@param appID the app ID.
|
||||
@param userID the user ID.
|
||||
@param expirationDate the optional expiration date (defaults to distantFuture).
|
||||
@param refreshDate the optional date the token was last refreshed (defaults to today).
|
||||
|
||||
This initializer should only be used for advanced apps that
|
||||
manage tokens explicitly. Typical login flows only need to use `FBSDKLoginManager`
|
||||
along with `+currentAccessToken`.
|
||||
*/
|
||||
- (instancetype)initWithTokenString:(NSString *)tokenString
|
||||
permissions:(NSArray *)permissions
|
||||
declinedPermissions:(NSArray *)declinedPermissions
|
||||
appID:(NSString *)appID
|
||||
userID:(NSString *)userID
|
||||
expirationDate:(NSDate *)expirationDate
|
||||
refreshDate:(NSDate *)refreshDate;
|
||||
|
||||
/**
|
||||
Initializes a new instance.
|
||||
- Parameter tokenString: the opaque token string.
|
||||
- Parameter permissions: the granted permissions. Note this is converted to NSSet and is only
|
||||
@param tokenString the opaque token string.
|
||||
@param permissions the granted permissions. Note this is converted to NSSet and is only
|
||||
an NSArray for the convenience of literal syntax.
|
||||
- Parameter declinedPermissions: the declined permissions. Note this is converted to NSSet and is only
|
||||
@param declinedPermissions the declined permissions. Note this is converted to NSSet and is only
|
||||
an NSArray for the convenience of literal syntax.
|
||||
- Parameter appID: the app ID.
|
||||
- Parameter userID: the user ID.
|
||||
- Parameter expirationDate: the optional expiration date (defaults to distantFuture).
|
||||
- Parameter refreshDate: the optional date the token was last refreshed (defaults to today).
|
||||
@param appID the app ID.
|
||||
@param userID the user ID.
|
||||
@param expirationDate the optional expiration date (defaults to distantFuture).
|
||||
@param refreshDate the optional date the token was last refreshed (defaults to today).
|
||||
@param dataAccessExpirationDate the date which data access will expire for the given user
|
||||
(defaults to distantFuture).
|
||||
|
||||
This initializer should only be used for advanced apps that
|
||||
manage tokens explicitly. Typical login flows only need to use `FBSDKLoginManager`
|
||||
@ -138,18 +174,19 @@ FBSDK_EXTERN NSString *const FBSDKAccessTokenDidExpire;
|
||||
userID:(NSString *)userID
|
||||
expirationDate:(NSDate *)expirationDate
|
||||
refreshDate:(NSDate *)refreshDate
|
||||
dataAccessExpirationDate:(NSDate *)dataAccessExpirationDate
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
Convenience getter to determine if a permission has been granted
|
||||
- Parameter permission: The permission to check.
|
||||
@param permission The permission to check.
|
||||
*/
|
||||
- (BOOL)hasGranted:(NSString *)permission;
|
||||
|
||||
/**
|
||||
Compares the receiver to another FBSDKAccessToken
|
||||
- Parameter token: The other token
|
||||
- Returns: YES if the receiver's values are equal to the other token's values; otherwise NO
|
||||
@param token The other token
|
||||
@return YES if the receiver's values are equal to the other token's values; otherwise NO
|
||||
*/
|
||||
- (BOOL)isEqualToAccessToken:(FBSDKAccessToken *)token;
|
||||
|
||||
@ -169,7 +206,7 @@ NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
Sets the "global" access token that represents the currently logged in user.
|
||||
- Parameter token: The access token to set.
|
||||
@param token The access token to set.
|
||||
|
||||
This will broadcast a notification and save the token to the app keychain.
|
||||
*/
|
||||
@ -178,7 +215,7 @@ NS_DESIGNATED_INITIALIZER;
|
||||
/**
|
||||
Refresh the current access token's permission state and extend the token's expiration date,
|
||||
if possible.
|
||||
- Parameter completionHandler: an optional callback handler that can surface any errors related to permission refreshing.
|
||||
@param completionHandler an optional callback handler that can surface any errors related to permission refreshing.
|
||||
|
||||
On a successful refresh, the currentAccessToken will be updated so you typically only need to
|
||||
observe the `FBSDKAccessTokenDidChangeNotification` notification.
|
||||
|
||||
@ -38,6 +38,8 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
#define FBSDK_ACCESSTOKEN_USERID_KEY @"userID"
|
||||
#define FBSDK_ACCESSTOKEN_REFRESHDATE_KEY @"refreshDate"
|
||||
#define FBSDK_ACCESSTOKEN_EXPIRATIONDATE_KEY @"expirationDate"
|
||||
#define FBSDK_ACCESSTOKEN_DATA_EXPIRATIONDATE_KEY @"dataAccessExpirationDate"
|
||||
|
||||
|
||||
@implementation FBSDKAccessToken
|
||||
|
||||
@ -53,6 +55,25 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
userID:(NSString *)userID
|
||||
expirationDate:(NSDate *)expirationDate
|
||||
refreshDate:(NSDate *)refreshDate
|
||||
{
|
||||
return [self initWithTokenString:tokenString
|
||||
permissions:permissions
|
||||
declinedPermissions:declinedPermissions
|
||||
appID:appID
|
||||
userID:userID
|
||||
expirationDate:expirationDate
|
||||
refreshDate:refreshDate
|
||||
dataAccessExpirationDate:[NSDate distantFuture]];
|
||||
}
|
||||
|
||||
- (instancetype)initWithTokenString:(NSString *)tokenString
|
||||
permissions:(NSArray *)permissions
|
||||
declinedPermissions:(NSArray *)declinedPermissions
|
||||
appID:(NSString *)appID
|
||||
userID:(NSString *)userID
|
||||
expirationDate:(NSDate *)expirationDate
|
||||
refreshDate:(NSDate *)refreshDate
|
||||
dataAccessExpirationDate:(NSDate *)dataAccessExpirationDate
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_tokenString = [tokenString copy];
|
||||
@ -62,6 +83,7 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
_userID = [userID copy];
|
||||
_expirationDate = [expirationDate copy] ?: [NSDate distantFuture];
|
||||
_refreshDate = [refreshDate copy] ?: [NSDate date];
|
||||
_dataAccessExpirationDate = [dataAccessExpirationDate copy] ?: [NSDate distantFuture];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -69,6 +91,12 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
- (BOOL)hasGranted:(NSString *)permission
|
||||
{
|
||||
return [self.permissions containsObject:permission];
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)isDataAccessExpired
|
||||
{
|
||||
return [self.dataAccessExpirationDate compare:NSDate.date] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)isExpired
|
||||
@ -137,7 +165,8 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
[self.appID hash],
|
||||
[self.userID hash],
|
||||
[self.refreshDate hash],
|
||||
[self.expirationDate hash]
|
||||
[self.expirationDate hash],
|
||||
[self.dataAccessExpirationDate hash]
|
||||
};
|
||||
return [FBSDKMath hashWithIntegerArray:subhashes count:sizeof(subhashes) / sizeof(subhashes[0])];
|
||||
}
|
||||
@ -162,7 +191,8 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
[FBSDKInternalUtility object:self.appID isEqualToObject:token.appID] &&
|
||||
[FBSDKInternalUtility object:self.userID isEqualToObject:token.userID] &&
|
||||
[FBSDKInternalUtility object:self.refreshDate isEqualToObject:token.refreshDate] &&
|
||||
[FBSDKInternalUtility object:self.expirationDate isEqualToObject:token.expirationDate] );
|
||||
[FBSDKInternalUtility object:self.expirationDate isEqualToObject:token.expirationDate] &&
|
||||
[FBSDKInternalUtility object:self.dataAccessExpirationDate isEqualToObject:token.dataAccessExpirationDate] );
|
||||
}
|
||||
|
||||
#pragma mark - NSCopying
|
||||
@ -189,6 +219,7 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
NSString *userID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDK_ACCESSTOKEN_USERID_KEY];
|
||||
NSDate *refreshDate = [decoder decodeObjectOfClass:[NSDate class] forKey:FBSDK_ACCESSTOKEN_REFRESHDATE_KEY];
|
||||
NSDate *expirationDate = [decoder decodeObjectOfClass:[NSDate class] forKey:FBSDK_ACCESSTOKEN_EXPIRATIONDATE_KEY];
|
||||
NSDate *dataAccessExpirationDate = [decoder decodeObjectOfClass:[NSDate class] forKey:FBSDK_ACCESSTOKEN_DATA_EXPIRATIONDATE_KEY];
|
||||
|
||||
return [self initWithTokenString:tokenString
|
||||
permissions:[permissions allObjects]
|
||||
@ -196,7 +227,8 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
appID:appID
|
||||
userID:userID
|
||||
expirationDate:expirationDate
|
||||
refreshDate:refreshDate];
|
||||
refreshDate:refreshDate
|
||||
dataAccessExpirationDate:dataAccessExpirationDate];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)encoder
|
||||
@ -208,6 +240,7 @@ static FBSDKAccessToken *g_currentAccessToken;
|
||||
[encoder encodeObject:self.userID forKey:FBSDK_ACCESSTOKEN_USERID_KEY];
|
||||
[encoder encodeObject:self.expirationDate forKey:FBSDK_ACCESSTOKEN_EXPIRATIONDATE_KEY];
|
||||
[encoder encodeObject:self.refreshDate forKey:FBSDK_ACCESSTOKEN_REFRESHDATE_KEY];
|
||||
[encoder encodeObject:self.dataAccessExpirationDate forKey:FBSDK_ACCESSTOKEN_DATA_EXPIRATIONDATE_KEY];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -18,6 +18,10 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
#import <WebKit/WebKit.h>
|
||||
#endif
|
||||
|
||||
#import <FBSDKCoreKit/FBSDKGraphRequestConnection.h>
|
||||
|
||||
#import "FBSDKMacros.h"
|
||||
@ -51,6 +55,45 @@ typedef NS_ENUM(NSUInteger, FBSDKAppEventsFlushBehavior)
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
NS_ENUM(NSUInteger, FBSDKProductAvailability)
|
||||
Specifies product availability for Product Catalog product item update
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, FBSDKProductAvailability)
|
||||
{
|
||||
/**
|
||||
* Item ships immediately
|
||||
*/
|
||||
FBSDKProductAvailabilityInStock = 0,
|
||||
/**
|
||||
* No plan to restock
|
||||
*/
|
||||
FBSDKProductAvailabilityOutOfStock,
|
||||
/**
|
||||
* Available in future
|
||||
*/
|
||||
FBSDKProductAvailabilityPreOrder,
|
||||
/**
|
||||
* Ships in 1-2 weeks
|
||||
*/
|
||||
FBSDKProductAvailabilityAvailableForOrder,
|
||||
/**
|
||||
* Discontinued
|
||||
*/
|
||||
FBSDKProductAvailabilityDiscontinued,
|
||||
};
|
||||
|
||||
/**
|
||||
NS_ENUM(NSUInteger, FBSDKProductCondition)
|
||||
Specifies product condition for Product Catalog product item update
|
||||
*/
|
||||
typedef NS_ENUM(NSUInteger, FBSDKProductCondition)
|
||||
{
|
||||
FBSDKProductConditionNew = 0,
|
||||
FBSDKProductConditionRefurbished,
|
||||
FBSDKProductConditionUsed,
|
||||
};
|
||||
|
||||
/**
|
||||
@methodgroup Predefined event names for logging events common to many apps. Logging occurs through the `logEvent` family of methods on `FBSDKAppEvents`.
|
||||
Common event parameters are provided in the `FBSDKAppEventsParameterNames*` constants.
|
||||
@ -92,6 +135,36 @@ FBSDK_EXTERN NSString *const FBSDKAppEventNameUnlockedAchievement;
|
||||
/** Log this event when a user has viewed a form of content in the app. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameViewedContent;
|
||||
|
||||
/** A telephone/SMS, email, chat or other type of contact between a customer and your business. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameContact;
|
||||
|
||||
/** The customization of products through a configuration tool or other application your business owns. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameCustomizeProduct;
|
||||
|
||||
/** The donation of funds to your organization or cause. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameDonate;
|
||||
|
||||
/** When a person finds one of your locations via web or application, with an intention to visit (example: find product at a local store). */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameFindLocation;
|
||||
|
||||
/** The booking of an appointment to visit one of your locations. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameSchedule;
|
||||
|
||||
/** The start of a free trial of a product or service you offer (example: trial subscription). */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameStartTrial;
|
||||
|
||||
/** The submission of an application for a product, service or program you offer (example: credit card, educational program or job).. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameSubmitApplication;
|
||||
|
||||
/** The start of a paid subscription for a product or service you offer. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameSubscribe;
|
||||
|
||||
/** Log this event when the user views an ad. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameAdImpression;
|
||||
|
||||
/** Log this event when the user clicks an ad. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventNameAdClick;
|
||||
|
||||
/**
|
||||
@methodgroup Predefined event name parameters for common additional information to accompany events logged through the `logEvent` family
|
||||
of methods on `FBSDKAppEvents`. Common event names are provided in the `FBAppEventName*` constants.
|
||||
@ -149,6 +222,14 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueYes;
|
||||
/** No-valued parameter value to be used with parameter keys that need a Yes/No value */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
|
||||
/** Parameter key used to specify the type of ad in an FBSDKAppEventNameAdImpression
|
||||
* or FBSDKAppEventNameAdClick event.
|
||||
* E.g. "banner", "interstitial", "rewarded_video", "native" */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventParameterNameAdType;
|
||||
|
||||
/** Parameter key used to specify the unique ID for all events within a subscription
|
||||
* in an FBSDKAppEventNameSubscribe or FBSDKAppEventNameStartTrial event. */
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventParameterNameOrderID;
|
||||
|
||||
/**
|
||||
|
||||
@ -209,7 +290,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
|
||||
Log an event with just an eventName.
|
||||
|
||||
- Parameter eventName: The name of the event to record. Limitations on number of events and name length
|
||||
@param eventName The name of the event to record. Limitations on number of events and name length
|
||||
are given in the `FBSDKAppEvents` documentation.
|
||||
|
||||
*/
|
||||
@ -219,10 +300,10 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
|
||||
Log an event with an eventName and a numeric value to be aggregated with other events of this name.
|
||||
|
||||
- Parameter eventName: The name of the event to record. Limitations on number of events and name length
|
||||
@param eventName The name of the event to record. Limitations on number of events and name length
|
||||
are given in the `FBSDKAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
|
||||
|
||||
- Parameter valueToSum: Amount to be aggregated into all events of this eventName, and App Insights will report
|
||||
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
|
||||
the cumulative and average value of this amount.
|
||||
*/
|
||||
+ (void)logEvent:(NSString *)eventName
|
||||
@ -234,10 +315,10 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
Log an event with an eventName and a set of key/value pairs in the parameters dictionary.
|
||||
Parameter limitations are described above.
|
||||
|
||||
- Parameter eventName: The name of the event to record. Limitations on number of events and name construction
|
||||
@param eventName The name of the event to record. Limitations on number of events and name construction
|
||||
are given in the `FBSDKAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
|
||||
|
||||
- Parameter parameters: Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
|
||||
parameters and name construction are given in the `FBSDKAppEvents` documentation. Commonly used parameter names
|
||||
are provided in `FBSDKAppEventParameterName*` constants.
|
||||
@ -250,13 +331,13 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
Log an event with an eventName, a numeric value to be aggregated with other events of this name,
|
||||
and a set of key/value pairs in the parameters dictionary.
|
||||
|
||||
- Parameter eventName: The name of the event to record. Limitations on number of events and name construction
|
||||
@param eventName The name of the event to record. Limitations on number of events and name construction
|
||||
are given in the `FBSDKAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
|
||||
|
||||
- Parameter valueToSum: Amount to be aggregated into all events of this eventName, and App Insights will report
|
||||
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
|
||||
the cumulative and average value of this amount.
|
||||
|
||||
- Parameter parameters: Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
|
||||
parameters and name construction are given in the `FBSDKAppEvents` documentation. Commonly used parameter names
|
||||
are provided in `FBSDKAppEventParameterName*` constants.
|
||||
@ -273,19 +354,19 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
and a set of key/value pairs in the parameters dictionary. Providing session lets the developer
|
||||
target a particular <FBSession>. If nil is provided, then `[FBSession activeSession]` will be used.
|
||||
|
||||
- Parameter eventName: The name of the event to record. Limitations on number of events and name construction
|
||||
@param eventName The name of the event to record. Limitations on number of events and name construction
|
||||
are given in the `FBSDKAppEvents` documentation. Common event names are provided in `FBAppEventName*` constants.
|
||||
|
||||
- Parameter valueToSum: Amount to be aggregated into all events of this eventName, and App Insights will report
|
||||
@param valueToSum Amount to be aggregated into all events of this eventName, and App Insights will report
|
||||
the cumulative and average value of this amount. Note that this is an NSNumber, and a value of `nil` denotes
|
||||
that this event doesn't have a value associated with it for summation.
|
||||
|
||||
- Parameter parameters: Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
|
||||
parameters and name construction are given in the `FBSDKAppEvents` documentation. Commonly used parameter names
|
||||
are provided in `FBSDKAppEventParameterName*` constants.
|
||||
|
||||
- Parameter accessToken: The optional access token to log the event as.
|
||||
@param accessToken The optional access token to log the event as.
|
||||
*/
|
||||
+ (void)logEvent:(NSString *)eventName
|
||||
valueToSum:(NSNumber *)valueToSum
|
||||
@ -300,10 +381,10 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
|
||||
Log a purchase of the specified amount, in the specified currency.
|
||||
|
||||
- Parameter purchaseAmount: Purchase amount to be logged, as expressed in the specified currency. This value
|
||||
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency. This value
|
||||
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
|
||||
|
||||
- Parameter currency: Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
|
||||
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
|
||||
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
|
||||
|
||||
|
||||
@ -319,13 +400,13 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
Log a purchase of the specified amount, in the specified currency, also providing a set of
|
||||
additional characteristics describing the purchase.
|
||||
|
||||
- Parameter purchaseAmount: Purchase amount to be logged, as expressed in the specified currency.This value
|
||||
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency.This value
|
||||
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
|
||||
|
||||
- Parameter currency: Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
|
||||
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
|
||||
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
|
||||
|
||||
- Parameter parameters: Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
|
||||
parameters and name construction are given in the `FBSDKAppEvents` documentation. Commonly used parameter names
|
||||
are provided in `FBSDKAppEventParameterName*` constants.
|
||||
@ -344,18 +425,18 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
Log a purchase of the specified amount, in the specified currency, also providing a set of
|
||||
additional characteristics describing the purchase, as well as an <FBSession> to log to.
|
||||
|
||||
- Parameter purchaseAmount: Purchase amount to be logged, as expressed in the specified currency.This value
|
||||
@param purchaseAmount Purchase amount to be logged, as expressed in the specified currency.This value
|
||||
will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
|
||||
|
||||
- Parameter currency: Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
|
||||
@param currency Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for
|
||||
specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>.
|
||||
|
||||
- Parameter parameters: Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
@param parameters Arbitrary parameter dictionary of characteristics. The keys to this dictionary must
|
||||
be NSString's, and the values are expected to be NSString or NSNumber. Limitations on the number of
|
||||
parameters and name construction are given in the `FBSDKAppEvents` documentation. Commonly used parameter names
|
||||
are provided in `FBSDKAppEventParameterName*` constants.
|
||||
|
||||
- Parameter accessToken: The optional access token to log the event as.
|
||||
@param accessToken The optional access token to log the event as.
|
||||
|
||||
|
||||
This event immediately triggers a flush of the `FBSDKAppEvents` event queue, unless the `flushBehavior` is set
|
||||
@ -375,18 +456,58 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
/**
|
||||
Log an app event that tracks that the application was open via Push Notification.
|
||||
|
||||
- Parameter payload: Notification payload received via `UIApplicationDelegate`.
|
||||
@param payload Notification payload received via `UIApplicationDelegate`.
|
||||
*/
|
||||
+ (void)logPushNotificationOpen:(NSDictionary *)payload;
|
||||
|
||||
/**
|
||||
Log an app event that tracks that a custom action was taken from a push notification.
|
||||
|
||||
- Parameter payload: Notification payload received via `UIApplicationDelegate`.
|
||||
- Parameter action: Name of the action that was taken.
|
||||
@param payload Notification payload received via `UIApplicationDelegate`.
|
||||
@param action Name of the action that was taken.
|
||||
*/
|
||||
+ (void)logPushNotificationOpen:(NSDictionary *)payload action:(NSString *)action;
|
||||
|
||||
/**
|
||||
Uploads product catalog product item as an app event
|
||||
@param itemID Unique ID for the item. Can be a variant for a product.
|
||||
Max size is 100.
|
||||
@param availability If item is in stock. Accepted values are:
|
||||
in stock - Item ships immediately
|
||||
out of stock - No plan to restock
|
||||
preorder - Available in future
|
||||
available for order - Ships in 1-2 weeks
|
||||
discontinued - Discontinued
|
||||
@param condition Product condition: new, refurbished or used.
|
||||
@param description Short text describing product. Max size is 5000.
|
||||
@param imageLink Link to item image used in ad.
|
||||
@param link Link to merchant's site where someone can buy the item.
|
||||
@param title Title of item.
|
||||
@param priceAmount Amount of purchase, in the currency specified by the 'currency'
|
||||
parameter. This value will be rounded to the thousandths place
|
||||
(e.g., 12.34567 becomes 12.346).
|
||||
@param currency Currency used to specify the amount.
|
||||
E.g. "USD", "EUR", "GBP". See ISO-4217 for specific values. One reference for these is <http://en.wikipedia.org/wiki/ISO_4217>
|
||||
@param gtin Global Trade Item Number including UPC, EAN, JAN and ISBN
|
||||
@param mpn Unique manufacture ID for product
|
||||
@param brand Name of the brand
|
||||
Note: Either gtin, mpn or brand is required.
|
||||
@param parameters Optional fields for deep link specification.
|
||||
*/
|
||||
+ (void)logProductItem:(NSString *)itemID
|
||||
availability:(FBSDKProductAvailability)availability
|
||||
condition:(FBSDKProductCondition)condition
|
||||
description:(NSString *)description
|
||||
imageLink:(NSString *)imageLink
|
||||
link:(NSString *)link
|
||||
title:(NSString *)title
|
||||
priceAmount:(double)priceAmount
|
||||
currency:(NSString *)currency
|
||||
gtin:(NSString *)gtin
|
||||
mpn:(NSString *)mpn
|
||||
brand:(NSString *)brand
|
||||
parameters:(NSDictionary *)parameters;
|
||||
|
||||
/**
|
||||
|
||||
Notifies the events system that the app has launched and, when appropriate, logs an "activated app" event.
|
||||
@ -419,7 +540,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
|
||||
Sets and sends a device token from `NSData` representation that you get from `UIApplicationDelegate.-application:didRegisterForRemoteNotificationsWithDeviceToken:`.
|
||||
|
||||
- Parameter deviceToken: Device token data.
|
||||
@param deviceToken Device token data.
|
||||
*/
|
||||
+ (void)setPushNotificationsDeviceToken:(NSData *)deviceToken;
|
||||
|
||||
@ -437,7 +558,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
|
||||
Set the current event flushing behavior specifying when events are sent back to Facebook servers.
|
||||
|
||||
- Parameter flushBehavior: The desired `FBSDKAppEventsFlushBehavior` to be used.
|
||||
@param flushBehavior The desired `FBSDKAppEventsFlushBehavior` to be used.
|
||||
*/
|
||||
+ (void)setFlushBehavior:(FBSDKAppEventsFlushBehavior)flushBehavior;
|
||||
|
||||
@ -454,7 +575,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
This should be set before any other calls are made to `FBSDKAppEvents`. Thus, you should set it in your application
|
||||
delegate's `application:didFinishLaunchingWithOptions:` delegate.
|
||||
|
||||
- Parameter appID: The Facebook App ID to be used for App Event logging.
|
||||
@param appID The Facebook App ID to be used for App Event logging.
|
||||
*/
|
||||
+ (void)setLoggingOverrideAppID:(NSString *)appID;
|
||||
|
||||
@ -462,7 +583,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
Get the 'override' App ID for App Event logging.
|
||||
|
||||
|
||||
- See:setLoggingOverrideAppID:
|
||||
@see setLoggingOverrideAppID:
|
||||
|
||||
*/
|
||||
+ (NSString *)loggingOverrideAppID;
|
||||
@ -479,7 +600,7 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
Callers will send this ID back to their own servers, collect up a set to create a Facebook Custom Audience with,
|
||||
and then use the resultant Custom Audience to target ads.
|
||||
|
||||
- Parameter accessToken: The access token to use to establish the user's identity for users logged into Facebook through this app.
|
||||
@param accessToken The access token to use to establish the user's identity for users logged into Facebook through this app.
|
||||
If `nil`, then the `[FBSDKAccessToken currentAccessToken]` is used.
|
||||
|
||||
|
||||
@ -506,18 +627,96 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterValueNo;
|
||||
*/
|
||||
+ (void)setUserID:(NSString *)userID;
|
||||
|
||||
/*
|
||||
Clears the custom user ID to associate with all app events.
|
||||
*/
|
||||
+ (void)clearUserID;
|
||||
|
||||
/*
|
||||
Returns the set custom user ID.
|
||||
*/
|
||||
+ (NSString *)userID;
|
||||
|
||||
/*
|
||||
Sets custom user data to associate with all app events. All user data are hashed
|
||||
and used to match Facebook user from this instance of an application.
|
||||
|
||||
The user data will be persisted between application instances.
|
||||
|
||||
@param userData user data to identify the user. User data should be formated as
|
||||
a NSDictionary of data type name and value.
|
||||
Supported data types and names are:
|
||||
Email: em
|
||||
First Name: fn
|
||||
Last Name: ln
|
||||
Phone: ph
|
||||
Date of Birth: db
|
||||
Gender: ge
|
||||
City: ct
|
||||
State: st
|
||||
Zip: zp
|
||||
Country: country
|
||||
*/
|
||||
+ (void)setUserData:(NSDictionary *)userData
|
||||
DEPRECATED_MSG_ATTRIBUTE("Renamed `setUserEmail:firstName: ...`");
|
||||
|
||||
/*
|
||||
Sets custom user data to associate with all app events. All user data are hashed
|
||||
and used to match Facebook user from this instance of an application.
|
||||
|
||||
The user data will be persisted between application instances.
|
||||
|
||||
@param email user's email
|
||||
@param firstName user's first name
|
||||
@param lastName user's last name
|
||||
@param phone user's phone
|
||||
@param dateOfBirth user's date of birth
|
||||
@param gender user's gender
|
||||
@param city user's city
|
||||
@param state user's state
|
||||
@param zip user's zip
|
||||
@param country user's country
|
||||
*/
|
||||
+ (void)setUserEmail:(nullable NSString *)email
|
||||
firstName:(nullable NSString *)firstName
|
||||
lastName:(nullable NSString *)lastName
|
||||
phone:(nullable NSString *)phone
|
||||
dateOfBirth:(nullable NSString *)dateOfBirth
|
||||
gender:(nullable NSString *)gender
|
||||
city:(nullable NSString *)city
|
||||
state:(nullable NSString *)state
|
||||
zip:(nullable NSString *)zip
|
||||
country:(nullable NSString *)country;
|
||||
/*
|
||||
Returns the set user data else nil
|
||||
*/
|
||||
+ (NSString *)getUserData;
|
||||
|
||||
/*
|
||||
Clears the current user data
|
||||
*/
|
||||
+ (void)clearUserData;
|
||||
|
||||
/*
|
||||
Sends a request to update the properties for the current user, set by `setUserID:`
|
||||
|
||||
You must call `FBSDKAppEvents setUserID:` before making this call.
|
||||
- Parameter properties: the custom user properties
|
||||
- Parameter handler: the optional completion handler
|
||||
@param properties the custom user properties
|
||||
@param handler the optional completion handler
|
||||
*/
|
||||
+ (void)updateUserProperties:(NSDictionary *)properties handler:(FBSDKGraphRequestHandler)handler;
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
/*
|
||||
Intended to be used as part of a hybrid webapp.
|
||||
If you call this method, the FB SDK will inject a new JavaScript object into your webview.
|
||||
If the FB Pixel is used within the webview, and references the app ID of this app,
|
||||
then it will detect the presence of this injected JavaScript object
|
||||
and pass Pixel events back to the FB SDK for logging using the AppEvents framework.
|
||||
|
||||
@param webView The webview to augment with the additional JavaScript behaviour
|
||||
*/
|
||||
+ (void)augmentHybridWKWebView:(WKWebView *)webView;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#import "FBSDKAppEventsStateManager.h"
|
||||
#import "FBSDKAppEventsUtility.h"
|
||||
#import "FBSDKConstants.h"
|
||||
#import "FBSDKDynamicFrameworkLoader.h"
|
||||
#import "FBSDKError.h"
|
||||
#import "FBSDKGraphRequest+Internal.h"
|
||||
#import "FBSDKInternalUtility.h"
|
||||
@ -36,6 +37,12 @@
|
||||
#import "FBSDKSettings.h"
|
||||
#import "FBSDKTimeSpentData.h"
|
||||
#import "FBSDKUtility.h"
|
||||
#import "FBSDKUserDataStore.h"
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
#import "FBSDKEventBindingManager.h"
|
||||
#import "FBSDKHybridAppEventsScriptMessageHandler.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Public event names
|
||||
@ -47,13 +54,23 @@ NSString *const FBSDKAppEventNameViewedContent = @"fb_mobile_content_v
|
||||
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 FBSDKAppEventNameContact = @"Contact";
|
||||
NSString *const FBSDKAppEventNameCustomizeProduct = @"CustomizeProduct";
|
||||
NSString *const FBSDKAppEventNameDonate = @"Donate";
|
||||
NSString *const FBSDKAppEventNameFindLocation = @"FindLocation";
|
||||
NSString *const FBSDKAppEventNameSchedule = @"Schedule";
|
||||
NSString *const FBSDKAppEventNameStartTrial = @"StartTrial";
|
||||
NSString *const FBSDKAppEventNameSubmitApplication = @"SubmitApplication";
|
||||
NSString *const FBSDKAppEventNameSubscribe = @"Subscribe";
|
||||
NSString *const FBSDKAppEventNameAdImpression = @"AdImpression";
|
||||
NSString *const FBSDKAppEventNameAdClick = @"AdClick";
|
||||
|
||||
// Ecommerce related
|
||||
NSString *const FBSDKAppEventNameAddedToCart = @"fb_mobile_add_to_cart";
|
||||
NSString *const FBSDKAppEventNameAddedToWishlist = @"fb_mobile_add_to_wishlist";
|
||||
NSString *const FBSDKAppEventNameInitiatedCheckout = @"fb_mobile_initiated_checkout";
|
||||
NSString *const FBSDKAppEventNameAddedPaymentInfo = @"fb_mobile_add_payment_info";
|
||||
NSString *const FBSDKAppEventNameProductCatalogUpdate = @"fb_mobile_catalog_update";
|
||||
|
||||
// Gaming related
|
||||
NSString *const FBSDKAppEventNameAchievedLevel = @"fb_mobile_level_achieved";
|
||||
@ -76,6 +93,9 @@ NSString *const FBSDKAppEventParameterNamePaymentInfoAvailable = @"fb_payment_
|
||||
NSString *const FBSDKAppEventParameterNameNumItems = @"fb_num_items";
|
||||
NSString *const FBSDKAppEventParameterNameLevel = @"fb_level";
|
||||
NSString *const FBSDKAppEventParameterNameDescription = @"fb_description";
|
||||
NSString *const FBSDKAppEventParameterLaunchSource = @"fb_mobile_launch_source";
|
||||
NSString *const FBSDKAppEventParameterNameAdType = @"ad_type";
|
||||
NSString *const FBSDKAppEventParameterNameOrderID = @"fb_order_id";
|
||||
|
||||
//
|
||||
// Public event parameter values
|
||||
@ -181,6 +201,19 @@ NSString *const FBSDKAppEventParameterLiveStreamingVideoID = @"live_stream
|
||||
NSString *const FBSDKAppEventParameterLiveStreamingMicEnabled = @"live_streaming_mic_enabled";
|
||||
NSString *const FBSDKAppEventParameterLiveStreamingCameraEnabled = @"live_streaming_camera_enabled";
|
||||
|
||||
NSString *const FBSDKAppEventParameterProductItemID = @"fb_product_item_id";
|
||||
NSString *const FBSDKAppEventParameterProductAvailability = @"fb_product_availability";
|
||||
NSString *const FBSDKAppEventParameterProductCondition = @"fb_product_condition";
|
||||
NSString *const FBSDKAppEventParameterProductDescription = @"fb_product_description";
|
||||
NSString *const FBSDKAppEventParameterProductImageLink = @"fb_product_image_link";
|
||||
NSString *const FBSDKAppEventParameterProductLink = @"fb_product_link";
|
||||
NSString *const FBSDKAppEventParameterProductTitle = @"fb_product_title";
|
||||
NSString *const FBSDKAppEventParameterProductGTIN = @"fb_product_gtin";
|
||||
NSString *const FBSDKAppEventParameterProductMPN = @"fb_product_mpn";
|
||||
NSString *const FBSDKAppEventParameterProductBrand = @"fb_product_brand";
|
||||
NSString *const FBSDKAppEventParameterProductPriceAmount = @"fb_product_price_amount";
|
||||
NSString *const FBSDKAppEventParameterProductPriceCurrency = @"fb_product_price_currency";
|
||||
|
||||
// Event parameter values internal to this file
|
||||
NSString *const FBSDKAppEventsDialogOutcomeValue_Completed = @"Completed";
|
||||
NSString *const FBSDKAppEventsDialogOutcomeValue_Cancelled = @"Cancelled";
|
||||
@ -224,9 +257,18 @@ static NSString *const FBSDKAppEventParameterPushAction = @"fb_push_action";
|
||||
static NSString *const FBSDKAppEventsPushPayloadKey = @"fb_push_payload";
|
||||
static NSString *const FBSDKAppEventsPushPayloadCampaignKey = @"campaign";
|
||||
|
||||
//
|
||||
// Augmentation of web browser constants
|
||||
//
|
||||
NSString *const FBSDKAppEventsWKWebViewMessagesPixelIDKey = @"pixelID";
|
||||
NSString *const FBSDKAppEventsWKWebViewMessagesHandlerKey = @"fbmqHandler";
|
||||
NSString *const FBSDKAppEventsWKWebViewMessagesEventKey = @"event";
|
||||
NSString *const FBSDKAppEventsWKWebViewMessagesParamsKey = @"params";
|
||||
NSString *const FBSDKAPPEventsWKWebViewMessagesProtocolKey = @"fbmq-0.1";
|
||||
|
||||
|
||||
#define NUM_LOG_EVENTS_TO_TRY_TO_FLUSH_AFTER 100
|
||||
#define FLUSH_PERIOD_IN_SECONDS 15
|
||||
#define APP_SUPPORTS_ATTRIBUTION_ID_RECHECK_PERIOD 60 * 60 * 24
|
||||
#define USER_ID_USER_DEFAULTS_KEY @"com.facebook.sdk.appevents.userid"
|
||||
|
||||
static NSString *g_overrideAppID = nil;
|
||||
@ -240,7 +282,6 @@ static NSString *g_overrideAppID = nil;
|
||||
@property (nonatomic, copy) NSString *pushNotificationsDeviceTokenString;
|
||||
|
||||
@property (nonatomic, strong) dispatch_source_t flushTimer;
|
||||
@property (nonatomic, strong) dispatch_source_t attributionIDRecheckTimer;
|
||||
|
||||
@end
|
||||
|
||||
@ -249,6 +290,9 @@ static NSString *g_overrideAppID = nil;
|
||||
BOOL _explicitEventsLoggedYet;
|
||||
FBSDKServerConfiguration *_serverConfiguration;
|
||||
FBSDKAppEventsState *_appEventsState;
|
||||
#if !TARGET_OS_TV
|
||||
FBSDKEventBindingManager *_eventBindingManager;
|
||||
#endif
|
||||
NSString *_userID;
|
||||
}
|
||||
|
||||
@ -273,29 +317,6 @@ static NSString *g_overrideAppID = nil;
|
||||
[weakSelf flushTimerFired:nil];
|
||||
}];
|
||||
|
||||
self.attributionIDRecheckTimer = [FBSDKUtility startGCDTimerWithInterval:APP_SUPPORTS_ATTRIBUTION_ID_RECHECK_PERIOD
|
||||
block:^{
|
||||
[weakSelf appSettingsFetchStateResetTimerFired:nil];
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationMovingFromActiveStateOrTerminating)
|
||||
name:UIApplicationWillResignActiveNotification
|
||||
object:NULL];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationMovingFromActiveStateOrTerminating)
|
||||
name:UIApplicationWillTerminateNotification
|
||||
object:NULL];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationDidBecomeActive)
|
||||
name:UIApplicationDidBecomeActiveNotification
|
||||
object:NULL];
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
_userID = [defaults stringForKey:USER_ID_USER_DEFAULTS_KEY];
|
||||
}
|
||||
@ -303,11 +324,30 @@ static NSString *g_overrideAppID = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)registerNotifications {
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationMovingFromActiveStateOrTerminating)
|
||||
name:UIApplicationWillResignActiveNotification
|
||||
object:NULL];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationMovingFromActiveStateOrTerminating)
|
||||
name:UIApplicationWillTerminateNotification
|
||||
object:NULL];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationDidBecomeActive)
|
||||
name:UIApplicationDidBecomeActiveNotification
|
||||
object:NULL];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[FBSDKUtility stopGCDTimer:self.flushTimer];
|
||||
[FBSDKUtility stopGCDTimer:self.attributionIDRecheckTimer];
|
||||
}
|
||||
|
||||
#pragma mark - Public Methods
|
||||
@ -432,6 +472,109 @@ static NSString *g_overrideAppID = nil;
|
||||
[self logEvent:FBSDKAppEventNamePushOpened parameters:parameters];
|
||||
}
|
||||
|
||||
/*
|
||||
* Uploads product catalog product item as an app event
|
||||
*/
|
||||
+ (void)logProductItem:(NSString *)itemID
|
||||
availability:(FBSDKProductAvailability)availability
|
||||
condition:(FBSDKProductCondition)condition
|
||||
description:(NSString *)description
|
||||
imageLink:(NSString *)imageLink
|
||||
link:(NSString *)link
|
||||
title:(NSString *)title
|
||||
priceAmount:(double)priceAmount
|
||||
currency:(NSString *)currency
|
||||
gtin:(NSString *)gtin
|
||||
mpn:(NSString *)mpn
|
||||
brand:(NSString *)brand
|
||||
parameters:(NSDictionary *)parameters {
|
||||
if (itemID == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"itemID cannot be null"];
|
||||
return;
|
||||
} else if (description == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"description cannot be null"];
|
||||
return;
|
||||
} else if (imageLink == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"imageLink cannot be null"];
|
||||
return;
|
||||
} else if (link == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"link cannot be null"];
|
||||
return;
|
||||
} else if (title == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"title cannot be null"];
|
||||
return;
|
||||
} else if (currency == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"currency cannot be null"];
|
||||
return;
|
||||
} else if (gtin == nil && mpn == nil && brand == nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"Either gtin, mpn or brand is required"];
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
if (nil != parameters) {
|
||||
[dict setValuesForKeysWithDictionary:parameters];
|
||||
}
|
||||
|
||||
[dict setObject:itemID forKey:FBSDKAppEventParameterProductItemID];
|
||||
|
||||
NSString *avail = nil;
|
||||
switch (availability) {
|
||||
case FBSDKProductAvailabilityInStock:
|
||||
avail = @"IN_STOCK"; break;
|
||||
case FBSDKProductAvailabilityOutOfStock:
|
||||
avail = @"OUT_OF_STOCK"; break;
|
||||
case FBSDKProductAvailabilityPreOrder:
|
||||
avail = @"PREORDER"; break;
|
||||
case FBSDKProductAvailabilityAvailableForOrder:
|
||||
avail = @"AVALIABLE_FOR_ORDER"; break;
|
||||
case FBSDKProductAvailabilityDiscontinued:
|
||||
avail = @"DISCONTINUED"; break;
|
||||
}
|
||||
if (avail) {
|
||||
[dict setObject:avail forKey:FBSDKAppEventParameterProductAvailability];
|
||||
}
|
||||
|
||||
NSString *cond = nil;
|
||||
switch (condition) {
|
||||
case FBSDKProductConditionNew:
|
||||
cond = @"NEW"; break;
|
||||
case FBSDKProductConditionRefurbished:
|
||||
cond = @"REFURBISHED"; break;
|
||||
case FBSDKProductConditionUsed:
|
||||
cond = @"USED"; break;
|
||||
}
|
||||
if (cond) {
|
||||
[dict setObject:cond forKey:FBSDKAppEventParameterProductCondition];
|
||||
}
|
||||
|
||||
[dict setObject:description forKey:FBSDKAppEventParameterProductDescription];
|
||||
[dict setObject:imageLink forKey:FBSDKAppEventParameterProductImageLink];
|
||||
[dict setObject:link forKey:FBSDKAppEventParameterProductLink];
|
||||
[dict setObject:title forKey:FBSDKAppEventParameterProductTitle];
|
||||
[dict setObject:[NSString stringWithFormat:@"%.3lf", priceAmount] forKey:FBSDKAppEventParameterProductPriceAmount];
|
||||
[dict setObject:currency forKey:FBSDKAppEventParameterProductPriceCurrency];
|
||||
if (gtin) {
|
||||
[dict setObject:gtin forKey:FBSDKAppEventParameterProductGTIN];
|
||||
}
|
||||
if (mpn) {
|
||||
[dict setObject:mpn forKey:FBSDKAppEventParameterProductMPN];
|
||||
}
|
||||
if (brand) {
|
||||
[dict setObject:brand forKey:FBSDKAppEventParameterProductBrand];
|
||||
}
|
||||
|
||||
[FBSDKAppEvents logEvent:FBSDKAppEventNameProductCatalogUpdate
|
||||
parameters:dict];
|
||||
}
|
||||
|
||||
+ (void)activateApp
|
||||
{
|
||||
[FBSDKAppEventsUtility ensureOnMainThread:NSStringFromSelector(_cmd) className:NSStringFromClass(self)];
|
||||
@ -446,6 +589,7 @@ static NSString *g_overrideAppID = nil;
|
||||
// when appropriate, result in logging an "activated app" and "deactivated app" (for the
|
||||
// previous session) App Event.
|
||||
[FBSDKTimeSpentData restore:YES];
|
||||
[FBSDKUserDataStore initStore];
|
||||
}
|
||||
|
||||
+ (void)setPushNotificationsDeviceToken:(NSData *)deviceToken
|
||||
@ -509,11 +653,63 @@ static NSString *g_overrideAppID = nil;
|
||||
[defaults synchronize];
|
||||
}
|
||||
|
||||
+ (void)clearUserID
|
||||
{
|
||||
[self setUserID:nil];
|
||||
}
|
||||
|
||||
+ (NSString *)userID
|
||||
{
|
||||
return [[self class] singleton]->_userID;
|
||||
}
|
||||
|
||||
+ (void)setUserData:(NSDictionary*)userData
|
||||
{
|
||||
[FBSDKUserDataStore setUserDataAndHash:userData];
|
||||
}
|
||||
|
||||
+ (void)setUserEmail:(nullable NSString *)email
|
||||
firstName:(nullable NSString *)firstName
|
||||
lastName:(nullable NSString *)lastName
|
||||
phone:(nullable NSString *)phone
|
||||
dateOfBirth:(nullable NSString *)dateOfBirth
|
||||
gender:(nullable NSString *)gender
|
||||
city:(nullable NSString *)city
|
||||
state:(nullable NSString *)state
|
||||
zip:(nullable NSString *)zip
|
||||
country:(nullable NSString *)country
|
||||
{
|
||||
[FBSDKUserDataStore setUserDataAndHash:email
|
||||
firstName:firstName
|
||||
lastName:lastName
|
||||
phone:phone
|
||||
dateOfBirth:dateOfBirth
|
||||
gender:gender
|
||||
city:city
|
||||
state:state
|
||||
zip:zip
|
||||
country:country];
|
||||
}
|
||||
|
||||
+ (NSString*)getUserData
|
||||
{
|
||||
return [FBSDKUserDataStore getHashedUserData];
|
||||
}
|
||||
|
||||
+ (void)clearUserData
|
||||
{
|
||||
[FBSDKUserDataStore setUserDataAndHash:nil
|
||||
firstName:nil
|
||||
lastName:nil
|
||||
phone:nil
|
||||
dateOfBirth:nil
|
||||
gender:nil
|
||||
city:nil
|
||||
state:nil
|
||||
zip:nil
|
||||
country:nil];
|
||||
}
|
||||
|
||||
+ (void)updateUserProperties:(NSDictionary *)properties handler:(FBSDKGraphRequestHandler)handler
|
||||
{
|
||||
NSString *userID = [[self class] userID];
|
||||
@ -560,6 +756,35 @@ static NSString *g_overrideAppID = nil;
|
||||
[request startWithCompletionHandler:handler];
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
+ (void)augmentHybridWKWebView:(WKWebView *)webView {
|
||||
// Ensure we can instantiate WebKit before trying this
|
||||
Class WKWebViewClass = fbsdkdfl_WKWebViewClass();
|
||||
if (WKWebViewClass != nil && [webView isKindOfClass:WKWebViewClass]) {
|
||||
Class WKUserScriptClass = fbsdkdfl_WKUserScriptClass();
|
||||
if (WKUserScriptClass != nil) {
|
||||
WKUserContentController *controller = webView.configuration.userContentController;
|
||||
FBSDKHybridAppEventsScriptMessageHandler *scriptHandler = [[FBSDKHybridAppEventsScriptMessageHandler alloc] init];
|
||||
[controller addScriptMessageHandler:scriptHandler name:FBSDKAppEventsWKWebViewMessagesHandlerKey];
|
||||
|
||||
NSString *js = [NSString stringWithFormat:@"window.fbmq_%@={'sendEvent': function(pixel_id,event_name,custom_data){var msg={\"%@\":pixel_id, \"%@\":event_name,\"%@\":custom_data};window.webkit.messageHandlers[\"%@\"].postMessage(msg);}, 'getProtocol':function(){return \"%@\";}}",
|
||||
[[self singleton] appID],
|
||||
FBSDKAppEventsWKWebViewMessagesPixelIDKey,
|
||||
FBSDKAppEventsWKWebViewMessagesEventKey,
|
||||
FBSDKAppEventsWKWebViewMessagesParamsKey,
|
||||
FBSDKAppEventsWKWebViewMessagesHandlerKey,
|
||||
FBSDKAPPEventsWKWebViewMessagesProtocolKey
|
||||
];
|
||||
|
||||
[controller addUserScript:[[WKUserScriptClass alloc] initWithSource:js injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
[FBSDKAppEventsUtility logAndNotify:@"You must call augmentHybridWKWebView with WebKit linked to your project and a WKWebView instance"];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma mark - Internal Methods
|
||||
|
||||
+ (void)logImplicitEvent:(NSString *)eventName
|
||||
@ -624,7 +849,7 @@ static NSString *g_overrideAppID = nil;
|
||||
[self fetchServerConfiguration:^{
|
||||
NSDictionary *params = [FBSDKAppEventsUtility activityParametersDictionaryForEvent:@"MOBILE_APP_INSTALL"
|
||||
implicitEventsOnly:NO
|
||||
shouldAccessAdvertisingID:_serverConfiguration.isAdvertisingIDEnabled];
|
||||
shouldAccessAdvertisingID:self->_serverConfiguration.isAdvertisingIDEnabled];
|
||||
NSString *path = [NSString stringWithFormat:@"%@/activities", appID];
|
||||
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:path
|
||||
parameters:params
|
||||
@ -642,27 +867,38 @@ static NSString *g_overrideAppID = nil;
|
||||
}];
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
- (void)enableCodelessEvents {
|
||||
if (_serverConfiguration.isCodelessEventsEnabled) {
|
||||
if (!_eventBindingManager) {
|
||||
_eventBindingManager = [[FBSDKEventBindingManager alloc] init];
|
||||
[_eventBindingManager start];
|
||||
}
|
||||
|
||||
[_eventBindingManager updateBindings:[FBSDKEventBindingManager
|
||||
parseArray:_serverConfiguration.eventBindings]];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// app events can use a server configuration up to 24 hours old to minimize network traffic.
|
||||
- (void)fetchServerConfiguration:(void (^)(void))callback
|
||||
{
|
||||
if (_serverConfiguration == nil) {
|
||||
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *error) {
|
||||
_serverConfiguration = serverConfiguration;
|
||||
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *error) {
|
||||
self->_serverConfiguration = serverConfiguration;
|
||||
|
||||
if (_serverConfiguration.implicitPurchaseLoggingEnabled) {
|
||||
[FBSDKPaymentObserver startObservingTransactions];
|
||||
} else {
|
||||
[FBSDKPaymentObserver stopObservingTransactions];
|
||||
}
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}];
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
if (self->_serverConfiguration.implicitPurchaseLoggingEnabled) {
|
||||
[FBSDKPaymentObserver startObservingTransactions];
|
||||
} else {
|
||||
[FBSDKPaymentObserver stopObservingTransactions];
|
||||
}
|
||||
#if !TARGET_OS_TV
|
||||
[self enableCodelessEvents];
|
||||
#endif
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)instanceLogEvent:(NSString *)eventName
|
||||
@ -819,7 +1055,7 @@ static NSString *g_overrideAppID = nil;
|
||||
|
||||
[self fetchServerConfiguration:^(void) {
|
||||
NSString *receipt_data = [appEventsState extractReceiptData];
|
||||
NSString *encodedEvents = [appEventsState JSONStringForEvents:_serverConfiguration.implicitLoggingEnabled];
|
||||
NSString *encodedEvents = [appEventsState JSONStringForEvents:self->_serverConfiguration.implicitLoggingEnabled];
|
||||
if (!encodedEvents) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorAppEvents
|
||||
logEntry:@"FBSDKAppEvents: Flushing skipped - no events after removing implicitly logged ones.\n"];
|
||||
@ -828,7 +1064,7 @@ static NSString *g_overrideAppID = nil;
|
||||
NSMutableDictionary *postParameters = [FBSDKAppEventsUtility
|
||||
activityParametersDictionaryForEvent:@"CUSTOM_APP_EVENTS"
|
||||
implicitEventsOnly:appEventsState.areAllEventsImplicit
|
||||
shouldAccessAdvertisingID:_serverConfiguration.advertisingIDEnabled];
|
||||
shouldAccessAdvertisingID:self->_serverConfiguration.advertisingIDEnabled];
|
||||
NSInteger length = [receipt_data length];
|
||||
if (length > 0) {
|
||||
postParameters[@"receipt_data"] = receipt_data;
|
||||
@ -861,6 +1097,7 @@ static NSString *g_overrideAppID = nil;
|
||||
prettyPrintedJsonEvents];
|
||||
}
|
||||
|
||||
[FBSDKAppEventsUtility logAndNotify:[NSString stringWithFormat:@"param %@", postParameters]];
|
||||
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"%@/activities", appEventsState.appID]
|
||||
parameters:postParameters
|
||||
tokenString:appEventsState.tokenString
|
||||
@ -943,11 +1180,6 @@ static NSString *g_overrideAppID = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appSettingsFetchStateResetTimerFired:(id)arg
|
||||
{
|
||||
_serverConfiguration = nil;
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive
|
||||
{
|
||||
[FBSDKAppEventsUtility ensureOnMainThread:NSStringFromSelector(_cmd) className:NSStringFromClass([self class])];
|
||||
|
||||
63
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLink.h
generated
Normal file
63
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLink.h
generated
Normal file
@ -0,0 +1,63 @@
|
||||
// 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>
|
||||
|
||||
#import "FBSDKAppLinkTarget.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*! The version of the App Link protocol that this library supports */
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkVersion;
|
||||
|
||||
/*!
|
||||
Contains App Link metadata relevant for navigation on this device
|
||||
derived from the HTML at a given URL.
|
||||
*/
|
||||
@interface FBSDKAppLink : NSObject
|
||||
|
||||
/*!
|
||||
Creates a FBSDKAppLink with the given list of FBSDKAppLinkTargets and target URL.
|
||||
|
||||
Generally, this will only be used by implementers of the FBSDKAppLinkResolving protocol,
|
||||
as these implementers will produce App Link metadata for a given URL.
|
||||
|
||||
@param sourceURL the URL from which this App Link is derived
|
||||
@param targets an ordered list of FBSDKAppLinkTargets for this platform derived
|
||||
from App Link metadata.
|
||||
@param webURL the fallback web URL, if any, for the app link.
|
||||
*/
|
||||
+ (instancetype)appLinkWithSourceURL:(NSURL *)sourceURL
|
||||
targets:(NSArray<FBSDKAppLinkTarget *> *)targets
|
||||
webURL:(nullable NSURL *)webURL;
|
||||
|
||||
/*! The URL from which this FBSDKAppLink was derived */
|
||||
@property (nonatomic, strong, readonly) NSURL *sourceURL;
|
||||
|
||||
/*!
|
||||
The ordered list of targets applicable to this platform that will be used
|
||||
for navigation.
|
||||
*/
|
||||
@property (nonatomic, copy, readonly) NSArray<FBSDKAppLinkTarget *> *targets;
|
||||
|
||||
/*! The fallback web URL to use if no targets are installed on this device. */
|
||||
@property (nonatomic, strong, readonly, nullable) NSURL *webURL;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
70
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLink.m
generated
Normal file
70
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLink.m
generated
Normal file
@ -0,0 +1,70 @@
|
||||
// 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 "FBSDKAppLink_Internal.h"
|
||||
|
||||
NSString *const FBSDKAppLinkDataParameterName = @"al_applink_data";
|
||||
NSString *const FBSDKAppLinkTargetKeyName = @"target_url";
|
||||
NSString *const FBSDKAppLinkUserAgentKeyName = @"user_agent";
|
||||
NSString *const FBSDKAppLinkExtrasKeyName = @"extras";
|
||||
NSString *const FBSDKAppLinkRefererAppLink = @"referer_app_link";
|
||||
NSString *const FBSDKAppLinkRefererAppName = @"app_name";
|
||||
NSString *const FBSDKAppLinkRefererUrl = @"url";
|
||||
NSString *const FBSDKAppLinkVersionKeyName = @"version";
|
||||
NSString *const FBSDKAppLinkVersion = @"1.0";
|
||||
|
||||
@interface FBSDKAppLink ()
|
||||
|
||||
@property (nonatomic, strong, readwrite) NSURL *sourceURL;
|
||||
@property (nonatomic, copy, readwrite) NSArray<FBSDKAppLinkTarget *> *targets;
|
||||
@property (nonatomic, strong, readwrite) NSURL *webURL;
|
||||
|
||||
@property (nonatomic, assign, readwrite, getter=isBackToReferrer) BOOL backToReferrer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKAppLink
|
||||
|
||||
+ (instancetype)appLinkWithSourceURL:(NSURL *)sourceURL
|
||||
targets:(NSArray<FBSDKAppLinkTarget *> *)targets
|
||||
webURL:(NSURL *)webURL
|
||||
isBackToReferrer:(BOOL)isBackToReferrer {
|
||||
FBSDKAppLink *link = [[self alloc] initWithIsBackToReferrer:isBackToReferrer];
|
||||
link.sourceURL = sourceURL;
|
||||
link.targets = [targets copy];
|
||||
link.webURL = webURL;
|
||||
return link;
|
||||
}
|
||||
|
||||
+ (instancetype)appLinkWithSourceURL:(NSURL *)sourceURL
|
||||
targets:(NSArray<FBSDKAppLinkTarget *> *)targets
|
||||
webURL:(NSURL *)webURL {
|
||||
return [self appLinkWithSourceURL:sourceURL
|
||||
targets:targets
|
||||
webURL:webURL
|
||||
isBackToReferrer:NO];
|
||||
}
|
||||
|
||||
- (FBSDKAppLink *)initWithIsBackToReferrer:(BOOL)backToReferrer {
|
||||
if ((self = [super init])) {
|
||||
_backToReferrer = backToReferrer;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
137
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkNavigation.h
generated
Normal file
137
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkNavigation.h
generated
Normal file
@ -0,0 +1,137 @@
|
||||
// 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>
|
||||
|
||||
#import "FBSDKAppLink.h"
|
||||
#import "FBSDKAppLinkResolving.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
The result of calling navigate on a FBSDKAppLinkNavigation
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, FBSDKAppLinkNavigationType) {
|
||||
/*! Indicates that the navigation failed and no app was opened */
|
||||
FBSDKAppLinkNavigationTypeFailure,
|
||||
/*! Indicates that the navigation succeeded by opening the URL in the browser */
|
||||
FBSDKAppLinkNavigationTypeBrowser,
|
||||
/*! Indicates that the navigation succeeded by opening the URL in an app on the device */
|
||||
FBSDKAppLinkNavigationTypeApp
|
||||
};
|
||||
|
||||
/**
|
||||
Describes the callback for appLinkFromURLInBackground.
|
||||
@param navType the FBSDKAppLink representing the deferred App Link
|
||||
@param error the error during the request, if any
|
||||
|
||||
*/
|
||||
typedef void (^FBSDKAppLinkNavigationHandler)(FBSDKAppLinkNavigationType navType, NSError * _Nullable error);
|
||||
|
||||
/*!
|
||||
Represents a pending request to navigate to an App Link. Most developers will
|
||||
simply use navigateToURLInBackground: to open a URL, but developers can build
|
||||
custom requests with additional navigation and app data attached to them by
|
||||
creating FBSDKAppLinkNavigations themselves.
|
||||
*/
|
||||
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension")
|
||||
@interface FBSDKAppLinkNavigation : NSObject
|
||||
|
||||
/*!
|
||||
The extras for the AppLinkNavigation. This will generally contain application-specific
|
||||
data that should be passed along with the request, such as advertiser or affiliate IDs or
|
||||
other such metadata relevant on this device.
|
||||
*/
|
||||
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *extras;
|
||||
|
||||
/*!
|
||||
The al_applink_data for the AppLinkNavigation. This will generally contain data common to
|
||||
navigation attempts such as back-links, user agents, and other information that may be used
|
||||
in routing and handling an App Link request.
|
||||
*/
|
||||
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *appLinkData;
|
||||
|
||||
/*! The AppLink to navigate to */
|
||||
@property (nonatomic, strong, readonly) FBSDKAppLink *appLink;
|
||||
|
||||
/*! Creates an AppLinkNavigation with the given link, extras, and App Link data */
|
||||
+ (instancetype)navigationWithAppLink:(FBSDKAppLink *)appLink
|
||||
extras:(NSDictionary<NSString *, id> *)extras
|
||||
appLinkData:(NSDictionary<NSString *, id> *)appLinkData;
|
||||
|
||||
/*!
|
||||
Creates an NSDictionary with the correct format for iOS callback URLs,
|
||||
to be used as 'appLinkData' argument in the call to navigationWithAppLink:extras:appLinkData:
|
||||
*/
|
||||
+ (NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *> *)callbackAppLinkDataForAppWithName:(NSString *)appName
|
||||
url:(NSString *)url;
|
||||
|
||||
/*! Performs the navigation */
|
||||
- (FBSDKAppLinkNavigationType)navigate:(NSError *__autoreleasing *)error;
|
||||
|
||||
/*! Returns a FBSDKAppLink for the given URL */
|
||||
+ (void)resolveAppLink:(NSURL *)destination handler:(FBSDKAppLinkFromURLHandler)handler;
|
||||
|
||||
/*! Returns a FBSDKAppLink for the given URL using the given App Link resolution strategy */
|
||||
+ (void)resolveAppLink:(NSURL *)destination
|
||||
resolver:(id<FBSDKAppLinkResolving>)resolver
|
||||
handler:(FBSDKAppLinkFromURLHandler)handler;
|
||||
|
||||
/*! Navigates to a FBSDKAppLink and returns whether it opened in-app or in-browser */
|
||||
+ (FBSDKAppLinkNavigationType)navigateToAppLink:(FBSDKAppLink *)link error:(NSError *__autoreleasing *)error;
|
||||
|
||||
/*!
|
||||
Returns a FBSDKAppLinkNavigationType based on a FBSDKAppLink.
|
||||
It's essentially a no-side-effect version of navigateToAppLink:error:,
|
||||
allowing apps to determine flow based on the link type (e.g. open an
|
||||
internal web view instead of going straight to the browser for regular links.)
|
||||
*/
|
||||
+ (FBSDKAppLinkNavigationType)navigationTypeForLink:(FBSDKAppLink *)link;
|
||||
|
||||
/*!
|
||||
Return navigation type for current instance.
|
||||
No-side-effect version of navigate:
|
||||
*/
|
||||
- (FBSDKAppLinkNavigationType)navigationType;
|
||||
|
||||
/*! Navigates to a URL (an asynchronous action) and returns a FBSDKNavigationType */
|
||||
+ (void)navigateToURL:(NSURL *)destination handler:(FBSDKAppLinkNavigationHandler)handler;
|
||||
|
||||
/*!
|
||||
Navigates to a URL (an asynchronous action) using the given App Link resolution
|
||||
strategy and returns a FBSDKNavigationType
|
||||
*/
|
||||
+ (void)navigateToURL:(NSURL *)destination
|
||||
resolver:(id<FBSDKAppLinkResolving>)resolver
|
||||
handler:(FBSDKAppLinkNavigationHandler)handler;
|
||||
|
||||
/*!
|
||||
Gets the default resolver to be used for App Link resolution. If the developer has not set one explicitly,
|
||||
a basic, built-in resolver will be used.
|
||||
*/
|
||||
+ (id<FBSDKAppLinkResolving>)defaultResolver;
|
||||
|
||||
/*!
|
||||
Sets the default resolver to be used for App Link resolution. Setting this to nil will revert the
|
||||
default resolver to the basic, built-in resolver provided by FBSDK.
|
||||
*/
|
||||
+ (void)setDefaultResolver:(id<FBSDKAppLinkResolving>)resolver;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
302
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkNavigation.m
generated
Normal file
302
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkNavigation.m
generated
Normal file
@ -0,0 +1,302 @@
|
||||
// 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 "FBSDKAppLinkNavigation.h"
|
||||
|
||||
#import "FBSDKAppLinkTarget.h"
|
||||
#import "FBSDKAppLink_Internal.h"
|
||||
#import "FBSDKMeasurementEvent_Internal.h"
|
||||
#import "FBSDKSettings.h"
|
||||
#import "FBSDKWebViewAppLinkResolver.h"
|
||||
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkDataParameterName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkTargetKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkUserAgentKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkExtrasKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkVersionKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkRefererAppLink;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkRefererAppName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkRefererUrl;
|
||||
|
||||
static id<FBSDKAppLinkResolving> defaultResolver;
|
||||
|
||||
@interface FBSDKAppLinkNavigation ()
|
||||
|
||||
@property (nonatomic, copy, readwrite) NSDictionary<NSString *, id> *extras;
|
||||
@property (nonatomic, copy, readwrite) NSDictionary<NSString *, id> *appLinkData;
|
||||
@property (nonatomic, strong, readwrite) FBSDKAppLink *appLink;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKAppLinkNavigation
|
||||
|
||||
+ (instancetype)navigationWithAppLink:(FBSDKAppLink *)appLink
|
||||
extras:(NSDictionary<NSString *, id> *)extras
|
||||
appLinkData:(NSDictionary<NSString *, id> *)appLinkData {
|
||||
FBSDKAppLinkNavigation *navigation = [[self alloc] init];
|
||||
navigation.appLink = appLink;
|
||||
navigation.extras = extras;
|
||||
navigation.appLinkData = appLinkData;
|
||||
return navigation;
|
||||
}
|
||||
|
||||
+ (NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *> *)callbackAppLinkDataForAppWithName:(NSString *)appName
|
||||
url:(NSString *)url {
|
||||
return @{FBSDKAppLinkRefererAppLink: @{FBSDKAppLinkRefererAppName: appName, FBSDKAppLinkRefererUrl: url}};
|
||||
}
|
||||
|
||||
- (NSString *)stringByEscapingQueryString:(NSString *)string {
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9
|
||||
return [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||||
#else
|
||||
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,
|
||||
(CFStringRef)string,
|
||||
NULL,
|
||||
(CFStringRef) @":/?#[]@!$&'()*+,;=",
|
||||
kCFStringEncodingUTF8));
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSURL *)appLinkURLWithTargetURL:(NSURL *)targetUrl error:(NSError **)error {
|
||||
NSMutableDictionary<NSString *, id> *appLinkData =
|
||||
[NSMutableDictionary dictionaryWithDictionary:self.appLinkData ?: @{}];
|
||||
|
||||
// Add applink protocol data
|
||||
if (!appLinkData[FBSDKAppLinkUserAgentKeyName]) {
|
||||
appLinkData[FBSDKAppLinkUserAgentKeyName] = [NSString stringWithFormat:@"FBSDK %@", FBSDKSettings.sdkVersion];
|
||||
}
|
||||
if (!appLinkData[FBSDKAppLinkVersionKeyName]) {
|
||||
appLinkData[FBSDKAppLinkVersionKeyName] = FBSDKAppLinkVersion;
|
||||
}
|
||||
if (self.appLink.sourceURL.absoluteString) {
|
||||
appLinkData[FBSDKAppLinkTargetKeyName] = self.appLink.sourceURL.absoluteString;
|
||||
}
|
||||
appLinkData[FBSDKAppLinkExtrasKeyName] = self.extras ?: @{};
|
||||
|
||||
// JSON-ify the applink data
|
||||
NSError *jsonError = nil;
|
||||
NSData *jsonBlob = [NSJSONSerialization dataWithJSONObject:appLinkData options:0 error:&jsonError];
|
||||
if (!jsonError) {
|
||||
NSString *jsonString = [[NSString alloc] initWithData:jsonBlob encoding:NSUTF8StringEncoding];
|
||||
NSString *encoded = [self stringByEscapingQueryString:jsonString];
|
||||
|
||||
NSString *endUrlString = [NSString stringWithFormat:@"%@%@%@=%@",
|
||||
[targetUrl absoluteString],
|
||||
targetUrl.query ? @"&" : @"?",
|
||||
FBSDKAppLinkDataParameterName,
|
||||
encoded];
|
||||
|
||||
return [NSURL URLWithString:endUrlString];
|
||||
} else {
|
||||
if (error) {
|
||||
*error = jsonError;
|
||||
}
|
||||
|
||||
// If there was an error encoding the app link data, fail hard.
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (FBSDKAppLinkNavigationType)navigate:(NSError **)error {
|
||||
NSURL *openedURL = nil;
|
||||
NSError *encodingError = nil;
|
||||
FBSDKAppLinkNavigationType retType = FBSDKAppLinkNavigationTypeFailure;
|
||||
|
||||
// Find the first eligible/launchable target in the FBSDKAppLink.
|
||||
for (FBSDKAppLinkTarget *target in self.appLink.targets) {
|
||||
NSURL *appLinkAppURL = [self appLinkURLWithTargetURL:target.URL error:&encodingError];
|
||||
if (encodingError || !appLinkAppURL) {
|
||||
if (error) {
|
||||
*error = encodingError;
|
||||
}
|
||||
} else if ([[UIApplication sharedApplication] openURL:appLinkAppURL]) {
|
||||
retType = FBSDKAppLinkNavigationTypeApp;
|
||||
openedURL = appLinkAppURL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!openedURL && self.appLink.webURL) {
|
||||
// Fall back to opening the url in the browser if available.
|
||||
NSURL *appLinkBrowserURL = [self appLinkURLWithTargetURL:self.appLink.webURL error:&encodingError];
|
||||
if (encodingError || !appLinkBrowserURL) {
|
||||
// If there was an error encoding the app link data, fail hard.
|
||||
if (error) {
|
||||
*error = encodingError;
|
||||
}
|
||||
} else if ([[UIApplication sharedApplication] openURL:appLinkBrowserURL]) {
|
||||
// This was a browser navigation.
|
||||
retType = FBSDKAppLinkNavigationTypeBrowser;
|
||||
openedURL = appLinkBrowserURL;
|
||||
}
|
||||
}
|
||||
|
||||
[self postAppLinkNavigateEventNotificationWithTargetURL:openedURL
|
||||
error:error ? *error : nil
|
||||
type:retType];
|
||||
return retType;
|
||||
}
|
||||
|
||||
- (void)postAppLinkNavigateEventNotificationWithTargetURL:(NSURL *)outputURL error:(NSError *)error type:(FBSDKAppLinkNavigationType)type {
|
||||
NSString *const EVENT_YES_VAL = @"1";
|
||||
NSString *const EVENT_NO_VAL = @"0";
|
||||
NSMutableDictionary<NSString *, id> *logData =
|
||||
[[NSMutableDictionary alloc] init];
|
||||
|
||||
NSString *outputURLScheme = [outputURL scheme];
|
||||
NSString *outputURLString = [outputURL absoluteString];
|
||||
if (outputURLScheme) {
|
||||
logData[@"outputURLScheme"] = outputURLScheme;
|
||||
}
|
||||
if (outputURLString) {
|
||||
logData[@"outputURL"] = outputURLString;
|
||||
}
|
||||
|
||||
NSString *sourceURLString = [self.appLink.sourceURL absoluteString];
|
||||
NSString *sourceURLHost = [self.appLink.sourceURL host];
|
||||
NSString *sourceURLScheme = [self.appLink.sourceURL scheme];
|
||||
if (sourceURLString) {
|
||||
logData[@"sourceURL"] = sourceURLString;
|
||||
}
|
||||
if (sourceURLHost) {
|
||||
logData[@"sourceHost"] = sourceURLHost;
|
||||
}
|
||||
if (sourceURLScheme) {
|
||||
logData[@"sourceScheme"] = sourceURLScheme;
|
||||
}
|
||||
if ([error localizedDescription]) {
|
||||
logData[@"error"] = [error localizedDescription];
|
||||
}
|
||||
NSString *success = nil; //no
|
||||
NSString *linkType = nil; // unknown;
|
||||
switch (type) {
|
||||
case FBSDKAppLinkNavigationTypeFailure:
|
||||
success = EVENT_NO_VAL;
|
||||
linkType = @"fail";
|
||||
break;
|
||||
case FBSDKAppLinkNavigationTypeBrowser:
|
||||
success = EVENT_YES_VAL;
|
||||
linkType = @"web";
|
||||
break;
|
||||
case FBSDKAppLinkNavigationTypeApp:
|
||||
success = EVENT_YES_VAL;
|
||||
linkType = @"app";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (success) {
|
||||
logData[@"success"] = success;
|
||||
}
|
||||
if (linkType) {
|
||||
logData[@"type"] = linkType;
|
||||
}
|
||||
|
||||
if ([self.appLink isBackToReferrer]) {
|
||||
[FBSDKMeasurementEvent postNotificationForEventName:FBSDKAppLinkNavigateBackToReferrerEventName args:logData];
|
||||
} else {
|
||||
[FBSDKMeasurementEvent postNotificationForEventName:FBSDKAppLinkNavigateOutEventName args:logData];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)resolveAppLink:(NSURL *)destination
|
||||
resolver:(id<FBSDKAppLinkResolving>)resolver
|
||||
handler:(FBSDKAppLinkFromURLHandler)handler {
|
||||
[resolver appLinkFromURL:destination handler:handler];
|
||||
}
|
||||
|
||||
+ (void)resolveAppLink:(NSURL *)destination handler:(FBSDKAppLinkFromURLHandler)handler {
|
||||
[self resolveAppLink:destination resolver:[self defaultResolver] handler:handler];
|
||||
}
|
||||
|
||||
+ (void)navigateToURL:(NSURL *)destination handler:(FBSDKAppLinkNavigationHandler)handler {
|
||||
[self navigateToURL:destination resolver:[self defaultResolver] handler:handler];
|
||||
}
|
||||
|
||||
+ (void)navigateToURL:(NSURL *)destination
|
||||
resolver:(id<FBSDKAppLinkResolving>)resolver
|
||||
handler:(FBSDKAppLinkNavigationHandler)handler {
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self resolveAppLink:destination
|
||||
resolver:resolver
|
||||
handler:^(FBSDKAppLink * _Nullable appLink, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
handler(FBSDKAppLinkNavigationTypeFailure, error);
|
||||
return;
|
||||
}
|
||||
|
||||
NSError *navigateError = nil;
|
||||
FBSDKAppLinkNavigationType result = [self navigateToAppLink:appLink error:&navigateError];
|
||||
handler(result, navigateError);
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
+ (FBSDKAppLinkNavigationType)navigateToAppLink:(FBSDKAppLink *)link error:(NSError **)error {
|
||||
return [[FBSDKAppLinkNavigation navigationWithAppLink:link
|
||||
extras:@{}
|
||||
appLinkData:@{}] navigate:error];
|
||||
}
|
||||
|
||||
+ (FBSDKAppLinkNavigationType)navigationTypeForLink:(FBSDKAppLink *)link {
|
||||
return [[self navigationWithAppLink:link extras:@{} appLinkData:@{}] navigationType];
|
||||
}
|
||||
|
||||
- (FBSDKAppLinkNavigationType)navigationType {
|
||||
FBSDKAppLinkTarget *eligibleTarget = nil;
|
||||
for (FBSDKAppLinkTarget *target in self.appLink.targets) {
|
||||
if ([[UIApplication sharedApplication] canOpenURL:target.URL]) {
|
||||
eligibleTarget = target;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (eligibleTarget != nil) {
|
||||
NSURL *appLinkURL = [self appLinkURLWithTargetURL:eligibleTarget.URL error:nil];
|
||||
if (appLinkURL != nil) {
|
||||
return FBSDKAppLinkNavigationTypeApp;
|
||||
} else {
|
||||
return FBSDKAppLinkNavigationTypeFailure;
|
||||
}
|
||||
}
|
||||
|
||||
if (self.appLink.webURL != nil) {
|
||||
NSURL *appLinkURL = [self appLinkURLWithTargetURL:eligibleTarget.URL error:nil];
|
||||
if (appLinkURL != nil) {
|
||||
return FBSDKAppLinkNavigationTypeBrowser;
|
||||
} else {
|
||||
return FBSDKAppLinkNavigationTypeFailure;
|
||||
}
|
||||
}
|
||||
|
||||
return FBSDKAppLinkNavigationTypeFailure;
|
||||
}
|
||||
|
||||
+ (id<FBSDKAppLinkResolving>)defaultResolver {
|
||||
if (defaultResolver) {
|
||||
return defaultResolver;
|
||||
}
|
||||
return [FBSDKWebViewAppLinkResolver sharedInstance];
|
||||
}
|
||||
|
||||
+ (void)setDefaultResolver:(id<FBSDKAppLinkResolving>)resolver {
|
||||
defaultResolver = resolver;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -18,12 +18,15 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FBSDKAppLinkResolving.h"
|
||||
|
||||
@class BFTask;
|
||||
|
||||
|
||||
// Check if Bolts.framework is available for import
|
||||
#if __has_include(<Bolts/BFAppLinkResolving.h>)
|
||||
// Import it if it's available
|
||||
# import <Bolts/BFAppLinkResolving.h>
|
||||
#import <Bolts/BFAppLinkResolving.h>
|
||||
#else
|
||||
// Otherwise - redeclare BFAppLinkResolving protocol to resolve the problem of missing symbols
|
||||
// Please note: Bolts.framework is still required for AppLink resolving to work,
|
||||
@ -34,15 +37,17 @@
|
||||
App Links that may include pre-fetching, caching, or querying for App Link
|
||||
data from an index provided by a service provider.
|
||||
*/
|
||||
DEPRECATED_MSG_ATTRIBUTE("Use `FBSDKAppLinkResolving`")
|
||||
@protocol BFAppLinkResolving <NSObject>
|
||||
|
||||
/**
|
||||
Asynchronously resolves App Link data for a given URL.
|
||||
|
||||
- Parameter url: The URL to resolve into an App Link.
|
||||
- Returns: A BFTask that will return a BFAppLink for the given URL.
|
||||
@param url The URL to resolve into an App Link.
|
||||
@return A BFTask that will return a BFAppLink for the given URL.
|
||||
*/
|
||||
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url;
|
||||
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url
|
||||
DEPRECATED_MSG_ATTRIBUTE("Use `appLinkFromURL:handler:`");
|
||||
|
||||
@end
|
||||
|
||||
@ -59,20 +64,40 @@
|
||||
Usage of this type requires a client token. See `[FBSDKSettings setClientToken:]` and linking
|
||||
Bolts.framework
|
||||
*/
|
||||
@interface FBSDKAppLinkResolver : NSObject<BFAppLinkResolving>
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
@interface FBSDKAppLinkResolver : NSObject<FBSDKAppLinkResolving, BFAppLinkResolving>
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
/**
|
||||
Asynchronously resolves App Link data for multiple URLs.
|
||||
|
||||
- Parameter urls: An array of NSURLs to resolve into App Links.
|
||||
- Returns: A BFTask that will return dictionary mapping input NSURLs to their
|
||||
@param urls An array of NSURLs to resolve into App Links.
|
||||
@return A BFTask that will return dictionary mapping input NSURLs to their
|
||||
corresponding BFAppLink.
|
||||
|
||||
|
||||
|
||||
You should set the client token before making this call. See `[FBSDKSettings setClientToken:]`
|
||||
*/
|
||||
- (BFTask *)appLinksFromURLsInBackground:(NSArray *)urls;
|
||||
- (BFTask *)appLinksFromURLsInBackground:(NSArray<NSURL *> *)urls
|
||||
DEPRECATED_MSG_ATTRIBUTE("Use `appLinkFromURLs:handler:`");
|
||||
|
||||
/**
|
||||
Asynchronously resolves App Link data for a given URL.
|
||||
|
||||
@param url The URL to resolve into an App Link.
|
||||
@return A BFTask that will return a BFAppLink for the given URL.
|
||||
*/
|
||||
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url
|
||||
DEPRECATED_MSG_ATTRIBUTE("Use `appLinkFromURL:handler:`");
|
||||
|
||||
/**
|
||||
Asynchronously resolves App Link data for a given array of URLs.
|
||||
|
||||
@param urls The URLs to resolve into an App Link.
|
||||
@param handler The completion block that will return an App Link for the given URL.
|
||||
*/
|
||||
- (void)appLinksFromURLs:(NSArray<NSURL *> *)urls handler:(FBSDKAppLinksFromURLArrayHandler)handler
|
||||
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension");
|
||||
|
||||
/**
|
||||
Allocates and initializes a new instance of FBSDKAppLinkResolver.
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#import <Bolts/BFTaskCompletionSource.h>
|
||||
|
||||
#import "FBSDKAccessToken.h"
|
||||
#import "FBSDKAppLink.h"
|
||||
#import "FBSDKGraphRequest+Internal.h"
|
||||
#import "FBSDKGraphRequestConnection.h"
|
||||
#import "FBSDKInternalUtility.h"
|
||||
@ -45,7 +46,8 @@ static NSString *const kAppLinksKey = @"app_links";
|
||||
|
||||
@interface FBSDKAppLinkResolver ()
|
||||
|
||||
@property (nonatomic, strong) NSMutableDictionary *cachedLinks;
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSURL *, BFAppLink *> *cachedBFAppLinks;
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSURL *, FBSDKAppLink *> *cachedFBSDKAppLinks;
|
||||
@property (nonatomic, assign) UIUserInterfaceIdiom userInterfaceIdiom;
|
||||
@end
|
||||
|
||||
@ -67,29 +69,133 @@ static Class g_BFTaskClass;
|
||||
}
|
||||
}
|
||||
|
||||
- (id)initWithUserInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdiom
|
||||
- (instancetype)initWithUserInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdiom
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.cachedLinks = [NSMutableDictionary dictionary];
|
||||
self.cachedBFAppLinks = [NSMutableDictionary dictionary];
|
||||
self.cachedFBSDKAppLinks = [NSMutableDictionary dictionary];
|
||||
self.userInterfaceIdiom = userInterfaceIdiom;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appLinkFromURL:(NSURL *)url handler:(FBSDKAppLinkFromURLHandler)handler
|
||||
{
|
||||
[self appLinksFromURLs:@[url] handler:^(NSDictionary<NSURL *, FBSDKAppLink *> *urls, NSError * _Nullable error) {
|
||||
handler(urls[url], error);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)appLinksFromURLs:(NSArray<NSURL *> *)urls handler:(FBSDKAppLinksFromURLArrayHandler)handler
|
||||
{
|
||||
if (![FBSDKSettings clientToken] && ![FBSDKAccessToken currentAccessToken]) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"A user access token or clientToken is required to use FBAppLinkResolver"];
|
||||
}
|
||||
NSMutableDictionary<NSURL *, FBSDKAppLink *> *appLinks = [NSMutableDictionary dictionary];
|
||||
NSMutableArray<NSURL *> *toFind = [NSMutableArray array];
|
||||
NSMutableArray<NSString *> *toFindStrings = [NSMutableArray array];
|
||||
|
||||
@synchronized (self.cachedFBSDKAppLinks) {
|
||||
for (NSURL *url in urls) {
|
||||
if (self.cachedFBSDKAppLinks[url]) {
|
||||
appLinks[url] = self.cachedFBSDKAppLinks[url];
|
||||
} else {
|
||||
[toFind addObject:url];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
NSString *toFindString = [url.absoluteString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
#pragma clang diagnostic pop
|
||||
if (toFindString) {
|
||||
[toFindStrings addObject:toFindString];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toFind.count == 0) {
|
||||
// All of the URLs have already been found.
|
||||
handler(_cachedFBSDKAppLinks, nil);
|
||||
}
|
||||
NSMutableArray<NSString *> *fields = [NSMutableArray arrayWithObject:kIOSKey];
|
||||
|
||||
NSString *idiomSpecificField = nil;
|
||||
|
||||
switch (self.userInterfaceIdiom) {
|
||||
case UIUserInterfaceIdiomPad:
|
||||
idiomSpecificField = kIPadKey;
|
||||
break;
|
||||
case UIUserInterfaceIdiomPhone:
|
||||
idiomSpecificField = kIPhoneKey;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (idiomSpecificField) {
|
||||
[fields addObject:idiomSpecificField];
|
||||
}
|
||||
NSString *path = [NSString stringWithFormat:@"?fields=%@.fields(%@)&ids=%@",
|
||||
kAppLinksKey,
|
||||
[fields componentsJoinedByString:@","],
|
||||
[toFindStrings componentsJoinedByString:@","]];
|
||||
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:path
|
||||
parameters:nil
|
||||
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
|
||||
|
||||
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||
if (error) {
|
||||
handler(@{}, error);
|
||||
return;
|
||||
}
|
||||
for (NSURL *url in toFind) {
|
||||
id nestedObject = [[result objectForKey:url.absoluteString] objectForKey:kAppLinksKey];
|
||||
NSMutableArray *rawTargets = [NSMutableArray array];
|
||||
if (idiomSpecificField) {
|
||||
[rawTargets addObjectsFromArray:[nestedObject objectForKey:idiomSpecificField]];
|
||||
}
|
||||
[rawTargets addObjectsFromArray:[nestedObject objectForKey:kIOSKey]];
|
||||
|
||||
NSMutableArray<FBSDKAppLinkTarget *> *targets = [NSMutableArray arrayWithCapacity:rawTargets.count];
|
||||
for (id rawTarget in rawTargets) {
|
||||
[targets addObject:[FBSDKAppLinkTarget appLinkTargetWithURL:[NSURL URLWithString:[rawTarget objectForKey:kURLKey]]
|
||||
appStoreId:[rawTarget objectForKey:kIOSAppStoreIdKey]
|
||||
appName:[rawTarget objectForKey:kIOSAppNameKey]]];
|
||||
}
|
||||
|
||||
id webTarget = [nestedObject objectForKey:kWebKey];
|
||||
NSString *webFallbackString = [webTarget objectForKey:kURLKey];
|
||||
NSURL *fallbackUrl = webFallbackString ? [NSURL URLWithString:webFallbackString] : url;
|
||||
|
||||
NSNumber *shouldFallback = [webTarget objectForKey:kShouldFallbackKey];
|
||||
if (shouldFallback && !shouldFallback.boolValue) {
|
||||
fallbackUrl = nil;
|
||||
}
|
||||
|
||||
FBSDKAppLink *link = [FBSDKAppLink appLinkWithSourceURL:url
|
||||
targets:targets
|
||||
webURL:fallbackUrl];
|
||||
@synchronized (self.cachedFBSDKAppLinks) {
|
||||
self.cachedFBSDKAppLinks[url] = link;
|
||||
}
|
||||
appLinks[url] = link;
|
||||
}
|
||||
handler(appLinks, nil);
|
||||
}];
|
||||
}
|
||||
|
||||
- (BFTask *)appLinksFromURLsInBackground:(NSArray *)urls
|
||||
{
|
||||
if (![FBSDKSettings clientToken] && ![FBSDKAccessToken currentAccessToken]) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"A user access token or clientToken is required to use FBAppLinkResolver"];
|
||||
}
|
||||
NSMutableDictionary *appLinks = [NSMutableDictionary dictionary];
|
||||
NSMutableArray *toFind = [NSMutableArray array];
|
||||
NSMutableArray *toFindStrings = [NSMutableArray array];
|
||||
NSMutableDictionary<NSURL *, BFAppLink *> *appLinks = [NSMutableDictionary dictionary];
|
||||
NSMutableArray<NSURL *> *toFind = [NSMutableArray array];
|
||||
NSMutableArray<NSString *> *toFindStrings = [NSMutableArray array];
|
||||
|
||||
@synchronized (self.cachedLinks) {
|
||||
@synchronized (self.cachedBFAppLinks) {
|
||||
for (NSURL *url in urls) {
|
||||
if (self.cachedLinks[url]) {
|
||||
appLinks[url] = self.cachedLinks[url];
|
||||
if (self.cachedBFAppLinks[url]) {
|
||||
appLinks[url] = self.cachedBFAppLinks[url];
|
||||
} else {
|
||||
[toFind addObject:url];
|
||||
#pragma clang diagnostic push
|
||||
@ -103,7 +209,7 @@ static Class g_BFTaskClass;
|
||||
// All of the URLs have already been found.
|
||||
return [g_BFTaskClass taskWithResult:appLinks];
|
||||
}
|
||||
NSMutableArray *fields = [NSMutableArray arrayWithObject:kIOSKey];
|
||||
NSMutableArray<NSString *> *fields = [NSMutableArray arrayWithObject:kIOSKey];
|
||||
|
||||
NSString *idiomSpecificField = nil;
|
||||
|
||||
@ -141,7 +247,7 @@ static Class g_BFTaskClass;
|
||||
}
|
||||
[rawTargets addObjectsFromArray:[nestedObject objectForKey:kIOSKey]];
|
||||
|
||||
NSMutableArray *targets = [NSMutableArray arrayWithCapacity:rawTargets.count];
|
||||
NSMutableArray<BFAppLinkTarget *> *targets = [NSMutableArray arrayWithCapacity:rawTargets.count];
|
||||
for (id rawTarget in rawTargets) {
|
||||
[targets addObject:[g_BFAppLinkTargetClass appLinkTargetWithURL:[NSURL URLWithString:[rawTarget objectForKey:kURLKey]]
|
||||
appStoreId:[rawTarget objectForKey:kIOSAppStoreIdKey]
|
||||
@ -160,8 +266,8 @@ static Class g_BFTaskClass;
|
||||
BFAppLink *link = [g_BFAppLinkClass appLinkWithSourceURL:url
|
||||
targets:targets
|
||||
webURL:fallbackUrl];
|
||||
@synchronized (self.cachedLinks) {
|
||||
self.cachedLinks[url] = link;
|
||||
@synchronized (self.cachedBFAppLinks) {
|
||||
self.cachedBFAppLinks[url] = link;
|
||||
}
|
||||
appLinks[url] = link;
|
||||
}
|
||||
@ -170,6 +276,8 @@ static Class g_BFTaskClass;
|
||||
return tcs.task;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url
|
||||
{
|
||||
// Implement in terms of appLinksFromURLsInBackground
|
||||
@ -178,6 +286,7 @@ static Class g_BFTaskClass;
|
||||
return task.result[url];
|
||||
}];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
+ (id)resolver
|
||||
{
|
||||
|
||||
60
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkResolving.h
generated
Normal file
60
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkResolving.h
generated
Normal file
@ -0,0 +1,60 @@
|
||||
// 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class FBSDKAppLink;
|
||||
|
||||
/**
|
||||
Describes the callback for appLinkFromURLInBackground.
|
||||
@param appLink the FBSDKAppLink representing the deferred App Link
|
||||
@param error the error during the request, if any
|
||||
|
||||
*/
|
||||
typedef void (^FBSDKAppLinkFromURLHandler)(FBSDKAppLink * _Nullable appLink, NSError * _Nullable error);
|
||||
|
||||
|
||||
/**
|
||||
Describes the callback for appLinkFromURLInBackground.
|
||||
@param appLinks the FBSDKAppLinks representing the deferred App Links
|
||||
@param error the error during the request, if any
|
||||
*/
|
||||
typedef void (^FBSDKAppLinksFromURLArrayHandler)(NSDictionary<NSURL *, FBSDKAppLink *> * appLinks,
|
||||
NSError * _Nullable error);
|
||||
|
||||
/*!
|
||||
Implement this protocol to provide an alternate strategy for resolving
|
||||
App Links that may include pre-fetching, caching, or querying for App Link
|
||||
data from an index provided by a service provider.
|
||||
*/
|
||||
@protocol FBSDKAppLinkResolving <NSObject>
|
||||
|
||||
/**
|
||||
Asynchronously resolves App Link data for a given URL.
|
||||
|
||||
@param url The URL to resolve into an App Link.
|
||||
@param handler The completion block that will return an App Link for the given URL.
|
||||
*/
|
||||
- (void)appLinkFromURL:(NSURL *)url handler:(FBSDKAppLinkFromURLHandler)handler
|
||||
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
100
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererController.h
generated
Normal file
100
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererController.h
generated
Normal file
@ -0,0 +1,100 @@
|
||||
// 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>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "FBSDKAppLinkReturnToRefererView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class FBSDKAppLink;
|
||||
@class FBSDKAppLinkReturnToRefererController;
|
||||
|
||||
/*!
|
||||
Protocol that a class can implement in order to be notified when the user has navigated back
|
||||
to the referer of an App Link.
|
||||
*/
|
||||
@protocol FBSDKAppLinkReturnToRefererControllerDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/*! Called when the user has tapped to navigate, but before the navigation has been performed. */
|
||||
- (void)returnToRefererController:(FBSDKAppLinkReturnToRefererController *)controller
|
||||
willNavigateToAppLink:(FBSDKAppLink *)appLink;
|
||||
|
||||
/*! Called after the navigation has been attempted, with an indication of whether the referer
|
||||
app link was successfully opened. */
|
||||
- (void)returnToRefererController:(FBSDKAppLinkReturnToRefererController *)controller
|
||||
didNavigateToAppLink:(FBSDKAppLink *)url
|
||||
type:(FBSDKAppLinkNavigationType)type;
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
A controller class that implements default behavior for a FBSDKAppLinkReturnToRefererView, including
|
||||
the ability to display the view above the navigation bar for navigation-based apps.
|
||||
*/
|
||||
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension")
|
||||
@interface FBSDKAppLinkReturnToRefererController : NSObject <FBSDKAppLinkReturnToRefererViewDelegate>
|
||||
|
||||
/*!
|
||||
The delegate that will be notified when the user navigates back to the referer.
|
||||
*/
|
||||
@property (nonatomic, weak, nullable) id<FBSDKAppLinkReturnToRefererControllerDelegate> delegate;
|
||||
|
||||
/*!
|
||||
The FBSDKAppLinkReturnToRefererView this controller is controlling.
|
||||
*/
|
||||
@property (nonatomic, strong) FBSDKAppLinkReturnToRefererView *view;
|
||||
|
||||
/*!
|
||||
Initializes a controller suitable for controlling a FBSDKAppLinkReturnToRefererView that is to be displayed
|
||||
contained within another UIView (i.e., not displayed above the navigation bar).
|
||||
*/
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/*!
|
||||
Initializes a controller suitable for controlling a FBSDKAppLinkReturnToRefererView that is to be displayed
|
||||
displayed above the navigation bar.
|
||||
*/
|
||||
- (instancetype)initForDisplayAboveNavController:(UINavigationController *)navController;
|
||||
|
||||
/*!
|
||||
Removes the view entirely from the navigation controller it is currently displayed in.
|
||||
*/
|
||||
- (void)removeFromNavController;
|
||||
|
||||
/*!
|
||||
Shows the FBSDKAppLinkReturnToRefererView with the specified referer information. If nil or missing data,
|
||||
the view will not be displayed. */
|
||||
- (void)showViewForRefererAppLink:(FBSDKAppLink *)refererAppLink;
|
||||
|
||||
/*!
|
||||
Shows the FBSDKAppLinkReturnToRefererView with referer information extracted from the specified URL.
|
||||
If nil or missing referer App Link data, the view will not be displayed. */
|
||||
- (void)showViewForRefererURL:(NSURL *)url;
|
||||
|
||||
/*!
|
||||
Closes the view, possibly animating it.
|
||||
*/
|
||||
- (void)closeViewAnimated:(BOOL)animated;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
238
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererController.m
generated
Normal file
238
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererController.m
generated
Normal file
@ -0,0 +1,238 @@
|
||||
// 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 "FBSDKAppLinkReturnToRefererController.h"
|
||||
|
||||
#import "FBSDKAppLink.h"
|
||||
#import "FBSDKAppLinkReturnToRefererView_Internal.h"
|
||||
#import "FBSDKURL_Internal.h"
|
||||
|
||||
static const CFTimeInterval kFBSDKViewAnimationDuration = 0.25f;
|
||||
|
||||
@implementation FBSDKAppLinkReturnToRefererController {
|
||||
UINavigationController *_navigationController;
|
||||
FBSDKAppLinkReturnToRefererView *_view;
|
||||
}
|
||||
|
||||
#pragma mark - Object lifecycle
|
||||
|
||||
- (instancetype)init {
|
||||
return [super init];
|
||||
}
|
||||
|
||||
- (instancetype)initForDisplayAboveNavController:(UINavigationController *)navController {
|
||||
self = [self init];
|
||||
if (self) {
|
||||
_navigationController = navController;
|
||||
|
||||
if (_navigationController != nil) {
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
[nc addObserver:self
|
||||
selector:@selector(statusBarFrameWillChange:)
|
||||
name:UIApplicationWillChangeStatusBarFrameNotification
|
||||
object:nil];
|
||||
[nc addObserver:self
|
||||
selector:@selector(statusBarFrameDidChange:)
|
||||
name:UIApplicationDidChangeStatusBarFrameNotification
|
||||
object:nil];
|
||||
[nc addObserver:self
|
||||
selector:@selector(orientationDidChange:)
|
||||
name:UIDeviceOrientationDidChangeNotification
|
||||
object:nil];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
_view.delegate = nil;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
#pragma mark - Public API
|
||||
|
||||
- (FBSDKAppLinkReturnToRefererView *)view {
|
||||
if (!_view) {
|
||||
self.view = [[FBSDKAppLinkReturnToRefererView alloc] initWithFrame:CGRectZero];
|
||||
if (_navigationController) {
|
||||
[_navigationController.view addSubview:_view];
|
||||
}
|
||||
}
|
||||
return _view;
|
||||
}
|
||||
|
||||
- (void)setView:(FBSDKAppLinkReturnToRefererView *)view {
|
||||
if (_view != view) {
|
||||
_view.delegate = nil;
|
||||
}
|
||||
|
||||
_view = view;
|
||||
_view.delegate = self;
|
||||
|
||||
if (_navigationController) {
|
||||
_view.includeStatusBarInSize = FBSDKIncludeStatusBarInSizeAlways;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showViewForRefererAppLink:(FBSDKAppLink *)refererAppLink {
|
||||
self.view.refererAppLink = refererAppLink;
|
||||
|
||||
[_view sizeToFit];
|
||||
|
||||
if (_navigationController) {
|
||||
if (!_view.closed) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self moveNavigationBar];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showViewForRefererURL:(NSURL *)url {
|
||||
FBSDKAppLink *appLink = [FBSDKURL URLForRenderBackToReferrerBarURL:url].appLinkReferer;
|
||||
[self showViewForRefererAppLink:appLink];
|
||||
}
|
||||
|
||||
- (void)removeFromNavController {
|
||||
if (_navigationController) {
|
||||
[_view removeFromSuperview];
|
||||
_navigationController = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - FBSDKAppLinkReturnToRefererViewDelegate
|
||||
|
||||
- (void)returnToRefererViewDidTapInsideCloseButton:(FBSDKAppLinkReturnToRefererView *)view {
|
||||
[self closeViewAnimated:YES explicitlyClosed:YES];
|
||||
}
|
||||
|
||||
- (void)returnToRefererViewDidTapInsideLink:(FBSDKAppLinkReturnToRefererView *)view
|
||||
link:(FBSDKAppLink *)link {
|
||||
[self openRefererAppLink:link];
|
||||
[self closeViewAnimated:NO explicitlyClosed:NO];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)statusBarFrameWillChange:(NSNotification *)notification {
|
||||
NSValue *rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey];
|
||||
CGRect newFrame;
|
||||
[rectValue getValue:&newFrame];
|
||||
|
||||
if (_navigationController && !_view.closed) {
|
||||
if (CGRectGetHeight(newFrame) == 40) {
|
||||
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState;
|
||||
[UIView animateWithDuration:kFBSDKViewAnimationDuration delay:0.0 options:options animations:^{
|
||||
self->_view.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(self->_view.bounds), 0.0);
|
||||
} completion:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)statusBarFrameDidChange:(NSNotification *)notification {
|
||||
NSValue *rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey];
|
||||
CGRect newFrame;
|
||||
[rectValue getValue:&newFrame];
|
||||
|
||||
if (_navigationController && !_view.closed) {
|
||||
if (CGRectGetHeight(newFrame) == 40) {
|
||||
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState;
|
||||
[UIView animateWithDuration:kFBSDKViewAnimationDuration delay:0.0 options:options animations:^{
|
||||
[self->_view sizeToFit];
|
||||
[self moveNavigationBar];
|
||||
} completion:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)orientationDidChange:(NSNotificationCenter *)notification {
|
||||
if (_navigationController && !_view.closed && CGRectGetHeight(_view.bounds) > 0) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self moveNavigationBar];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)moveNavigationBar {
|
||||
if (_view.closed || !_view.refererAppLink) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self updateNavigationBarY:CGRectGetHeight(_view.bounds)];
|
||||
}
|
||||
|
||||
- (void)updateNavigationBarY:(CGFloat)y {
|
||||
UINavigationBar *navigationBar = _navigationController.navigationBar;
|
||||
CGRect navigationBarFrame = navigationBar.frame;
|
||||
CGFloat oldContainerViewY = CGRectGetMaxY(navigationBarFrame);
|
||||
navigationBarFrame.origin.y = y;
|
||||
navigationBar.frame = navigationBarFrame;
|
||||
|
||||
CGFloat dy = CGRectGetMaxY(navigationBarFrame) - oldContainerViewY;
|
||||
UIView *containerView = _navigationController.visibleViewController.view.superview;
|
||||
containerView.frame = UIEdgeInsetsInsetRect(containerView.frame, UIEdgeInsetsMake(dy, 0.0, 0.0, 0.0));
|
||||
}
|
||||
|
||||
- (void)closeViewAnimated:(BOOL)animated {
|
||||
[self closeViewAnimated:animated explicitlyClosed:YES];
|
||||
}
|
||||
|
||||
- (void)closeViewAnimated:(BOOL)animated explicitlyClosed:(BOOL)explicitlyClosed {
|
||||
void (^closer)(void) = ^{
|
||||
if (self->_navigationController) {
|
||||
[self updateNavigationBarY:self->_view.statusBarHeight];
|
||||
}
|
||||
|
||||
CGRect frame = self->_view.frame;
|
||||
frame.size.height = 0.0;
|
||||
self->_view.frame = frame;
|
||||
};
|
||||
|
||||
if (animated) {
|
||||
[UIView animateWithDuration:kFBSDKViewAnimationDuration animations:^{
|
||||
closer();
|
||||
} completion:^(BOOL finished) {
|
||||
if (explicitlyClosed) {
|
||||
self->_view.closed = YES;
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
closer();
|
||||
if (explicitlyClosed) {
|
||||
self->_view.closed = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openRefererAppLink:(FBSDKAppLink *)refererAppLink {
|
||||
if (refererAppLink) {
|
||||
id<FBSDKAppLinkReturnToRefererControllerDelegate> delegate = _delegate;
|
||||
if ([delegate respondsToSelector:@selector(returnToRefererController:willNavigateToAppLink:)]) {
|
||||
[delegate returnToRefererController:self willNavigateToAppLink:refererAppLink];
|
||||
}
|
||||
|
||||
NSError *error = nil;
|
||||
FBSDKAppLinkNavigationType type = [FBSDKAppLinkNavigation navigateToAppLink:refererAppLink error:&error];
|
||||
|
||||
if ([delegate respondsToSelector:@selector(returnToRefererController:didNavigateToAppLink:type:)]) {
|
||||
[delegate returnToRefererController:self didNavigateToAppLink:refererAppLink type:type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
90
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererView.h
generated
Normal file
90
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererView.h
generated
Normal file
@ -0,0 +1,90 @@
|
||||
// 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>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "FBSDKAppLinkNavigation.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSUInteger, FBSDKIncludeStatusBarInSize) {
|
||||
FBSDKIncludeStatusBarInSizeNever,
|
||||
FBSDKIncludeStatusBarInSizeIOS7AndLater,
|
||||
FBSDKIncludeStatusBarInSizeAlways,
|
||||
};
|
||||
|
||||
@class FBSDKAppLinkReturnToRefererView;
|
||||
@class FBSDKURL;
|
||||
|
||||
/*!
|
||||
Protocol that a class can implement in order to be notified when the user has navigated back
|
||||
to the referer of an App Link.
|
||||
*/
|
||||
@protocol FBSDKAppLinkReturnToRefererViewDelegate <NSObject>
|
||||
|
||||
/*!
|
||||
Called when the user has tapped inside the close button.
|
||||
*/
|
||||
- (void)returnToRefererViewDidTapInsideCloseButton:(FBSDKAppLinkReturnToRefererView *)view;
|
||||
|
||||
/*!
|
||||
Called when the user has tapped inside the App Link portion of the view.
|
||||
*/
|
||||
- (void)returnToRefererViewDidTapInsideLink:(FBSDKAppLinkReturnToRefererView *)view
|
||||
link:(FBSDKAppLink *)link;
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
Provides a UIView that displays a button allowing users to navigate back to the
|
||||
application that launched the App Link currently being handled, if the App Link
|
||||
contained referer data. The user can also close the view by clicking a close button
|
||||
rather than navigating away. If the view is provided an App Link that does not contain
|
||||
referer data, it will have zero size and no UI will be displayed.
|
||||
*/
|
||||
NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension")
|
||||
@interface FBSDKAppLinkReturnToRefererView : UIView
|
||||
|
||||
/*!
|
||||
The delegate that will be notified when the user navigates back to the referer.
|
||||
*/
|
||||
@property (nonatomic, weak, nullable) id<FBSDKAppLinkReturnToRefererViewDelegate> delegate;
|
||||
|
||||
/*!
|
||||
The color of the text label and close button.
|
||||
*/
|
||||
@property (nonatomic, strong) UIColor *textColor;
|
||||
|
||||
@property (nonatomic, strong) FBSDKAppLink *refererAppLink;
|
||||
|
||||
/*!
|
||||
Indicates whether to extend the size of the view to include the current status bar
|
||||
size, for use in scenarios where the view might extend under the status bar on iOS 7 and
|
||||
above; this property has no effect on earlier versions of iOS.
|
||||
*/
|
||||
@property (nonatomic, assign) FBSDKIncludeStatusBarInSize includeStatusBarInSize;
|
||||
|
||||
/*!
|
||||
Indicates whether the user has closed the view by clicking the close button.
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL closed;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
275
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererView.m
generated
Normal file
275
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkReturnToRefererView.m
generated
Normal file
@ -0,0 +1,275 @@
|
||||
// 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 "FBSDKAppLinkReturnToRefererView.h"
|
||||
|
||||
#import "FBSDKAppLink.h"
|
||||
#import "FBSDKAppLinkTarget.h"
|
||||
|
||||
static const CGFloat FBSDKMarginX = 8.5f;
|
||||
static const CGFloat FBSDKMarginY = 8.5f;
|
||||
|
||||
static NSString *const FBSDKRefererAppLink = @"referer_app_link";
|
||||
static NSString *const FBSDKRefererAppName = @"app_name";
|
||||
static NSString *const FBSDKRefererUrl = @"url";
|
||||
static const CGFloat FBSDKCloseButtonWidth = 12.0;
|
||||
static const CGFloat FBSDKCloseButtonHeight = 12.0;
|
||||
|
||||
@interface FBSDKAppLinkReturnToRefererView ()
|
||||
|
||||
@property (nonatomic, strong) UILabel *labelView;
|
||||
@property (nonatomic, strong) UIButton *closeButton;
|
||||
@property (nonatomic, strong) UITapGestureRecognizer *insideTapGestureRecognizer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKAppLinkReturnToRefererView {
|
||||
BOOL _explicitlyHidden;
|
||||
}
|
||||
|
||||
#pragma mark - Initialization
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
[self sizeToFit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
|
||||
self = [super initWithCoder:aDecoder];
|
||||
if (self) {
|
||||
[self commonInit];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)commonInit {
|
||||
// Initialization code
|
||||
_includeStatusBarInSize = FBSDKIncludeStatusBarInSizeIOS7AndLater;
|
||||
|
||||
// iOS 7 system blue color
|
||||
self.backgroundColor = [UIColor colorWithRed:0.0f green:122.0f / 255.0f blue:1.0f alpha:1.0f];
|
||||
self.textColor = [UIColor whiteColor];
|
||||
self.clipsToBounds = YES;
|
||||
|
||||
[self initViews];
|
||||
}
|
||||
|
||||
- (void)initViews {
|
||||
if (!_labelView && !_closeButton) {
|
||||
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_closeButton.backgroundColor = [UIColor clearColor];
|
||||
_closeButton.userInteractionEnabled = YES;
|
||||
_closeButton.clipsToBounds = YES;
|
||||
_closeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
|
||||
_closeButton.contentMode = UIViewContentModeCenter;
|
||||
[_closeButton addTarget:self action:@selector(closeButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self addSubview:_closeButton];
|
||||
|
||||
_labelView = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_labelView.font = [UIFont systemFontOfSize:[UIFont smallSystemFontSize]];
|
||||
_labelView.textColor = [UIColor whiteColor];
|
||||
_labelView.backgroundColor = [UIColor clearColor];
|
||||
#ifdef __IPHONE_6_0
|
||||
_labelView.textAlignment = NSTextAlignmentCenter;
|
||||
#else
|
||||
_labelView.textAlignment = UITextAlignmentCenter;
|
||||
#endif
|
||||
_labelView.clipsToBounds = YES;
|
||||
[self updateLabelText];
|
||||
[self addSubview:_labelView];
|
||||
|
||||
_insideTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapInside:)];
|
||||
_labelView.userInteractionEnabled = YES;
|
||||
[_labelView addGestureRecognizer:_insideTapGestureRecognizer];
|
||||
|
||||
[self updateColors];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (CGSize)intrinsicContentSize {
|
||||
CGSize size = self.bounds.size;
|
||||
if (_closed || !self.hasRefererData) {
|
||||
size.height = 0.0;
|
||||
} else {
|
||||
CGSize labelSize = [_labelView sizeThatFits:size];
|
||||
size = CGSizeMake(size.width, labelSize.height + 2 * FBSDKMarginY + self.statusBarHeight);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
|
||||
CGRect bounds = self.bounds;
|
||||
|
||||
_labelView.preferredMaxLayoutWidth = _labelView.bounds.size.width;
|
||||
CGSize labelSize = [_labelView sizeThatFits:bounds.size];
|
||||
_labelView.frame = CGRectMake(FBSDKMarginX,
|
||||
CGRectGetMaxY(bounds) - labelSize.height - 1.5f * FBSDKMarginY,
|
||||
CGRectGetMaxX(bounds) - FBSDKCloseButtonWidth - 3 * FBSDKMarginX,
|
||||
labelSize.height + FBSDKMarginY);
|
||||
|
||||
_closeButton.frame = CGRectMake(CGRectGetMaxX(bounds) - FBSDKCloseButtonWidth - 2 * FBSDKMarginX,
|
||||
_labelView.center.y - FBSDKCloseButtonHeight / 2.0f - FBSDKMarginY,
|
||||
FBSDKCloseButtonWidth + 2 * FBSDKMarginX,
|
||||
FBSDKCloseButtonHeight + 2 * FBSDKMarginY);
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size {
|
||||
if (_closed || !self.hasRefererData) {
|
||||
size = CGSizeMake(size.width, 0.0);
|
||||
} else {
|
||||
CGSize labelSize = [_labelView sizeThatFits:size];
|
||||
size = CGSizeMake(size.width, labelSize.height + 2 * FBSDKMarginY + self.statusBarHeight);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
- (CGFloat)statusBarHeight {
|
||||
UIApplication *application = [UIApplication sharedApplication];
|
||||
|
||||
BOOL include;
|
||||
switch (_includeStatusBarInSize) {
|
||||
case FBSDKIncludeStatusBarInSizeAlways:
|
||||
include = YES;
|
||||
break;
|
||||
case FBSDKIncludeStatusBarInSizeIOS7AndLater: {
|
||||
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
|
||||
include = (systemVersion >= 7.0);
|
||||
break;
|
||||
}
|
||||
case FBSDKIncludeStatusBarInSizeNever:
|
||||
include = NO;
|
||||
break;
|
||||
}
|
||||
if (include && !application.statusBarHidden) {
|
||||
BOOL landscape = UIInterfaceOrientationIsLandscape(application.statusBarOrientation);
|
||||
CGRect statusBarFrame = application.statusBarFrame;
|
||||
return landscape ? CGRectGetWidth(statusBarFrame) : CGRectGetHeight(statusBarFrame);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma mark - Public API
|
||||
|
||||
- (void)setIncludeStatusBarInSize:(FBSDKIncludeStatusBarInSize)includeStatusBarInSize {
|
||||
_includeStatusBarInSize = includeStatusBarInSize;
|
||||
[self setNeedsLayout];
|
||||
[self invalidateIntrinsicContentSize];
|
||||
}
|
||||
|
||||
- (void)setTextColor:(UIColor *)textColor {
|
||||
_textColor = textColor;
|
||||
[self updateColors];
|
||||
}
|
||||
|
||||
- (void)setRefererAppLink:(FBSDKAppLink *)refererAppLink {
|
||||
_refererAppLink = refererAppLink;
|
||||
[self updateLabelText];
|
||||
[self updateHidden];
|
||||
[self invalidateIntrinsicContentSize];
|
||||
}
|
||||
|
||||
- (void)setClosed:(BOOL)closed {
|
||||
if (_closed != closed) {
|
||||
_closed = closed;
|
||||
[self updateHidden];
|
||||
[self invalidateIntrinsicContentSize];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setHidden:(BOOL)hidden {
|
||||
_explicitlyHidden = hidden;
|
||||
[self updateHidden];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)updateLabelText {
|
||||
NSString *appName = (_refererAppLink && _refererAppLink.targets[0]) ? [_refererAppLink.targets[0] appName] : nil;
|
||||
_labelView.text = [self localizedLabelForReferer:appName];
|
||||
}
|
||||
|
||||
- (void)updateColors {
|
||||
UIImage *closeButtonImage = [self drawCloseButtonImageWithColor:_textColor];
|
||||
|
||||
_labelView.textColor = _textColor;
|
||||
[_closeButton setImage:closeButtonImage forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (UIImage *)drawCloseButtonImageWithColor:(UIColor *)color {
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(FBSDKCloseButtonWidth, FBSDKCloseButtonHeight), NO, 0.0f);
|
||||
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGContextSetStrokeColorWithColor(context, [color CGColor]);
|
||||
CGContextSetFillColorWithColor(context, [color CGColor]);
|
||||
|
||||
CGContextSetLineWidth(context, 1.25f);
|
||||
|
||||
CGFloat inset = 0.5f;
|
||||
|
||||
CGContextMoveToPoint(context, inset, inset);
|
||||
CGContextAddLineToPoint(context, FBSDKCloseButtonWidth - inset, FBSDKCloseButtonHeight - inset);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
CGContextMoveToPoint(context, FBSDKCloseButtonWidth - inset, inset);
|
||||
CGContextAddLineToPoint(context, inset, FBSDKCloseButtonHeight - inset);
|
||||
CGContextStrokePath(context);
|
||||
|
||||
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *)localizedLabelForReferer:(NSString *)refererName {
|
||||
if (!refererName) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *format = NSLocalizedString(@"Touch to return to %1$@", @"Format for the string to return to a calling app.");
|
||||
return [NSString stringWithFormat:format, refererName];
|
||||
}
|
||||
|
||||
- (BOOL)hasRefererData {
|
||||
return _refererAppLink && _refererAppLink.targets[0];
|
||||
}
|
||||
|
||||
- (void)closeButtonTapped:(id)sender {
|
||||
[_delegate returnToRefererViewDidTapInsideCloseButton:self];
|
||||
}
|
||||
|
||||
- (void)onTapInside:(UIGestureRecognizer *)sender {
|
||||
[_delegate returnToRefererViewDidTapInsideLink:self link:_refererAppLink];
|
||||
}
|
||||
|
||||
- (void)updateHidden {
|
||||
[super setHidden:_explicitlyHidden || _closed || !self.hasRefererData];
|
||||
}
|
||||
|
||||
@end
|
||||
45
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkTarget.h
generated
Normal file
45
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkTarget.h
generated
Normal file
@ -0,0 +1,45 @@
|
||||
// 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
Represents a target defined in App Link metadata, consisting of at least
|
||||
a URL, and optionally an App Store ID and name.
|
||||
*/
|
||||
@interface FBSDKAppLinkTarget : NSObject
|
||||
|
||||
/*! Creates a FBSDKAppLinkTarget with the given app site and target URL. */
|
||||
+ (instancetype)appLinkTargetWithURL:(NSURL *)url
|
||||
appStoreId:(nullable NSString *)appStoreId
|
||||
appName:(NSString *)appName;
|
||||
|
||||
/*! The URL prefix for this app link target */
|
||||
@property (nonatomic, strong, readonly) NSURL *URL;
|
||||
|
||||
/*! The app ID for the app store */
|
||||
@property (nonatomic, copy, readonly, nullable) NSString *appStoreId;
|
||||
|
||||
/*! The name of the app */
|
||||
@property (nonatomic, copy, readonly) NSString *appName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
41
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkTarget.m
generated
Normal file
41
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkTarget.m
generated
Normal file
@ -0,0 +1,41 @@
|
||||
// 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 "FBSDKAppLinkTarget.h"
|
||||
|
||||
@interface FBSDKAppLinkTarget ()
|
||||
|
||||
@property (nonatomic, strong, readwrite) NSURL *URL;
|
||||
@property (nonatomic, copy, readwrite) NSString *appStoreId;
|
||||
@property (nonatomic, copy, readwrite) NSString *appName;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKAppLinkTarget
|
||||
|
||||
+ (instancetype)appLinkTargetWithURL:(NSURL *)url
|
||||
appStoreId:(NSString *)appStoreId
|
||||
appName:(NSString *)appName {
|
||||
FBSDKAppLinkTarget *target = [[self alloc] init];
|
||||
target.URL = url;
|
||||
target.appStoreId = appStoreId;
|
||||
target.appName = appName;
|
||||
return target;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -20,8 +20,8 @@
|
||||
|
||||
/**
|
||||
Describes the callback for fetchDeferredAppLink.
|
||||
- Parameter url: the url representing the deferred App Link
|
||||
- Parameter error: the error during the request, if any
|
||||
@param url the url representing the deferred App Link
|
||||
@param error the error during the request, if any
|
||||
|
||||
|
||||
The url may also have a fb_click_time_utc query parameter that
|
||||
@ -32,7 +32,7 @@ typedef void (^FBSDKDeferredAppLinkHandler)(NSURL *url, NSError *error);
|
||||
|
||||
/**
|
||||
Describes the callback for fetchOrganicDeferredAppLink.
|
||||
- Parameter url: the url representing the deferred App Link
|
||||
@param url the url representing the deferred App Link
|
||||
*/
|
||||
typedef void (^FBSDKDeferredAppInviteHandler)(NSURL *url);
|
||||
|
||||
@ -49,7 +49,7 @@ typedef void (^FBSDKDeferredAppInviteHandler)(NSURL *url);
|
||||
data (this will only return a valid URL once, and future calls will result in a nil URL
|
||||
value in the callback).
|
||||
|
||||
- Parameter handler: the handler to be invoked if there is deferred App Link data
|
||||
@param handler the handler to be invoked if there is deferred App Link data
|
||||
|
||||
|
||||
The handler may contain an NSError instance to capture any errors. In the
|
||||
@ -63,7 +63,7 @@ typedef void (^FBSDKDeferredAppInviteHandler)(NSURL *url);
|
||||
|
||||
/**
|
||||
|
||||
- Warning:This method is no longer available and will always return NO.
|
||||
@warning This method is no longer available and will always return NO.
|
||||
*/
|
||||
+ (BOOL)fetchDeferredAppInvite:(FBSDKDeferredAppInviteHandler)handler
|
||||
__attribute__((deprecated("This method is no longer available.")));;
|
||||
@ -75,9 +75,9 @@ __attribute__((deprecated("This method is no longer available.")));;
|
||||
Note: This throws an exception if Bolts.framework is not linked. Add '[BFURL class]' in intialize method
|
||||
of your AppDelegate.
|
||||
|
||||
- Parameter url: App Link url that was passed to the app.
|
||||
@param url App Link url that was passed to the app.
|
||||
|
||||
- Returns: Promotion code string.
|
||||
@return Promotion code string.
|
||||
|
||||
|
||||
Call this method to fetch App Invite Promotion Code from applink if present.
|
||||
|
||||
@ -41,15 +41,15 @@
|
||||
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
|
||||
with the native Facebook app or Safari as part of SSO authorization flow or Facebook dialogs.
|
||||
|
||||
- Parameter application: The application as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
@param application The application as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
|
||||
- Parameter url: The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
@param url The URL as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
|
||||
- Parameter sourceApplication: The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
@param sourceApplication The sourceApplication as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
|
||||
- Parameter annotation: The annotation as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
@param annotation The annotation as passed to [UIApplicationDelegate application:openURL:sourceApplication:annotation:].
|
||||
|
||||
- Returns: YES if the url was intended for the Facebook SDK, NO if not.
|
||||
@return YES if the url was intended for the Facebook SDK, NO if not.
|
||||
*/
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
@ -62,13 +62,13 @@
|
||||
of the AppDelegate for your app. It should be invoked for the proper processing of responses during interaction
|
||||
with the native Facebook app or Safari as part of SSO authorization flow or Facebook dialogs.
|
||||
|
||||
- Parameter application: The application as passed to [UIApplicationDelegate application:openURL:options:].
|
||||
@param application The application as passed to [UIApplicationDelegate application:openURL:options:].
|
||||
|
||||
- Parameter url: The URL as passed to [UIApplicationDelegate application:openURL:options:].
|
||||
@param url The URL as passed to [UIApplicationDelegate application:openURL:options:].
|
||||
|
||||
- Parameter options: The options dictionary as passed to [UIApplicationDelegate application:openURL:options:].
|
||||
@param options The options dictionary as passed to [UIApplicationDelegate application:openURL:options:].
|
||||
|
||||
- Returns: YES if the url was intended for the Facebook SDK, NO if not.
|
||||
@return YES if the url was intended for the Facebook SDK, NO if not.
|
||||
*/
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
@ -81,11 +81,11 @@
|
||||
As part of SDK initialization basic auto logging of app events will occur, this can be
|
||||
controlled via 'FacebookAutoLogAppEventsEnabled' key in the project info plist file.
|
||||
|
||||
- Parameter application: The application as passed to [UIApplicationDelegate application:didFinishLaunchingWithOptions:].
|
||||
@param application The application as passed to [UIApplicationDelegate application:didFinishLaunchingWithOptions:].
|
||||
|
||||
- Parameter launchOptions: The launchOptions as passed to [UIApplicationDelegate application:didFinishLaunchingWithOptions:].
|
||||
@param launchOptions The launchOptions as passed to [UIApplicationDelegate application:didFinishLaunchingWithOptions:].
|
||||
|
||||
- Returns: YES if the url was intended for the Facebook SDK, NO if not.
|
||||
@return YES if the url was intended for the Facebook SDK, NO if not.
|
||||
*/
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
|
||||
|
||||
|
||||
@ -56,10 +56,13 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
FBSDKBridgeAPICallbackBlock _pendingRequestCompletionBlock;
|
||||
id<FBSDKURLOpening> _pendingURLOpen;
|
||||
SFAuthenticationSession *_authenticationSession NS_AVAILABLE_IOS(11_0);
|
||||
SFAuthenticationCompletionHandler _authenticationSessionCompletionHandler NS_AVAILABLE_IOS(11_0);
|
||||
#endif
|
||||
BOOL _expectingBackground;
|
||||
BOOL _isRequestingSFAuthenticationSession;
|
||||
UIViewController *_safariViewController;
|
||||
BOOL _isDismissingSafariViewController;
|
||||
BOOL _isAppLaunched;
|
||||
}
|
||||
|
||||
#pragma mark - Class Methods
|
||||
@ -78,6 +81,9 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
+ (void)initializeWithLaunchData:(NSNotification *)note
|
||||
{
|
||||
NSDictionary *launchData = note.userInfo;
|
||||
|
||||
[[self sharedInstance] application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:launchData];
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
// Register Listener for Bolts measurement events
|
||||
[FBSDKBoltsMeasurementEventListener defaultListener];
|
||||
@ -112,6 +118,8 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
|
||||
[defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
|
||||
[defaultCenter addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||
|
||||
[[FBSDKAppEvents singleton] registerNotifications];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -156,12 +164,12 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
id<FBSDKURLOpening> pendingURLOpen = _pendingURLOpen;
|
||||
|
||||
void (^completePendingOpenURLBlock)(void) = ^{
|
||||
_pendingURLOpen = nil;
|
||||
self->_pendingURLOpen = nil;
|
||||
[pendingURLOpen application:application
|
||||
openURL:url
|
||||
sourceApplication:sourceApplication
|
||||
annotation:annotation];
|
||||
_isDismissingSafariViewController = NO;
|
||||
self->_isDismissingSafariViewController = NO;
|
||||
};
|
||||
// if they completed a SFVC flow, dismiss it.
|
||||
if (_safariViewController) {
|
||||
@ -195,12 +203,19 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
if (_isAppLaunched) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
_isAppLaunched = YES;
|
||||
FBSDKAccessToken *cachedToken = [[FBSDKSettings accessTokenCache] fetchAccessToken];
|
||||
[FBSDKAccessToken setCurrentAccessToken:cachedToken];
|
||||
// fetch app settings
|
||||
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:NULL];
|
||||
|
||||
[self _logSDKInitialize];
|
||||
if ([[FBSDKSettings autoLogAppEventsEnabled] boolValue]) {
|
||||
[self _logSDKInitialize];
|
||||
}
|
||||
#if !TARGET_OS_TV
|
||||
FBSDKProfile *cachedProfile = [FBSDKProfile fetchCachedProfile];
|
||||
[FBSDKProfile setCurrentProfile:cachedProfile];
|
||||
@ -226,6 +241,7 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
|
||||
- (void)applicationDidEnterBackground:(NSNotification *)notification
|
||||
{
|
||||
_isRequestingSFAuthenticationSession = NO;
|
||||
_active = NO;
|
||||
_expectingBackground = NO;
|
||||
}
|
||||
@ -239,9 +255,12 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
// _expectingBackground can be YES if the caller started doing work (like login)
|
||||
// within the app delegate's lifecycle like openURL, in which case there
|
||||
// might have been a "didBecomeActive" event pending that we want to ignore.
|
||||
BOOL notExpectingBackground = !_expectingBackground && !_safariViewController && !_isDismissingSafariViewController;
|
||||
BOOL notExpectingBackground = !_expectingBackground && !_safariViewController && !_isDismissingSafariViewController && !_isRequestingSFAuthenticationSession;
|
||||
#if !TARGET_OS_TV
|
||||
if (@available(iOS 11.0, *)) {
|
||||
if (notExpectingBackground && _authenticationSessionCompletionHandler != nil) {
|
||||
_authenticationSessionCompletionHandler(nil, nil);
|
||||
}
|
||||
notExpectingBackground = notExpectingBackground && !_authenticationSession;
|
||||
}
|
||||
#endif
|
||||
@ -309,8 +328,8 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
_pendingRequestCompletionBlock = [completionBlock copy];
|
||||
void (^handler)(BOOL, NSError *) = ^(BOOL openedURL, NSError *anError) {
|
||||
if (!openedURL) {
|
||||
_pendingRequest = nil;
|
||||
_pendingRequestCompletionBlock = nil;
|
||||
self->_pendingRequest = nil;
|
||||
self->_pendingRequestCompletionBlock = nil;
|
||||
NSError *openedURLError;
|
||||
if ([request.scheme hasPrefix:@"http"]) {
|
||||
openedURLError = [FBSDKError errorWithCode:FBSDKBrowserUnavailableErrorCode
|
||||
@ -349,13 +368,26 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
if ([sender isAuthenticationURL:url]) {
|
||||
Class SFAuthenticationSessionClass = fbsdkdfl_SFAuthenticationSessionClass();
|
||||
if (SFAuthenticationSessionClass != nil) {
|
||||
_authenticationSession = [[SFAuthenticationSessionClass alloc] initWithURL:url callbackURLScheme:[FBSDKInternalUtility appURLScheme] completionHandler:^ (NSURL *aURL, NSError *error) {
|
||||
if (_authenticationSession != nil) {
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
formatString:@"There is already a request for authenticated session. Cancelling active SFAuthenticationSession before starting the new one.", nil];
|
||||
[_authenticationSession cancel];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
_authenticationSessionCompletionHandler = ^ (NSURL *aURL, NSError *error) {
|
||||
typeof(self) strongSelf = weakSelf;
|
||||
strongSelf->_isRequestingSFAuthenticationSession = NO;
|
||||
handler(error == nil, error);
|
||||
if (error == nil) {
|
||||
[self application:[UIApplication sharedApplication] openURL:aURL sourceApplication:@"com.apple" annotation:nil];
|
||||
[strongSelf application:[UIApplication sharedApplication] openURL:aURL sourceApplication:@"com.apple" annotation:nil];
|
||||
}
|
||||
_authenticationSession = nil;
|
||||
}];
|
||||
strongSelf->_authenticationSession = nil;
|
||||
strongSelf->_authenticationSessionCompletionHandler = nil;
|
||||
};
|
||||
_authenticationSession = [[SFAuthenticationSessionClass alloc] initWithURL:url
|
||||
callbackURLScheme:[FBSDKInternalUtility appURLScheme]
|
||||
completionHandler:_authenticationSessionCompletionHandler];
|
||||
_isRequestingSFAuthenticationSession = YES;
|
||||
[_authenticationSession start];
|
||||
return;
|
||||
}
|
||||
@ -385,11 +417,11 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
// Wait until the transition is finished before presenting SafariVC to avoid a blank screen.
|
||||
[parent.transitionCoordinator animateAlongsideTransition:NULL completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
|
||||
// Note SFVC init must occur inside block to avoid blank screen.
|
||||
_safariViewController = [[SFSafariViewControllerClass alloc] initWithURL:url];
|
||||
self->_safariViewController = [[SFSafariViewControllerClass alloc] initWithURL:url];
|
||||
// Disable dismissing with edge pan gesture
|
||||
_safariViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
[_safariViewController performSelector:@selector(setDelegate:) withObject:self];
|
||||
[container displayChildController:_safariViewController];
|
||||
self->_safariViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
[self->_safariViewController performSelector:@selector(setDelegate:) withObject:self];
|
||||
[container displayChildController:self->_safariViewController];
|
||||
[parent presentViewController:container animated:YES completion:nil];
|
||||
}];
|
||||
} else {
|
||||
@ -507,6 +539,9 @@ static NSString *const FBSDKAppLinkInboundEvent = @"fb_al_inbound";
|
||||
if (objc_lookUpClass("FBSDKTVInterfaceFactory.m") != nil) {
|
||||
[params setObject:@1 forKey:@"tv_lib_included"];
|
||||
}
|
||||
if (objc_lookUpClass("FBSDKAutoLog") != nil) {
|
||||
[params setObject:@1 forKey:@"marketing_lib_included"];
|
||||
}
|
||||
[FBSDKAppEvents logEvent:@"fb_sdk_initialize" parameters:params];
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ typedef NS_ENUM(NSInteger, FBSDKErrorCode)
|
||||
|
||||
/**
|
||||
|
||||
- Warning:use FBSDKBrowserUnavailableErrorCode instead
|
||||
@warning use FBSDKBrowserUnavailableErrorCode instead
|
||||
*/
|
||||
FBSDKBrowswerUnavailableErrorCode __attribute__ ((deprecated("use FBSDKBrowserUnavailableErrorCode instead"))) = FBSDKBrowserUnavailableErrorCode,
|
||||
};
|
||||
@ -207,11 +207,11 @@ FBSDK_EXTERN NSString *const FBSDKGraphRequestErrorParsedJSONResponseKey;
|
||||
|
||||
/**
|
||||
attempt the recovery
|
||||
- Parameter error: the error
|
||||
- Parameter recoveryOptionIndex: the selected option index
|
||||
- Parameter delegate: the delegate
|
||||
- Parameter didRecoverSelector: the callback selector, see discussion.
|
||||
- Parameter contextInfo: context info to pass back to callback selector, see discussion.
|
||||
@param error the error
|
||||
@param recoveryOptionIndex the selected option index
|
||||
@param delegate the delegate
|
||||
@param didRecoverSelector the callback selector, see discussion.
|
||||
@param contextInfo context info to pass back to callback selector, see discussion.
|
||||
|
||||
|
||||
Given that an error alert has been presented document-modally to the user, and the user has chosen one of the error's recovery options, attempt recovery from the error, and send the selected message to the specified delegate. The option index is an index into the error's array of localized recovery options. The method selected by didRecoverSelector must have the same signature as:
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
/**
|
||||
Implemented by NSObject as a convenience to copyWithZone:.
|
||||
- Returns: A copy of the receiver.
|
||||
@return A copy of the receiver.
|
||||
*/
|
||||
- (id)copy;
|
||||
|
||||
|
||||
@ -33,16 +33,25 @@
|
||||
#import <FBSDKCoreKit/FBSDKUtility.h>
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
#import <FBSDKCoreKit/FBSDKAppLink.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkNavigation.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkResolver.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkResolving.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkReturnToRefererController.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkReturnToRefererView.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkTarget.h>
|
||||
#import <FBSDKCoreKit/FBSDKAppLinkUtility.h>
|
||||
#import <FBSDKCoreKit/FBSDKGraphErrorRecoveryProcessor.h>
|
||||
#import <FBSDKCoreKit/FBSDKMeasurementEvent.h>
|
||||
#import <FBSDKCoreKit/FBSDKMutableCopying.h>
|
||||
#import <FBSDKCoreKit/FBSDKProfile.h>
|
||||
#import <FBSDKCoreKit/FBSDKProfilePictureView.h>
|
||||
#import <FBSDKCoreKit/FBSDKURL.h>
|
||||
#import <FBSDKCoreKit/FBSDKWebViewAppLinkResolver.h>
|
||||
#else
|
||||
#import <FBSDKCoreKit/FBSDKDeviceButton.h>
|
||||
#import <FBSDKCoreKit/FBSDKDeviceViewControllerBase.h>
|
||||
#endif
|
||||
|
||||
#define FBSDK_VERSION_STRING @"4.33.0"
|
||||
#define FBSDK_TARGET_PLATFORM_VERSION @"v3.0"
|
||||
#define FBSDK_VERSION_STRING @"4.37.0"
|
||||
#define FBSDK_TARGET_PLATFORM_VERSION @"v3.1"
|
||||
|
||||
@ -30,17 +30,17 @@
|
||||
|
||||
/**
|
||||
Indicates the error recovery has been attempted.
|
||||
- Parameter processor: the processor instance.
|
||||
- Parameter didRecover: YES if the recovery was successful.
|
||||
- Parameter error: the error that that was attempted to be recovered from.
|
||||
@param processor the processor instance.
|
||||
@param didRecover YES if the recovery was successful.
|
||||
@param error the error that that was attempted to be recovered from.
|
||||
*/
|
||||
- (void)processorDidAttemptRecovery:(FBSDKGraphErrorRecoveryProcessor *)processor didRecover:(BOOL)didRecover error:(NSError *)error;
|
||||
|
||||
@optional
|
||||
/**
|
||||
Indicates the processor is about to process the error.
|
||||
- Parameter processor: the processor instance.
|
||||
- Parameter error: the error is about to be processed.
|
||||
@param processor the processor instance.
|
||||
@param error the error is about to be processed.
|
||||
|
||||
return NO if the processor should not process the error. For example,
|
||||
if you want to prevent alerts of localized messages but otherwise perform retries and recoveries,
|
||||
@ -83,16 +83,16 @@
|
||||
|
||||
/**
|
||||
Attempts to process the error, return YES if the error can be processed.
|
||||
- Parameter error: the error to process.
|
||||
- Parameter request: the related request that may be reissued.
|
||||
- Parameter delegate: the delegate that will be retained until recovery is complete.
|
||||
@param error the error to process.
|
||||
@param request the related request that may be reissued.
|
||||
@param delegate the delegate that will be retained until recovery is complete.
|
||||
*/
|
||||
- (BOOL)processError:(NSError *)error request:(FBSDKGraphRequest *)request delegate:(id<FBSDKGraphErrorRecoveryProcessorDelegate>) delegate;
|
||||
|
||||
/**
|
||||
The callback for FBSDKErrorRecoveryAttempting
|
||||
- Parameter didRecover: if the recovery succeeded
|
||||
- Parameter contextInfo: unused
|
||||
@param didRecover if the recovery succeeded
|
||||
@param contextInfo unused
|
||||
*/
|
||||
- (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo;
|
||||
|
||||
|
||||
@ -67,9 +67,9 @@
|
||||
// the block returns YES if recovery UI is started (meaning we wait for the alertviewdelegate to resume control flow).
|
||||
BOOL (^standardRecoveryWork)(void) = ^BOOL{
|
||||
NSArray *recoveryOptionsTitles = error.userInfo[NSLocalizedRecoveryOptionsErrorKey];
|
||||
if (recoveryOptionsTitles.count > 0 && _recoveryAttempter) {
|
||||
if (recoveryOptionsTitles.count > 0 && self->_recoveryAttempter) {
|
||||
NSString *recoverySuggestion = error.userInfo[NSLocalizedRecoverySuggestionErrorKey];
|
||||
_error = error;
|
||||
self->_error = error;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self displayAlertWithRecoverySuggestion:recoverySuggestion recoveryOptionsTitles:recoveryOptionsTitles];
|
||||
});
|
||||
@ -90,7 +90,7 @@
|
||||
[self.delegate processorDidAttemptRecovery:self didRecover:YES error:nil];
|
||||
self.delegate = nil;
|
||||
} else if (!standardRecoveryWork()) {
|
||||
[self.delegate processorDidAttemptRecovery:self didRecover:NO error:_error];
|
||||
[self.delegate processorDidAttemptRecovery:self didRecover:NO error:self->_error];
|
||||
};
|
||||
});
|
||||
}];
|
||||
@ -133,7 +133,7 @@
|
||||
UIAlertAction *option = [UIAlertAction actionWithTitle:title
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction * _Nonnull action) {
|
||||
[_recoveryAttempter attemptRecoveryFromError:_error
|
||||
[self->_recoveryAttempter attemptRecoveryFromError:self->_error
|
||||
optionIndex:i
|
||||
delegate:self
|
||||
didRecoverSelector:@selector(didPresentErrorWithRecovery:contextInfo:)
|
||||
@ -170,7 +170,7 @@
|
||||
UIAlertAction *OKAction = [UIAlertAction actionWithTitle:localizedOK
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:^(UIAlertAction * _Nonnull action) {
|
||||
[_recoveryAttempter attemptRecoveryFromError:_error
|
||||
[self->_recoveryAttempter attemptRecoveryFromError:self->_error
|
||||
optionIndex:0
|
||||
delegate:self
|
||||
didRecoverSelector:@selector(didPresentErrorWithRecovery:contextInfo:)
|
||||
|
||||
@ -39,23 +39,23 @@
|
||||
By default, FBSDKGraphRequest will attempt to recover any errors returned from
|
||||
Facebook. You can disable this via `disableErrorRecovery:`.
|
||||
|
||||
- See:FBSDKGraphErrorRecoveryProcessor
|
||||
@see FBSDKGraphErrorRecoveryProcessor
|
||||
*/
|
||||
@interface FBSDKGraphRequest : NSObject
|
||||
|
||||
/**
|
||||
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`.
|
||||
- Parameter graphPath: the graph path (e.g., @"me").
|
||||
- Parameter parameters: the optional parameters dictionary.
|
||||
@param graphPath the graph path (e.g., @"me").
|
||||
@param parameters the optional parameters dictionary.
|
||||
*/
|
||||
- (instancetype)initWithGraphPath:(NSString *)graphPath
|
||||
parameters:(NSDictionary *)parameters;
|
||||
|
||||
/**
|
||||
Initializes a new instance that use use `[FBSDKAccessToken currentAccessToken]`.
|
||||
- Parameter graphPath: the graph path (e.g., @"me").
|
||||
- Parameter parameters: the optional parameters dictionary.
|
||||
- Parameter HTTPMethod: the optional HTTP method. nil defaults to @"GET".
|
||||
@param graphPath the graph path (e.g., @"me").
|
||||
@param parameters the optional parameters dictionary.
|
||||
@param HTTPMethod the optional HTTP method. nil defaults to @"GET".
|
||||
*/
|
||||
- (instancetype)initWithGraphPath:(NSString *)graphPath
|
||||
parameters:(NSDictionary *)parameters
|
||||
@ -63,11 +63,11 @@
|
||||
|
||||
/**
|
||||
Initializes a new instance.
|
||||
- Parameter graphPath: the graph path (e.g., @"me").
|
||||
- Parameter parameters: the optional parameters dictionary.
|
||||
- Parameter tokenString: the token string to use. Specifying nil will cause no token to be used.
|
||||
- Parameter version: the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`.
|
||||
- Parameter HTTPMethod: the optional HTTP method (e.g., @"POST"). nil defaults to @"GET".
|
||||
@param graphPath the graph path (e.g., @"me").
|
||||
@param parameters the optional parameters dictionary.
|
||||
@param tokenString the token string to use. Specifying nil will cause no token to be used.
|
||||
@param version the optional Graph API version (e.g., @"v2.0"). nil defaults to `[FBSDKSettings graphAPIVersion]`.
|
||||
@param HTTPMethod the optional HTTP method (e.g., @"POST"). nil defaults to @"GET".
|
||||
*/
|
||||
- (instancetype)initWithGraphPath:(NSString *)graphPath
|
||||
parameters:(NSDictionary *)parameters
|
||||
@ -103,7 +103,7 @@ NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
If set, disables the automatic error recovery mechanism.
|
||||
- Parameter disable: whether to disable the automatic error recovery mechanism
|
||||
@param disable whether to disable the automatic error recovery mechanism
|
||||
|
||||
By default, non-batched FBSDKGraphRequest instances will automatically try to recover
|
||||
from errors by constructing a `FBSDKGraphErrorRecoveryProcessor` instance that
|
||||
@ -116,7 +116,7 @@ NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
/**
|
||||
Starts a connection to the Graph API.
|
||||
- Parameter handler: The handler block to call when the request completes.
|
||||
@param handler The handler block to call when the request completes.
|
||||
*/
|
||||
- (FBSDKGraphRequestConnection *)startWithCompletionHandler:(FBSDKGraphRequestHandler)handler;
|
||||
|
||||
|
||||
@ -34,13 +34,13 @@
|
||||
Pass a block of this type when calling addRequest. This will be called once
|
||||
the request completes. The call occurs on the UI thread.
|
||||
|
||||
- Parameter connection: The `FBSDKGraphRequestConnection` that sent the request.
|
||||
@param connection The `FBSDKGraphRequestConnection` that sent the request.
|
||||
|
||||
- Parameter result: The result of the request. This is a translation of
|
||||
@param result The result of the request. This is a translation of
|
||||
JSON data to `NSDictionary` and `NSArray` objects. This
|
||||
is nil if there was an error.
|
||||
|
||||
- Parameter error: The `NSError` representing any error that occurred.
|
||||
@param error The `NSError` representing any error that occurred.
|
||||
|
||||
*/
|
||||
typedef void (^FBSDKGraphRequestHandler)(FBSDKGraphRequestConnection *connection,
|
||||
@ -68,7 +68,7 @@ typedef void (^FBSDKGraphRequestHandler)(FBSDKGraphRequestConnection *connection
|
||||
start, the object returned from the convenience method has already begun loading and this method
|
||||
will not be called when the delegate is set.
|
||||
|
||||
- Parameter connection: The request connection that is starting a network request
|
||||
@param connection The request connection that is starting a network request
|
||||
*/
|
||||
- (void)requestConnectionWillBeginLoading:(FBSDKGraphRequestConnection *)connection;
|
||||
|
||||
@ -86,7 +86,7 @@ typedef void (^FBSDKGraphRequestHandler)(FBSDKGraphRequestConnection *connection
|
||||
|
||||
This method is invoked after the completion handler for each <FBSDKGraphRequest>.
|
||||
|
||||
- Parameter connection: The request connection that successfully completed a network request
|
||||
@param connection The request connection that successfully completed a network request
|
||||
*/
|
||||
- (void)requestConnectionDidFinishLoading:(FBSDKGraphRequestConnection *)connection;
|
||||
|
||||
@ -101,8 +101,8 @@ typedef void (^FBSDKGraphRequestHandler)(FBSDKGraphRequestConnection *connection
|
||||
argument specifies why the network connection failed. The `NSError` object passed to the
|
||||
FBSDKGraphRequestHandler block may contain additional information.
|
||||
|
||||
- Parameter connection: The request connection that successfully completed a network request
|
||||
- Parameter error: The `NSError` representing the network error that occurred, if any. May be nil
|
||||
@param connection The request connection that successfully completed a network request
|
||||
@param error The `NSError` representing the network error that occurred, if any. May be nil
|
||||
in some circumstances. Consult the `NSError` for the <FBSDKGraphRequest> for reliable
|
||||
failure information.
|
||||
*/
|
||||
@ -120,10 +120,10 @@ typedef void (^FBSDKGraphRequestHandler)(FBSDKGraphRequestConnection *connection
|
||||
|
||||
Like `NSURLConnection`, the values may change in unexpected ways if data needs to be resent.
|
||||
|
||||
- Parameter connection: The request connection transmitting data to a remote host
|
||||
- Parameter bytesWritten: The number of bytes sent in the last transmission
|
||||
- Parameter totalBytesWritten: The total number of bytes sent to the remote host
|
||||
- Parameter totalBytesExpectedToWrite: The total number of bytes expected to send to the remote host
|
||||
@param connection The request connection transmitting data to a remote host
|
||||
@param bytesWritten The number of bytes sent in the last transmission
|
||||
@param totalBytesWritten The total number of bytes sent to the remote host
|
||||
@param totalBytesExpectedToWrite The total number of bytes expected to send to the remote host
|
||||
*/
|
||||
- (void)requestConnection:(FBSDKGraphRequestConnection *)connection
|
||||
didSendBodyData:(NSInteger)bytesWritten
|
||||
@ -177,7 +177,7 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
|
||||
|
||||
This method sets the default timeout on all FBSDKGraphRequestConnection instances. Defaults to 60 seconds.
|
||||
|
||||
- Parameter defaultConnectionTimeout: The timeout interval.
|
||||
@param defaultConnectionTimeout The timeout interval.
|
||||
*/
|
||||
+ (void)setDefaultConnectionTimeout:(NSTimeInterval)defaultConnectionTimeout;
|
||||
|
||||
@ -190,8 +190,8 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
|
||||
|
||||
This method adds an <FBSDKGraphRequest> object to this connection.
|
||||
|
||||
- Parameter request: A request to be included in the round-trip when start is called.
|
||||
- Parameter handler: A handler to call back when the round-trip completes or times out.
|
||||
@param request A request to be included in the round-trip when start is called.
|
||||
@param handler A handler to call back when the round-trip completes or times out.
|
||||
|
||||
|
||||
|
||||
@ -206,12 +206,12 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
|
||||
|
||||
This method adds an <FBSDKGraphRequest> object to this connection.
|
||||
|
||||
- Parameter request: A request to be included in the round-trip when start is called.
|
||||
@param request A request to be included in the round-trip when start is called.
|
||||
|
||||
- Parameter handler: A handler to call back when the round-trip completes or times out.
|
||||
@param handler A handler to call back when the round-trip completes or times out.
|
||||
The handler will be invoked on the main thread.
|
||||
|
||||
- Parameter name: An optional name for this request. This can be used to feed
|
||||
@param name An optional name for this request. This can be used to feed
|
||||
the results of one request to the input of another <FBSDKGraphRequest> in the same
|
||||
`FBSDKGraphRequestConnection` as described in
|
||||
[Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
|
||||
@ -231,11 +231,11 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
|
||||
|
||||
This method adds an <FBSDKGraphRequest> object to this connection.
|
||||
|
||||
- Parameter request: A request to be included in the round-trip when start is called.
|
||||
@param request A request to be included in the round-trip when start is called.
|
||||
|
||||
- Parameter handler: A handler to call back when the round-trip completes or times out.
|
||||
@param handler A handler to call back when the round-trip completes or times out.
|
||||
|
||||
- Parameter batchParameters: The optional dictionary of parameters to include for this request
|
||||
@param batchParameters The optional dictionary of parameters to include for this request
|
||||
as described in [Graph API Batch Requests]( https://developers.facebook.com/docs/reference/api/batch/ ).
|
||||
Examples include "depends_on", "name", or "omit_response_on_success".
|
||||
|
||||
@ -285,7 +285,7 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
|
||||
|
||||
/**
|
||||
Determines the operation queue that is used to call methods on the connection's delegate.
|
||||
- Parameter queue: The operation queue to use when calling delegate methods.
|
||||
@param queue The operation queue to use when calling delegate methods.
|
||||
|
||||
By default, a connection is scheduled on the current thread in the default mode when it is created.
|
||||
You cannot reschedule a connection after it has started.
|
||||
@ -305,7 +305,7 @@ totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
|
||||
for applications. If you want to override the version part while using batch requests on the connection, call
|
||||
this method to set the version for the batch request.
|
||||
|
||||
- Parameter version: This is a string in the form @"v2.0" which will be used for the version part of an API path
|
||||
@param version This is a string in the form @"v2.0" which will be used for the version part of an API path
|
||||
*/
|
||||
- (void)overrideVersionPartWith:(NSString *)version;
|
||||
|
||||
|
||||
@ -76,7 +76,8 @@ static FBSDKAccessToken *_CreateExpiredAccessToken(FBSDKAccessToken *accessToken
|
||||
appID:accessToken.appID
|
||||
userID:accessToken.userID
|
||||
expirationDate:expirationDate
|
||||
refreshDate:expirationDate];
|
||||
refreshDate:expirationDate
|
||||
dataAccessExpirationDate:expirationDate];
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -726,9 +727,9 @@ NSURLSessionDataDelegate
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
if (resultError && ![metadata.request isGraphErrorRecoveryDisabled] && isSingleRequestToRecover) {
|
||||
_recoveringRequestMetadata = metadata;
|
||||
_errorRecoveryProcessor = [[FBSDKGraphErrorRecoveryProcessor alloc] init];
|
||||
if ([_errorRecoveryProcessor processError:resultError request:metadata.request delegate:self]) {
|
||||
self->_recoveringRequestMetadata = metadata;
|
||||
self->_errorRecoveryProcessor = [[FBSDKGraphErrorRecoveryProcessor alloc] init];
|
||||
if ([self->_errorRecoveryProcessor processError:resultError request:metadata.request delegate:self]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -753,9 +754,9 @@ NSURLSessionDataDelegate
|
||||
}
|
||||
[metadata invokeCompletionHandlerForConnection:self withResults:body error:error];
|
||||
|
||||
if (--_expectingResults == 0) {
|
||||
if (canNotifyDelegate && [_delegate respondsToSelector:@selector(requestConnectionDidFinishLoading:)]) {
|
||||
[_delegate requestConnectionDidFinishLoading:self];
|
||||
if (--self->_expectingResults == 0) {
|
||||
if (canNotifyDelegate && [self->_delegate respondsToSelector:@selector(requestConnectionDidFinishLoading:)]) {
|
||||
[self->_delegate requestConnectionDidFinishLoading:self];
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -793,7 +794,7 @@ NSURLSessionDataDelegate
|
||||
adapter.forceBlockingRenew = YES;
|
||||
} else {
|
||||
[adapter renewSystemAuthorization:^(ACAccountCredentialRenewResult result, NSError *renewError) {
|
||||
NSOperationQueue *queue = _delegateQueue ?: [NSOperationQueue mainQueue];
|
||||
NSOperationQueue *queue = self->_delegateQueue ?: [NSOperationQueue mainQueue];
|
||||
[queue addOperationWithBlock:^{
|
||||
clearToken(errorSubcode);
|
||||
finishAndInvokeCompletionHandler();
|
||||
@ -806,7 +807,7 @@ NSURLSessionDataDelegate
|
||||
} else if (errorCode >= 200 && errorCode < 300) {
|
||||
// permission error
|
||||
[adapter renewSystemAuthorization:^(ACAccountCredentialRenewResult result, NSError *renewError) {
|
||||
NSOperationQueue *queue = _delegateQueue ?: [NSOperationQueue mainQueue];
|
||||
NSOperationQueue *queue = self->_delegateQueue ?: [NSOperationQueue mainQueue];
|
||||
[queue addOperationWithBlock:finishAndInvokeCompletionHandler];
|
||||
}];
|
||||
return;
|
||||
@ -1028,8 +1029,8 @@ totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend
|
||||
FBSDKGraphRequestMetadata *retryMetadata = [[FBSDKGraphRequestMetadata alloc] initWithRequest:retryRequest completionHandler:_recoveringRequestMetadata.completionHandler batchParameters:_recoveringRequestMetadata.batchParameters];
|
||||
[retryRequest startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *retriedError) {
|
||||
[self processResultBody:result error:retriedError metadata:retryMetadata canNotifyDelegate:YES];
|
||||
_errorRecoveryProcessor = nil;
|
||||
_recoveringRequestMetadata = nil;
|
||||
self->_errorRecoveryProcessor = nil;
|
||||
self->_recoveringRequestMetadata = nil;
|
||||
}];
|
||||
} else {
|
||||
[self processResultBody:nil error:error metadata:_recoveringRequestMetadata canNotifyDelegate:YES];
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
|
||||
/**
|
||||
Initializes the receiver with the attachment data and metadata.
|
||||
- Parameter data: The attachment data (retained, not copied)
|
||||
- Parameter filename: The filename for the attachment
|
||||
- Parameter contentType: The content type for the attachment
|
||||
@param data The attachment data (retained, not copied)
|
||||
@param filename The filename for the attachment
|
||||
@param contentType The content type for the attachment
|
||||
*/
|
||||
- (instancetype)initWithData:(NSData *)data
|
||||
filename:(NSString *)filename
|
||||
|
||||
57
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKMeasurementEvent.h
generated
Normal file
57
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKMeasurementEvent.h
generated
Normal file
@ -0,0 +1,57 @@
|
||||
// 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*! The name of the notification posted by FBSDKMeasurementEvent */
|
||||
FOUNDATION_EXPORT NSString *const FBSDKMeasurementEventNotificationName;
|
||||
|
||||
/*! Defines keys in the userInfo object for the notification named FBSDKMeasurementEventNotificationName */
|
||||
/*! The string field for the name of the event */
|
||||
FOUNDATION_EXPORT NSString *const FBSDKMeasurementEventNameKey;
|
||||
/*! The dictionary field for the arguments of the event */
|
||||
FOUNDATION_EXPORT NSString *const FBSDKMeasurementEventArgsKey;
|
||||
|
||||
/*! Events raised by FBSDKMeasurementEvent for Applink */
|
||||
/*!
|
||||
The name of the event posted when [FBSDKURL URLWithURL:] is called successfully. This represents the successful parsing of an app link URL.
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkParseEventName;
|
||||
|
||||
/*!
|
||||
The name of the event posted when [FBSDKURL URLWithInboundURL:] is called successfully.
|
||||
This represents parsing an inbound app link URL from a different application
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkNavigateInEventName;
|
||||
|
||||
/*! The event raised when the user navigates from your app to other apps */
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkNavigateOutEventName;
|
||||
|
||||
/*!
|
||||
The event raised when the user navigates out from your app and back to the referrer app.
|
||||
e.g when the user leaves your app after tapping the back-to-referrer navigation bar
|
||||
*/
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkNavigateBackToReferrerEventName;
|
||||
|
||||
@interface FBSDKMeasurementEvent : NSObject
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
68
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKMeasurementEvent.m
generated
Normal file
68
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKMeasurementEvent.m
generated
Normal file
@ -0,0 +1,68 @@
|
||||
// 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 "FBSDKMeasurementEvent_Internal.h"
|
||||
|
||||
NSString *const FBSDKMeasurementEventNotificationName = @"com.facebook.facebook-objc-sdk.measurement_event";
|
||||
|
||||
NSString *const FBSDKMeasurementEventNameKey = @"event_name";
|
||||
NSString *const FBSDKMeasurementEventArgsKey = @"event_args";
|
||||
|
||||
/* app Link Event raised by this FBSDKURL */
|
||||
NSString *const FBSDKAppLinkParseEventName = @"al_link_parse";
|
||||
NSString *const FBSDKAppLinkNavigateInEventName = @"al_nav_in";
|
||||
|
||||
/*! AppLink events raised in this class */
|
||||
NSString *const FBSDKAppLinkNavigateOutEventName = @"al_nav_out";
|
||||
NSString *const FBSDKAppLinkNavigateBackToReferrerEventName = @"al_ref_back_out";
|
||||
|
||||
@implementation FBSDKMeasurementEvent {
|
||||
NSString *_name;
|
||||
NSDictionary<NSString *, id> *_args;
|
||||
}
|
||||
|
||||
- (void)postNotification {
|
||||
if (!_name) {
|
||||
NSLog(@"Warning: Missing event name when logging FBSDK measurement event. \n"
|
||||
" Ignoring this event in logging.");
|
||||
return;
|
||||
}
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
NSDictionary<NSString *, id> *userInfo = @{FBSDKMeasurementEventNameKey : _name,
|
||||
FBSDKMeasurementEventArgsKey : _args};
|
||||
|
||||
[center postNotificationName:FBSDKMeasurementEventNotificationName
|
||||
object:self
|
||||
userInfo:userInfo];
|
||||
}
|
||||
|
||||
- (instancetype)initEventWithName:(NSString *)name
|
||||
args:(NSDictionary<NSString *, id> *)args {
|
||||
if ((self = [super init])) {
|
||||
_name = name;
|
||||
_args = args ? args : @{};
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)postNotificationForEventName:(NSString *)name
|
||||
args:(NSDictionary<NSString *, id> *)args {
|
||||
[[[self alloc] initEventWithName:name args:args] postNotification];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
/**
|
||||
Implemented by NSObject as a convenience to mutableCopyWithZone:.
|
||||
- Returns: A mutable copy of the receiver.
|
||||
@return A mutable copy of the receiver.
|
||||
*/
|
||||
- (id)mutableCopy;
|
||||
|
||||
|
||||
@ -56,13 +56,13 @@ FBSDK_EXTERN NSString *const FBSDKProfileChangeNewKey;
|
||||
|
||||
/**
|
||||
initializes a new instance.
|
||||
- Parameter userID: the user ID
|
||||
- Parameter firstName: the user's first name
|
||||
- Parameter middleName: the user's middle name
|
||||
- Parameter lastName: the user's last name
|
||||
- Parameter name: the user's complete name
|
||||
- Parameter linkURL: the link for this profile
|
||||
- Parameter refreshDate: the optional date this profile was fetched. Defaults to [NSDate date].
|
||||
@param userID the user ID
|
||||
@param firstName the user's first name
|
||||
@param middleName the user's middle name
|
||||
@param lastName the user's last name
|
||||
@param name the user's complete name
|
||||
@param linkURL the link for this profile
|
||||
@param refreshDate the optional date this profile was fetched. Defaults to [NSDate date].
|
||||
*/
|
||||
- (instancetype)initWithUserID:(NSString *)userID
|
||||
firstName:(NSString *)firstName
|
||||
@ -112,7 +112,7 @@ FBSDK_EXTERN NSString *const FBSDKProfileChangeNewKey;
|
||||
/**
|
||||
Sets the current instance and posts the appropriate notification if the profile parameter is different
|
||||
than the receiver.
|
||||
- Parameter profile: the profile to set
|
||||
@param profile the profile to set
|
||||
|
||||
This persists the profile to NSUserDefaults.
|
||||
*/
|
||||
@ -120,7 +120,7 @@ FBSDK_EXTERN NSString *const FBSDKProfileChangeNewKey;
|
||||
|
||||
/**
|
||||
Indicates if `currentProfile` will automatically observe `FBSDKAccessTokenDidChangeNotification` notifications
|
||||
- Parameter enable: YES is observing
|
||||
@param enable YES is observing
|
||||
|
||||
If observing, this class will issue a graph request for public profile data when the current token's userID
|
||||
differs from the current profile. You can observe `FBSDKProfileDidChangeNotification` for when the profile is updated.
|
||||
@ -132,7 +132,7 @@ FBSDK_EXTERN NSString *const FBSDKProfileChangeNewKey;
|
||||
|
||||
/**
|
||||
Loads the current profile and passes it to the completion block.
|
||||
- Parameter completion: The block to be executed once the profile is loaded
|
||||
@param completion The block to be executed once the profile is loaded
|
||||
|
||||
If the profile is already loaded, this method will call the completion block synchronously, otherwise it
|
||||
will begin a graph request to update `currentProfile` and then call the completion block when finished.
|
||||
@ -141,26 +141,26 @@ FBSDK_EXTERN NSString *const FBSDKProfileChangeNewKey;
|
||||
|
||||
/**
|
||||
A convenience method for returning a complete `NSURL` for retrieving the user's profile image.
|
||||
- Parameter mode: The picture mode
|
||||
- Parameter size: The height and width. This will be rounded to integer precision.
|
||||
@param mode The picture mode
|
||||
@param size The height and width. This will be rounded to integer precision.
|
||||
*/
|
||||
- (NSURL *)imageURLForPictureMode:(FBSDKProfilePictureMode)mode size:(CGSize)size;
|
||||
|
||||
/**
|
||||
A convenience method for returning a Graph API path for retrieving the user's profile image.
|
||||
|
||||
- Warning:use `imageURLForPictureMode:size:` instead
|
||||
@warning use `imageURLForPictureMode:size:` instead
|
||||
|
||||
You can pass this to a `FBSDKGraphRequest` instance to download the image.
|
||||
- Parameter mode: The picture mode
|
||||
- Parameter size: The height and width. This will be rounded to integer precision.
|
||||
@param mode The picture mode
|
||||
@param size The height and width. This will be rounded to integer precision.
|
||||
*/
|
||||
- (NSString *)imagePathForPictureMode:(FBSDKProfilePictureMode)mode size:(CGSize)size
|
||||
__attribute__ ((deprecated("use imageURLForPictureMode:size: instead")));
|
||||
|
||||
/**
|
||||
Returns YES if the profile is equivalent to the receiver.
|
||||
- Parameter profile: the profile to compare to.
|
||||
@param profile the profile to compare to.
|
||||
*/
|
||||
- (BOOL)isEqualToProfile:(FBSDKProfile *)profile;
|
||||
@end
|
||||
|
||||
@ -67,7 +67,7 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
|
||||
/**
|
||||
Set the Facebook App ID to be used by the SDK.
|
||||
- Parameter appID: The Facebook App ID to be used by the SDK.
|
||||
@param appID The Facebook App ID to be used by the SDK.
|
||||
*/
|
||||
+ (void)setAppID:(NSString *)appID;
|
||||
|
||||
@ -80,7 +80,7 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
|
||||
/**
|
||||
Set the app url scheme suffix used by the SDK.
|
||||
- Parameter appURLSchemeSuffix: The url scheme suffix to be used by the SDK.
|
||||
@param appURLSchemeSuffix The url scheme suffix to be used by the SDK.
|
||||
*/
|
||||
+ (void)setAppURLSchemeSuffix:(NSString *)appURLSchemeSuffix;
|
||||
|
||||
@ -95,14 +95,14 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
Sets the Client Token for the Facebook App.
|
||||
|
||||
This is needed for certain API calls when made anonymously, without a user-based access token.
|
||||
- Parameter clientToken: The Facebook App's "client token", which, for a given appid can be found in the Security
|
||||
@param clientToken The Facebook App's "client token", which, for a given appid can be found in the Security
|
||||
section of the Advanced tab of the Facebook App settings found at <https://developers.facebook.com/apps/[your-app-id]>
|
||||
*/
|
||||
+ (void)setClientToken:(NSString *)clientToken;
|
||||
|
||||
/**
|
||||
A convenient way to toggle error recovery for all FBSDKGraphRequest instances created after this is set.
|
||||
- Parameter disableGraphErrorRecovery: YES or NO.
|
||||
@param disableGraphErrorRecovery YES or NO.
|
||||
*/
|
||||
+ (void)setGraphErrorRecoveryDisabled:(BOOL)disableGraphErrorRecovery;
|
||||
|
||||
@ -118,7 +118,7 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
|
||||
This should match the Display Name that has been set for the app with the corresponding Facebook App ID,
|
||||
in the Facebook App Dashboard.
|
||||
- Parameter displayName: The Facebook Display Name to be used by the SDK.
|
||||
@param displayName The Facebook Display Name to be used by the SDK.
|
||||
*/
|
||||
+ (void)setDisplayName:(NSString *)displayName;
|
||||
|
||||
@ -134,7 +134,7 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
|
||||
This can be used to change the Facebook domain (e.g. @"beta") so that requests will be sent to
|
||||
graph.beta.facebook.com
|
||||
- Parameter facebookDomainPart: The domain part to be inserted into facebook.com.
|
||||
@param facebookDomainPart The domain part to be inserted into facebook.com.
|
||||
*/
|
||||
+ (void)setFacebookDomainPart:(NSString *)facebookDomainPart;
|
||||
|
||||
@ -143,14 +143,14 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
|
||||
If not explicitly set, the default is 0.9.
|
||||
|
||||
- See:[UIImageJPEGRepresentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIImageJPEGRepresentation) */
|
||||
@see [UIImageJPEGRepresentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIImageJPEGRepresentation) */
|
||||
+ (CGFloat)JPEGCompressionQuality;
|
||||
|
||||
/**
|
||||
Set the quality of JPEG images sent to Facebook from the SDK.
|
||||
- Parameter JPEGCompressionQuality: The quality for JPEG images, expressed as a value from 0.0 to 1.0.
|
||||
@param JPEGCompressionQuality The quality for JPEG images, expressed as a value from 0.0 to 1.0.
|
||||
|
||||
- See:[UIImageJPEGRepresentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIImageJPEGRepresentation) */
|
||||
@see [UIImageJPEGRepresentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/#//apple_ref/c/func/UIImageJPEGRepresentation) */
|
||||
+ (void)setJPEGCompressionQuality:(CGFloat)JPEGCompressionQuality;
|
||||
|
||||
/**
|
||||
@ -161,10 +161,22 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
|
||||
/**
|
||||
Set the flag which controls the auto logging of basic app events, such as activateApp and deactivateApp.
|
||||
- Parameter AutoLogAppEventsEnabled: Flag value, expressed as a value from 0 - false or 1 - true.
|
||||
@param AutoLogAppEventsEnabled Flag value, expressed as a value from 0 - false or 1 - true.
|
||||
*/
|
||||
+ (void)setAutoLogAppEventsEnabled:(NSNumber *)AutoLogAppEventsEnabled;
|
||||
|
||||
/**
|
||||
Flag which controls the fb_codeless_debug logging event
|
||||
If not explicitly set, the default is 1 - true
|
||||
*/
|
||||
+ (NSNumber *)codelessDebugLogEnabled;
|
||||
|
||||
/**
|
||||
Set the flag which controls the fb_codeless_debug logging event
|
||||
@param CodelessDebugLogEnabled Flag value, expressed as a value from 0 - false or 1 - true.
|
||||
*/
|
||||
+ (void)setCodelessDebugLogEnabled:(NSNumber *)CodelessDebugLogEnabled;
|
||||
|
||||
/**
|
||||
Gets whether data such as that generated through FBSDKAppEvents and sent to Facebook should be restricted from being used for other than analytics and conversions. Defaults to NO. This value is stored on the device and persists across app launches.
|
||||
*/
|
||||
@ -173,7 +185,7 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
/**
|
||||
Sets whether data such as that generated through FBSDKAppEvents and sent to Facebook should be restricted from being used for other than analytics and conversions. Defaults to NO. This value is stored on the device and persists across app launches.
|
||||
|
||||
- Parameter limitEventAndDataUsage: The desired value.
|
||||
@param limitEventAndDataUsage The desired value.
|
||||
*/
|
||||
+ (void)setLimitEventAndDataUsage:(BOOL)limitEventAndDataUsage;
|
||||
|
||||
@ -191,7 +203,7 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
Set the current Facebook SDK logging behavior. This should consist of strings defined as
|
||||
constants with FBSDKLoggingBehavior*.
|
||||
|
||||
- Parameter loggingBehavior: A set of strings indicating what information should be logged. If nil is provided, the logging
|
||||
@param loggingBehavior A set of strings indicating what information should be logged. If nil is provided, the logging
|
||||
behavior is reset to the default set of enabled behaviors. Set to an empty set in order to disable all logging.
|
||||
|
||||
|
||||
@ -202,21 +214,21 @@ FBSDK_EXTERN NSString *const FBSDKLoggingBehaviorDeveloperErrors;
|
||||
/**
|
||||
Enable a particular Facebook SDK logging behavior.
|
||||
|
||||
- Parameter loggingBehavior: The LoggingBehavior to enable. This should be a string defined as a constant with FBSDKLoggingBehavior*.
|
||||
@param loggingBehavior The LoggingBehavior to enable. This should be a string defined as a constant with FBSDKLoggingBehavior*.
|
||||
*/
|
||||
+ (void)enableLoggingBehavior:(NSString *)loggingBehavior;
|
||||
|
||||
/**
|
||||
Disable a particular Facebook SDK logging behavior.
|
||||
|
||||
- Parameter loggingBehavior: The LoggingBehavior to disable. This should be a string defined as a constant with FBSDKLoggingBehavior*.
|
||||
@param loggingBehavior The LoggingBehavior to disable. This should be a string defined as a constant with FBSDKLoggingBehavior*.
|
||||
*/
|
||||
+ (void)disableLoggingBehavior:(NSString *)loggingBehavior;
|
||||
|
||||
/**
|
||||
Set the user defaults key used by legacy token caches.
|
||||
|
||||
- Parameter tokenInformationKeyName: the key used by legacy token caches.
|
||||
@param tokenInformationKeyName the key used by legacy token caches.
|
||||
|
||||
|
||||
Use this only if you customized FBSessionTokenCachingStrategy in v3.x of
|
||||
|
||||
@ -75,6 +75,8 @@ FBSDKSETTINGS_PLIST_CONFIGURATION_SETTING_IMPL(NSString, FacebookDomainPart, fac
|
||||
FBSDKSETTINGS_PLIST_CONFIGURATION_SETTING_IMPL(NSNumber, FacebookJpegCompressionQuality, _JPEGCompressionQualityNumber, _setJPEGCompressionQualityNumber, @0.9);
|
||||
FBSDKSETTINGS_PLIST_CONFIGURATION_SETTING_IMPL(NSNumber, FacebookAutoLogAppEventsEnabled, autoLogAppEventsEnabled,
|
||||
setAutoLogAppEventsEnabled, @1);
|
||||
FBSDKSETTINGS_PLIST_CONFIGURATION_SETTING_IMPL(NSNumber, FacebookCodelessDebugLogEnabled, codelessDebugLogEnabled,
|
||||
setCodelessDebugLogEnabled, @0);
|
||||
|
||||
+ (void)setGraphErrorRecoveryDisabled:(BOOL)disableGraphErrorRecovery {
|
||||
g_disableErrorRecovery = disableGraphErrorRecovery;
|
||||
|
||||
@ -50,20 +50,20 @@ typedef void (^FBSDKTestUsersManagerRemoveTestAccountHandler)(NSError *error) ;
|
||||
|
||||
/**
|
||||
construct or return the shared instance
|
||||
- Parameter appID: the Facebook app id
|
||||
- Parameter appSecret: the Facebook app secret
|
||||
@param appID the Facebook app id
|
||||
@param appSecret the Facebook app secret
|
||||
*/
|
||||
+ (instancetype)sharedInstanceForAppID:(NSString *)appID appSecret:(NSString *)appSecret;
|
||||
|
||||
/**
|
||||
retrieve FBSDKAccessToken instances for test accounts with the specific permissions.
|
||||
- Parameter arraysOfPermissions: an array of permissions sets, such as @[ [NSSet setWithObject:@"email"], [NSSet setWithObject:@"user_birthday"]]
|
||||
@param arraysOfPermissions an array of permissions sets, such as @[ [NSSet setWithObject:@"email"], [NSSet setWithObject:@"user_birthday"]]
|
||||
if you needed two test accounts with email and birthday permissions, respectively. You can pass in empty nested sets
|
||||
if you need two arbitrary test accounts. For convenience, passing nil is treated as @[ [NSSet set] ]
|
||||
for fetching a single test user.
|
||||
- Parameter createIfNotFound: if YES, new test accounts are created if no test accounts existed that fit the permissions
|
||||
@param createIfNotFound if YES, new test accounts are created if no test accounts existed that fit the permissions
|
||||
requirement
|
||||
- Parameter handler: the callback to invoke which will return an array of `FBAccessTokenData` instances or an `NSError`.
|
||||
@param handler the callback to invoke which will return an array of `FBAccessTokenData` instances or an `NSError`.
|
||||
If param `createIfNotFound` is NO, the array may contain `[NSNull null]` instances.
|
||||
|
||||
|
||||
@ -77,24 +77,24 @@ typedef void (^FBSDKTestUsersManagerRemoveTestAccountHandler)(NSError *error) ;
|
||||
|
||||
/**
|
||||
add a test account with the specified permissions
|
||||
- Parameter permissions: the set of permissions, e.g., [NSSet setWithObjects:@"email", @"user_friends"]
|
||||
- Parameter handler: the callback handler
|
||||
@param permissions the set of permissions, e.g., [NSSet setWithObjects:@"email", @"user_friends"]
|
||||
@param handler the callback handler
|
||||
*/
|
||||
- (void)addTestAccountWithPermissions:(NSSet *)permissions
|
||||
completionHandler:(FBSDKTestUsersManagerRetrieveTestAccountTokensHandler)handler;
|
||||
|
||||
/**
|
||||
remove a test account for the given user id
|
||||
- Parameter userId: the user id
|
||||
- Parameter handler: the callback handler
|
||||
@param userId the user id
|
||||
@param handler the callback handler
|
||||
*/
|
||||
- (void)removeTestAccount:(NSString *)userId completionHandler:(FBSDKTestUsersManagerRemoveTestAccountHandler)handler;
|
||||
|
||||
/**
|
||||
Make two test users friends with each other.
|
||||
- Parameter first: the token of the first user
|
||||
- Parameter second: the token of the second user
|
||||
- Parameter callback: the callback handler
|
||||
@param first the token of the first user
|
||||
@param second the token of the second user
|
||||
@param callback the callback handler
|
||||
*/
|
||||
- (void)makeFriendsWithFirst:(FBSDKAccessToken *)first second:(FBSDKAccessToken *)second callback:(void (^)(NSError *))callback;
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ static NSMutableDictionary *gInstancesDictionary;
|
||||
NSMutableDictionary *accountData = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||
accountData[kAccountsDictionaryPermissionsKey] = [NSSet setWithSet:permissions];
|
||||
accountData[kAccountsDictionaryTokenKey] = result[@"access_token"];
|
||||
_accounts[result[@"id"]] = accountData;
|
||||
self->_accounts[result[@"id"]] = accountData;
|
||||
|
||||
if (handler) {
|
||||
FBSDKAccessToken *token = [self tokenDataForTokenString:accountData[kAccountsDictionaryTokenKey]
|
||||
@ -216,7 +216,8 @@ static NSMutableDictionary *gInstancesDictionary;
|
||||
appID:_appID
|
||||
userID:userId
|
||||
expirationDate:nil
|
||||
refreshDate:nil];
|
||||
refreshDate:nil
|
||||
dataAccessExpirationDate:nil];
|
||||
}
|
||||
|
||||
- (NSArray *)userIdAndTokenOfExistingAccountWithPermissions:(NSSet *)permissions skip:(NSSet *)setToSkip {
|
||||
@ -264,15 +265,15 @@ static NSMutableDictionary *gInstancesDictionary;
|
||||
handler(error);
|
||||
}
|
||||
// on errors, clear out accounts since it may be in a bad state
|
||||
[_accounts removeAllObjects];
|
||||
[self->_accounts removeAllObjects];
|
||||
return;
|
||||
} else {
|
||||
for (NSDictionary *account in result[@"data"]) {
|
||||
NSString *userId = account[@"id"];
|
||||
NSString *token = account[@"access_token"];
|
||||
if (userId && token) {
|
||||
_accounts[userId] = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||
_accounts[userId][kAccountsDictionaryTokenKey] = token;
|
||||
self->_accounts[userId] = [NSMutableDictionary dictionaryWithCapacity:2];
|
||||
self->_accounts[userId][kAccountsDictionaryTokenKey] = token;
|
||||
expectedTestAccounts++;
|
||||
[permissionConnection addRequest:[[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"%@?fields=permissions", userId]
|
||||
parameters:nil
|
||||
@ -280,7 +281,7 @@ static NSMutableDictionary *gInstancesDictionary;
|
||||
version:nil
|
||||
HTTPMethod:nil]
|
||||
completionHandler:^(FBSDKGraphRequestConnection *innerConnection2, id innerResult, NSError *innerError) {
|
||||
if (_accounts.count == 0) {
|
||||
if (self->_accounts.count == 0) {
|
||||
// indicates an earlier error that was already passed to handler, so just short circuit.
|
||||
return;
|
||||
}
|
||||
@ -288,7 +289,7 @@ static NSMutableDictionary *gInstancesDictionary;
|
||||
if (handler) {
|
||||
handler(innerError);
|
||||
}
|
||||
[_accounts removeAllObjects];
|
||||
[self->_accounts removeAllObjects];
|
||||
return;
|
||||
} else {
|
||||
NSMutableSet *grantedPermissions = [NSMutableSet set];
|
||||
@ -298,7 +299,7 @@ static NSMutableDictionary *gInstancesDictionary;
|
||||
[grantedPermissions addObject:obj[@"permission"]];
|
||||
}
|
||||
}];
|
||||
_accounts[userId][kAccountsDictionaryPermissionsKey] = grantedPermissions;
|
||||
self->_accounts[userId][kAccountsDictionaryPermissionsKey] = grantedPermissions;
|
||||
}
|
||||
expectedTestAccounts--;
|
||||
if (!expectedTestAccounts) {
|
||||
|
||||
87
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKURL.h
generated
Normal file
87
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKURL.h
generated
Normal file
@ -0,0 +1,87 @@
|
||||
// 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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class FBSDKAppLink;
|
||||
|
||||
/*!
|
||||
Provides a set of utilities for working with NSURLs, such as parsing of query parameters
|
||||
and handling for App Link requests.
|
||||
*/
|
||||
@interface FBSDKURL : NSObject
|
||||
|
||||
/*!
|
||||
Creates a link target from a raw URL.
|
||||
On success, this posts the FBSDKAppLinkParseEventName measurement event. If you are constructing the FBSDKURL within your application delegate's
|
||||
application:openURL:sourceApplication:annotation:, you should instead use URLWithInboundURL:sourceApplication:
|
||||
to support better FBSDKMeasurementEvent notifications
|
||||
@param url The instance of `NSURL` to create FBSDKURL from.
|
||||
*/
|
||||
+ (FBSDKURL *)URLWithURL:(NSURL *)url;
|
||||
|
||||
/*!
|
||||
Creates a link target from a raw URL received from an external application. This is typically called from the app delegate's
|
||||
application:openURL:sourceApplication:annotation: and will post the FBSDKAppLinkNavigateInEventName measurement event.
|
||||
@param url The instance of `NSURL` to create FBSDKURL from.
|
||||
@param sourceApplication the bundle ID of the app that is requesting your app to open the URL. The same sourceApplication in application:openURL:sourceApplication:annotation:
|
||||
*/
|
||||
+ (FBSDKURL *)URLWithInboundURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication;
|
||||
|
||||
/*!
|
||||
Gets the target URL. If the link is an App Link, this is the target of the App Link.
|
||||
Otherwise, it is the url that created the target.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) NSURL *targetURL;
|
||||
|
||||
/*!
|
||||
Gets the query parameters for the target, parsed into an NSDictionary.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) NSDictionary<NSString *, id> *targetQueryParameters;
|
||||
|
||||
/*!
|
||||
If this link target is an App Link, this is the data found in al_applink_data.
|
||||
Otherwise, it is nil.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) NSDictionary<NSString *, id> *appLinkData;
|
||||
|
||||
/*!
|
||||
If this link target is an App Link, this is the data found in extras.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) NSDictionary<NSString *, id> *appLinkExtras;
|
||||
|
||||
/*!
|
||||
The App Link indicating how to navigate back to the referer app, if any.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) FBSDKAppLink *appLinkReferer;
|
||||
|
||||
/*!
|
||||
The URL that was used to create this FBSDKURL.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) NSURL *inputURL;
|
||||
|
||||
/*!
|
||||
The query parameters of the inputURL, parsed into an NSDictionary.
|
||||
*/
|
||||
@property (nonatomic, strong, readonly) NSDictionary<NSString *, id> *inputQueryParameters;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
152
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKURL.m
generated
Normal file
152
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKURL.m
generated
Normal file
@ -0,0 +1,152 @@
|
||||
// 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 "FBSDKURL_Internal.h"
|
||||
|
||||
#import "FBSDKAppLinkTarget.h"
|
||||
#import "FBSDKAppLink_Internal.h"
|
||||
#import "FBSDKMeasurementEvent_Internal.h"
|
||||
|
||||
@implementation FBSDKURL
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url forOpenInboundURL:(BOOL)forOpenURLEvent sourceApplication:(NSString *)sourceApplication forRenderBackToReferrerBar:(BOOL)forRenderBackToReferrerBar {
|
||||
self = [super init];
|
||||
if (!self) return nil;
|
||||
|
||||
_inputURL = url;
|
||||
_targetURL = url;
|
||||
|
||||
// Parse the query string parameters for the base URL
|
||||
NSDictionary<NSString *, id> *baseQuery = [FBSDKURL queryParametersForURL:url];
|
||||
_inputQueryParameters = baseQuery;
|
||||
_targetQueryParameters = baseQuery;
|
||||
|
||||
// Check for applink_data
|
||||
NSString *appLinkDataString = baseQuery[FBSDKAppLinkDataParameterName];
|
||||
if (appLinkDataString) {
|
||||
// Try to parse the JSON
|
||||
NSError *error = nil;
|
||||
NSDictionary<NSString *, id> *applinkData =
|
||||
[NSJSONSerialization JSONObjectWithData:[appLinkDataString dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:0
|
||||
error:&error];
|
||||
if (!error && [applinkData isKindOfClass:[NSDictionary class]]) {
|
||||
// If the version is not specified, assume it is 1.
|
||||
NSString *version = applinkData[FBSDKAppLinkVersionKeyName] ?: @"1.0";
|
||||
NSString *target = applinkData[FBSDKAppLinkTargetKeyName];
|
||||
if ([version isKindOfClass:[NSString class]] &&
|
||||
[version isEqual:FBSDKAppLinkVersion]) {
|
||||
// There's applink data! The target should actually be the applink target.
|
||||
_appLinkData = applinkData;
|
||||
id applinkExtras = applinkData[FBSDKAppLinkExtrasKeyName];
|
||||
if (applinkExtras && [applinkExtras isKindOfClass:[NSDictionary class]]) {
|
||||
_appLinkExtras = applinkExtras;
|
||||
}
|
||||
_targetURL = ([target isKindOfClass:[NSString class]] ? [NSURL URLWithString:target] : url);
|
||||
_targetQueryParameters = [FBSDKURL queryParametersForURL:_targetURL];
|
||||
|
||||
NSDictionary<NSString *, id> *refererAppLink = _appLinkData[FBSDKAppLinkRefererAppLink];
|
||||
NSString *refererURLString = refererAppLink[FBSDKAppLinkRefererUrl];
|
||||
NSString *refererAppName = refererAppLink[FBSDKAppLinkRefererAppName];
|
||||
|
||||
if (refererURLString && refererAppName) {
|
||||
FBSDKAppLinkTarget *appLinkTarget = [FBSDKAppLinkTarget appLinkTargetWithURL:[NSURL URLWithString:refererURLString]
|
||||
appStoreId:nil
|
||||
appName:refererAppName];
|
||||
_appLinkReferer = [FBSDKAppLink appLinkWithSourceURL:[NSURL URLWithString:refererURLString]
|
||||
targets:@[ appLinkTarget ]
|
||||
webURL:nil
|
||||
isBackToReferrer:YES];
|
||||
}
|
||||
|
||||
// Raise Measurement Event
|
||||
NSString *const EVENT_YES_VAL = @"1";
|
||||
NSString *const EVENT_NO_VAL = @"0";
|
||||
NSMutableDictionary<NSString *, id> *logData = [[NSMutableDictionary alloc] init];
|
||||
logData[@"version"] = version;
|
||||
if (refererURLString) {
|
||||
logData[@"refererURL"] = refererURLString;
|
||||
}
|
||||
if (refererAppName) {
|
||||
logData[@"refererAppName"] = refererAppName;
|
||||
}
|
||||
if (sourceApplication) {
|
||||
logData[@"sourceApplication"] = sourceApplication;
|
||||
}
|
||||
if ([_targetURL absoluteString]) {
|
||||
logData[@"targetURL"] = [_targetURL absoluteString];
|
||||
}
|
||||
if ([_inputURL absoluteString]) {
|
||||
logData[@"inputURL"] = [_inputURL absoluteString];
|
||||
}
|
||||
if ([_inputURL scheme]) {
|
||||
logData[@"inputURLScheme"] = [_inputURL scheme];
|
||||
}
|
||||
logData[@"forRenderBackToReferrerBar"] = forRenderBackToReferrerBar ? EVENT_YES_VAL : EVENT_NO_VAL;
|
||||
logData[@"forOpenUrl"] = forOpenURLEvent ? EVENT_YES_VAL : EVENT_NO_VAL;
|
||||
[FBSDKMeasurementEvent postNotificationForEventName:FBSDKAppLinkParseEventName args:logData];
|
||||
if (forOpenURLEvent) {
|
||||
[FBSDKMeasurementEvent postNotificationForEventName:FBSDKAppLinkNavigateInEventName args:logData];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (FBSDKURL *)URLWithURL:(NSURL *)url {
|
||||
return [[FBSDKURL alloc] initWithURL:url forOpenInboundURL:NO sourceApplication:nil forRenderBackToReferrerBar:NO];
|
||||
}
|
||||
|
||||
+ (FBSDKURL *)URLWithInboundURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication {
|
||||
return [[FBSDKURL alloc] initWithURL:url forOpenInboundURL:YES sourceApplication:sourceApplication forRenderBackToReferrerBar:NO];
|
||||
}
|
||||
|
||||
+ (FBSDKURL *)URLForRenderBackToReferrerBarURL:(NSURL *)url {
|
||||
return [[FBSDKURL alloc] initWithURL:url forOpenInboundURL:NO sourceApplication:nil forRenderBackToReferrerBar:YES];
|
||||
}
|
||||
|
||||
+ (NSString *)decodeURLString:(NSString *)string {
|
||||
return (NSString *)CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapes(NULL,
|
||||
(CFStringRef)string,
|
||||
CFSTR("")));
|
||||
}
|
||||
|
||||
+ (NSDictionary<NSString *, id> *)queryParametersForURL:(NSURL *)url {
|
||||
NSMutableDictionary<NSString *, id> *parameters = [NSMutableDictionary dictionary];
|
||||
NSString *query = url.query;
|
||||
if ([query isEqualToString:@""]) {
|
||||
return @{};
|
||||
}
|
||||
NSArray<NSString *> *queryComponents = [query componentsSeparatedByString:@"&"];
|
||||
for (NSString *component in queryComponents) {
|
||||
NSRange equalsLocation = [component rangeOfString:@"="];
|
||||
if (equalsLocation.location == NSNotFound) {
|
||||
// There's no equals, so associate the key with NSNull
|
||||
parameters[[self decodeURLString:component]] = [NSNull null];
|
||||
} else {
|
||||
NSString *key = [self decodeURLString:[component substringToIndex:equalsLocation.location]];
|
||||
NSString *value = [self decodeURLString:[component substringFromIndex:equalsLocation.location + 1]];
|
||||
parameters[key] = value;
|
||||
}
|
||||
}
|
||||
return [NSDictionary dictionaryWithDictionary:parameters];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -25,45 +25,52 @@
|
||||
|
||||
/**
|
||||
Parses a query string into a dictionary.
|
||||
- Parameter queryString: The query string value.
|
||||
- Returns: A dictionary with the key/value pairs.
|
||||
@param queryString The query string value.
|
||||
@return A dictionary with the key/value pairs.
|
||||
*/
|
||||
+ (NSDictionary *)dictionaryWithQueryString:(NSString *)queryString;
|
||||
|
||||
/**
|
||||
Constructs a query string from a dictionary.
|
||||
- Parameter dictionary: The dictionary with key/value pairs for the query string.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: Query string representation of the parameters.
|
||||
@param dictionary The dictionary with key/value pairs for the query string.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return Query string representation of the parameters.
|
||||
*/
|
||||
+ (NSString *)queryStringWithDictionary:(NSDictionary *)dictionary error:(NSError *__autoreleasing *)errorRef;
|
||||
|
||||
/**
|
||||
Decodes a value from an URL.
|
||||
- Parameter value: The value to decode.
|
||||
- Returns: The decoded value.
|
||||
@param value The value to decode.
|
||||
@return The decoded value.
|
||||
*/
|
||||
+ (NSString *)URLDecode:(NSString *)value;
|
||||
|
||||
/**
|
||||
Encodes a value for an URL.
|
||||
- Parameter value: The value to encode.
|
||||
- Returns: The encoded value.
|
||||
@param value The value to encode.
|
||||
@return The encoded value.
|
||||
*/
|
||||
+ (NSString *)URLEncode:(NSString *)value;
|
||||
|
||||
/**
|
||||
Creates a timer using Grand Central Dispatch.
|
||||
- Parameter interval: The interval to fire the timer, in seconds.
|
||||
- Parameter block: The code block to execute when timer is fired.
|
||||
- Returns: The dispatch handle.
|
||||
@param interval The interval to fire the timer, in seconds.
|
||||
@param block The code block to execute when timer is fired.
|
||||
@return The dispatch handle.
|
||||
*/
|
||||
+ (dispatch_source_t)startGCDTimerWithInterval:(double)interval block:(dispatch_block_t)block;
|
||||
|
||||
/**
|
||||
Stop a timer that was started by startGCDTimerWithInterval.
|
||||
- Parameter timer: The dispatch handle received from startGCDTimerWithInterval.
|
||||
@param timer The dispatch handle received from startGCDTimerWithInterval.
|
||||
*/
|
||||
+ (void)stopGCDTimer:(dispatch_source_t)timer;
|
||||
|
||||
/**
|
||||
Get SHA256 hased string of NSString/NSData
|
||||
|
||||
@param input The data that needs to be hashed, it could be NSString or NSData.
|
||||
*/
|
||||
+ (NSString *)SHA256Hash:(NSObject *)input;
|
||||
|
||||
@end
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
#import "FBSDKUtility.h"
|
||||
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
|
||||
#import "FBSDKInternalUtility.h"
|
||||
#import "FBSDKMacros.h"
|
||||
|
||||
@ -107,6 +109,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)SHA256Hash:(NSObject *)input
|
||||
{
|
||||
NSData *data = nil;
|
||||
|
||||
if ([input isKindOfClass:[NSString class]]) {
|
||||
data = [(NSString *)input dataUsingEncoding:NSUTF8StringEncoding];
|
||||
} else if ([input isKindOfClass:[NSData class]]) {
|
||||
data = (NSData *)input;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
uint8_t digest[CC_SHA256_DIGEST_LENGTH];
|
||||
CC_SHA256(data.bytes, (CC_LONG)data.length, digest);
|
||||
NSMutableString *encryptedStuff = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2];
|
||||
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) {
|
||||
[encryptedStuff appendFormat:@"%02x", digest[i]];
|
||||
}
|
||||
|
||||
return encryptedStuff;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
FBSDK_NO_DESIGNATED_INITIALIZER();
|
||||
|
||||
38
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKWebViewAppLinkResolver.h
generated
Normal file
38
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKWebViewAppLinkResolver.h
generated
Normal file
@ -0,0 +1,38 @@
|
||||
// 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>
|
||||
|
||||
#import "FBSDKAppLinkResolving.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
A reference implementation for an App Link resolver that uses a hidden UIWebView
|
||||
to parse the HTML containing App Link metadata.
|
||||
*/
|
||||
@interface FBSDKWebViewAppLinkResolver : NSObject <FBSDKAppLinkResolving>
|
||||
|
||||
/*!
|
||||
Gets the instance of a FBSDKWebViewAppLinkResolver.
|
||||
*/
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
308
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKWebViewAppLinkResolver.m
generated
Normal file
308
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/FBSDKWebViewAppLinkResolver.m
generated
Normal file
@ -0,0 +1,308 @@
|
||||
// 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 "FBSDKWebViewAppLinkResolver.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "FBSDKAppLink.h"
|
||||
#import "FBSDKAppLinkTarget.h"
|
||||
|
||||
/**
|
||||
Describes the callback for appLinkFromURLInBackground.
|
||||
@param result the results from following redirects
|
||||
@param error the error during the request, if any
|
||||
|
||||
*/
|
||||
typedef void (^FBSDKURLFollowRedirectsHandler)(NSDictionary<NSString *, id> *result, NSError * _Nullable error);
|
||||
|
||||
// Defines JavaScript to extract app link tags from HTML content
|
||||
static NSString *const FBSDKWebViewAppLinkResolverTagExtractionJavaScript = @""
|
||||
"(function() {"
|
||||
" var metaTags = document.getElementsByTagName('meta');"
|
||||
" var results = [];"
|
||||
" for (var i = 0; i < metaTags.length; i++) {"
|
||||
" var property = metaTags[i].getAttribute('property');"
|
||||
" if (property && property.substring(0, 'al:'.length) === 'al:') {"
|
||||
" var tag = { \"property\": metaTags[i].getAttribute('property') };"
|
||||
" if (metaTags[i].hasAttribute('content')) {"
|
||||
" tag['content'] = metaTags[i].getAttribute('content');"
|
||||
" }"
|
||||
" results.push(tag);"
|
||||
" }"
|
||||
" }"
|
||||
" return JSON.stringify(results);"
|
||||
"})()";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverIOSURLKey = @"url";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverIOSAppStoreIdKey = @"app_store_id";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverIOSAppNameKey = @"app_name";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverDictionaryValueKey = @"_value";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverPreferHeader = @"Prefer-Html-Meta-Tags";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverMetaTagPrefix = @"al";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverWebKey = @"web";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverIOSKey = @"ios";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverIPhoneKey = @"iphone";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverIPadKey = @"ipad";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverWebURLKey = @"url";
|
||||
static NSString *const FBSDKWebViewAppLinkResolverShouldFallbackKey = @"should_fallback";
|
||||
|
||||
@interface FBSDKWebViewAppLinkResolverWebViewDelegate : NSObject <UIWebViewDelegate>
|
||||
|
||||
@property (nonatomic, copy) void (^didFinishLoad)(UIWebView *webView);
|
||||
@property (nonatomic, copy) void (^didFailLoadWithError)(UIWebView *webView, NSError *error);
|
||||
@property (nonatomic, assign) BOOL hasLoaded;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKWebViewAppLinkResolverWebViewDelegate
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
||||
if (self.didFinishLoad) {
|
||||
self.didFinishLoad(webView);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)webViewDidStartLoad:(UIWebView *)webView {
|
||||
}
|
||||
|
||||
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
|
||||
if (self.didFailLoadWithError) {
|
||||
self.didFailLoadWithError(webView, error);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
|
||||
if (self.hasLoaded) {
|
||||
// Consider loading a second resource to be "success", since it indicates an inner frame
|
||||
// or redirect is happening. We can run the tag extraction script at this point.
|
||||
self.didFinishLoad(webView);
|
||||
return NO;
|
||||
}
|
||||
self.hasLoaded = YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKWebViewAppLinkResolver
|
||||
|
||||
+ (instancetype)sharedInstance {
|
||||
static id instance;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
instance = [[self alloc] init];
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (void)followRedirects:(NSURL *)url handler:(FBSDKURLFollowRedirectsHandler)handler
|
||||
{
|
||||
// This task will be resolved with either the redirect NSURL
|
||||
// or a dictionary with the response data to be returned.
|
||||
void (^completion)(NSURLResponse *response, NSData *data, NSError *error) = ^(NSURLResponse *response, NSData *data, NSError *error) {
|
||||
if (error) {
|
||||
handler(nil, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
|
||||
|
||||
// NSURLConnection usually follows redirects automatically, but the
|
||||
// documentation is unclear what the default is. This helps it along.
|
||||
if (httpResponse.statusCode >= 300 && httpResponse.statusCode < 400) {
|
||||
NSString *redirectString = httpResponse.allHeaderFields[@"Location"];
|
||||
NSURL *redirectURL = [NSURL URLWithString:redirectString];
|
||||
[self followRedirects:redirectURL handler:handler];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
handler(@{ @"response" : response, @"data" : data }, nil);
|
||||
};
|
||||
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
|
||||
[request setValue:FBSDKWebViewAppLinkResolverMetaTagPrefix forHTTPHeaderField:FBSDKWebViewAppLinkResolverPreferHeader];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9
|
||||
NSURLSession *session = [NSURLSession sharedSession];
|
||||
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
||||
completion(response, data, error);
|
||||
}] resume];
|
||||
#else
|
||||
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:completion];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)appLinkFromURL:(NSURL *)url handler:(FBSDKAppLinkFromURLHandler)handler
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self followRedirects:url handler:^(NSDictionary<NSString *,id> *result, NSError * _Nullable error) {
|
||||
|
||||
if (error) {
|
||||
handler(nil, error);
|
||||
return;
|
||||
}
|
||||
|
||||
NSData *responseData = result[@"data"];
|
||||
NSHTTPURLResponse *response = result[@"response"];
|
||||
|
||||
UIWebView *webView = [[UIWebView alloc] init];
|
||||
FBSDKWebViewAppLinkResolverWebViewDelegate *listener = [[FBSDKWebViewAppLinkResolverWebViewDelegate alloc] init];
|
||||
__block FBSDKWebViewAppLinkResolverWebViewDelegate *retainedListener = listener;
|
||||
listener.didFinishLoad = ^(UIWebView *view) {
|
||||
if (retainedListener) {
|
||||
NSDictionary<NSString *, id> *ogData = [self getALDataFromLoadedPage:view];
|
||||
[view removeFromSuperview];
|
||||
view.delegate = nil;
|
||||
retainedListener = nil;
|
||||
handler([self appLinkFromALData:ogData destination:url], nil);
|
||||
}
|
||||
};
|
||||
listener.didFailLoadWithError = ^(UIWebView* view, NSError *loadError) {
|
||||
if (retainedListener) {
|
||||
[view removeFromSuperview];
|
||||
view.delegate = nil;
|
||||
retainedListener = nil;
|
||||
handler(nil, loadError);
|
||||
}
|
||||
};
|
||||
webView.delegate = listener;
|
||||
webView.hidden = YES;
|
||||
[webView loadData:responseData
|
||||
MIMEType:response.MIMEType
|
||||
textEncodingName:response.textEncodingName
|
||||
baseURL:response.URL];
|
||||
UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
|
||||
[window addSubview:webView];
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
Builds up a data structure filled with the app link data from the meta tags on a page.
|
||||
The structure of this object is a dictionary where each key holds an array of app link
|
||||
data dictionaries. Values are stored in a key called "_value".
|
||||
*/
|
||||
- (NSDictionary<NSString *, id> *)parseALData:(NSArray<NSDictionary<NSString *, id> *> *)dataArray {
|
||||
NSMutableDictionary<NSString *, id> *al = [NSMutableDictionary dictionary];
|
||||
for (NSDictionary<NSString *, id> *tag in dataArray) {
|
||||
NSString *name = tag[@"property"];
|
||||
if (![name isKindOfClass:[NSString class]]) {
|
||||
continue;
|
||||
}
|
||||
NSArray<NSString *> *nameComponents = [name componentsSeparatedByString:@":"];
|
||||
if (![nameComponents[0] isEqualToString:FBSDKWebViewAppLinkResolverMetaTagPrefix]) {
|
||||
continue;
|
||||
}
|
||||
NSMutableDictionary<NSString *, id> *root = al;
|
||||
for (NSUInteger i = 1; i < nameComponents.count; i++) {
|
||||
NSMutableArray<NSMutableDictionary<NSString *, id> *> *children = root[nameComponents[i]];
|
||||
if (!children) {
|
||||
children = [NSMutableArray array];
|
||||
root[nameComponents[i]] = children;
|
||||
}
|
||||
NSMutableDictionary<NSString *, id> *child = children.lastObject;
|
||||
if (!child || i == nameComponents.count - 1) {
|
||||
child = [NSMutableDictionary dictionary];
|
||||
[children addObject:child];
|
||||
}
|
||||
root = child;
|
||||
}
|
||||
if (tag[@"content"]) {
|
||||
root[FBSDKWebViewAppLinkResolverDictionaryValueKey] = tag[@"content"];
|
||||
}
|
||||
}
|
||||
return al;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *)getALDataFromLoadedPage:(UIWebView *)webView {
|
||||
// Run some JavaScript in the webview to fetch the meta tags.
|
||||
NSString *jsonString = [webView stringByEvaluatingJavaScriptFromString:FBSDKWebViewAppLinkResolverTagExtractionJavaScript];
|
||||
NSError *error = nil;
|
||||
NSArray<NSDictionary<NSString *, id> *> *arr =
|
||||
[NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:0
|
||||
error:&error];
|
||||
return [self parseALData:arr];
|
||||
}
|
||||
|
||||
/*
|
||||
Converts app link data into a FBSDKAppLink containing the targets relevant for this platform.
|
||||
*/
|
||||
- (FBSDKAppLink *)appLinkFromALData:(NSDictionary<NSString *, id> *)appLinkDict destination:(NSURL *)destination {
|
||||
NSMutableArray<FBSDKAppLinkTarget *> *linkTargets = [NSMutableArray array];
|
||||
|
||||
NSArray *platformData = nil;
|
||||
|
||||
const UIUserInterfaceIdiom idiom = UI_USER_INTERFACE_IDIOM();
|
||||
if (idiom == UIUserInterfaceIdiomPad) {
|
||||
platformData = @[ appLinkDict[FBSDKWebViewAppLinkResolverIPadKey] ?: @{},
|
||||
appLinkDict[FBSDKWebViewAppLinkResolverIOSKey] ?: @{} ];
|
||||
} else if (idiom == UIUserInterfaceIdiomPhone) {
|
||||
platformData = @[ appLinkDict[FBSDKWebViewAppLinkResolverIPhoneKey] ?: @{},
|
||||
appLinkDict[FBSDKWebViewAppLinkResolverIOSKey] ?: @{} ];
|
||||
} else {
|
||||
// Future-proofing. Other User Interface idioms should only hit ios.
|
||||
platformData = @[ appLinkDict[FBSDKWebViewAppLinkResolverIOSKey] ?: @{} ];
|
||||
}
|
||||
|
||||
for (NSArray<NSDictionary *> *platformObjects in platformData) {
|
||||
for (NSDictionary<NSString *, NSArray *> *platformDict in platformObjects) {
|
||||
// The schema requires a single url/app store id/app name,
|
||||
// but we could find multiple of them. We'll make a best effort
|
||||
// to interpret this data.
|
||||
NSArray<NSDictionary<NSString *, id> *> *urls = platformDict[FBSDKWebViewAppLinkResolverIOSURLKey];
|
||||
NSArray<NSDictionary<NSString *, id> *> *appStoreIds = platformDict[FBSDKWebViewAppLinkResolverIOSAppStoreIdKey];
|
||||
NSArray<NSDictionary<NSString *, id> *> *appNames = platformDict[FBSDKWebViewAppLinkResolverIOSAppNameKey];
|
||||
|
||||
NSUInteger maxCount = MAX(urls.count, MAX(appStoreIds.count, appNames.count));
|
||||
|
||||
for (NSUInteger i = 0; i < maxCount; i++) {
|
||||
NSString *urlString = urls[i][FBSDKWebViewAppLinkResolverDictionaryValueKey];
|
||||
NSURL *url = urlString ? [NSURL URLWithString:urlString] : nil;
|
||||
NSString *appStoreId = appStoreIds[i][FBSDKWebViewAppLinkResolverDictionaryValueKey];
|
||||
NSString *appName = appNames[i][FBSDKWebViewAppLinkResolverDictionaryValueKey];
|
||||
FBSDKAppLinkTarget *target = [FBSDKAppLinkTarget appLinkTargetWithURL:url
|
||||
appStoreId:appStoreId
|
||||
appName:appName];
|
||||
[linkTargets addObject:target];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary<NSString *, id> *webDict = appLinkDict[FBSDKWebViewAppLinkResolverWebKey][0];
|
||||
NSString *webUrlString = webDict[FBSDKWebViewAppLinkResolverWebURLKey][0][FBSDKWebViewAppLinkResolverDictionaryValueKey];
|
||||
NSString *shouldFallbackString = webDict[FBSDKWebViewAppLinkResolverShouldFallbackKey][0][FBSDKWebViewAppLinkResolverDictionaryValueKey];
|
||||
|
||||
NSURL *webUrl = destination;
|
||||
|
||||
if (shouldFallbackString &&
|
||||
[@[ @"no", @"false", @"0" ] containsObject:[shouldFallbackString lowercaseString]]) {
|
||||
webUrl = nil;
|
||||
}
|
||||
if (webUrl && webUrlString) {
|
||||
webUrl = [NSURL URLWithString:webUrlString];
|
||||
}
|
||||
|
||||
return [FBSDKAppLink appLinkWithSourceURL:destination
|
||||
targets:linkTargets
|
||||
webURL:webUrl];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,48 @@
|
||||
// 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.
|
||||
#ifndef FBSDKCodelessMacros_h
|
||||
#define FBSDKCodelessMacros_h
|
||||
|
||||
// keys for event binding path compoenent
|
||||
#define CODELESS_MAPPING_METHOD_KEY @"method"
|
||||
#define CODELESS_MAPPING_EVENT_NAME_KEY @"event_name"
|
||||
#define CODELESS_MAPPING_EVENT_TYPE_KEY @"event_type"
|
||||
#define CODELESS_MAPPING_APP_VERSION_KEY @"app_version"
|
||||
#define CODELESS_MAPPING_PATH_KEY @"path"
|
||||
#define CODELESS_MAPPING_PATH_TYPE_KEY @"path_type"
|
||||
#define CODELESS_MAPPING_CLASS_NAME_KEY @"class_name"
|
||||
#define CODELESS_MAPPING_MATCH_BITMASK_KEY @"match_bitmask"
|
||||
#define CODELESS_MAPPING_ID_KEY @"id"
|
||||
#define CODELESS_MAPPING_INDEX_KEY @"index"
|
||||
#define CODELESS_MAPPING_SECTION_KEY @"section"
|
||||
#define CODELESS_MAPPING_ROW_KEY @"row"
|
||||
#define CODELESS_MAPPING_TEXT_KEY @"text"
|
||||
#define CODELESS_MAPPING_TAG_KEY @"tag"
|
||||
#define CODELESS_MAPPING_DESC_KEY @"description"
|
||||
#define CODELESS_MAPPING_HINT_KEY @"hint"
|
||||
#define CODELESS_MAPPING_PARAMETERS_KEY @"parameters"
|
||||
#define CODELESS_MAPPING_PARAMETER_NAME_KEY @"name"
|
||||
#define CODELESS_MAPPING_PARAMETER_VALUE_KEY @"value"
|
||||
|
||||
#define CODELESS_MAPPING_PARENT_CLASS_NAME @".."
|
||||
#define CODELESS_MAPPING_CURRENT_CLASS_NAME @"."
|
||||
|
||||
#define ReactNativeClassRCTView @"RCTView"
|
||||
#define ReactNativeClassRCTRootView @"RCTRootView"
|
||||
|
||||
#endif /* FBSDKCodelessMacros_h */
|
||||
@ -0,0 +1,30 @@
|
||||
// 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 FBSDKCodelessParameterComponent : NSObject
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *name;
|
||||
@property (nonatomic, copy, readonly) NSString *value;
|
||||
@property (nonatomic, readonly) NSArray *path;
|
||||
@property (nonatomic, copy, readonly) NSString *pathType;
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)dict;
|
||||
|
||||
@end
|
||||
@ -0,0 +1,45 @@
|
||||
// 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 "FBSDKCodelessParameterComponent.h"
|
||||
|
||||
#import "FBSDKCodelessMacros.h"
|
||||
#import "FBSDKCodelessPathComponent.h"
|
||||
|
||||
@implementation FBSDKCodelessParameterComponent
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)dict {
|
||||
if (self = [super init]) {
|
||||
_name = [[dict objectForKey:CODELESS_MAPPING_PARAMETER_NAME_KEY] copy];
|
||||
_value = [[dict objectForKey:CODELESS_MAPPING_PARAMETER_VALUE_KEY] copy];
|
||||
_pathType = [[dict objectForKey:CODELESS_MAPPING_PATH_TYPE_KEY] copy];
|
||||
|
||||
NSArray *ary = [dict objectForKey:CODELESS_MAPPING_PATH_KEY];
|
||||
NSMutableArray *mut = [NSMutableArray array];
|
||||
for (NSDictionary *info in ary) {
|
||||
FBSDKCodelessPathComponent *component = [[FBSDKCodelessPathComponent alloc]
|
||||
initWithJSON:info];
|
||||
[mut addObject:component];
|
||||
}
|
||||
_path = [mut copy];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,44 @@
|
||||
// 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>
|
||||
|
||||
typedef NS_OPTIONS(int, FBSDKCodelessMatchBitmaskField)
|
||||
{
|
||||
FBSDKCodelessMatchBitmaskFieldID = 1,
|
||||
FBSDKCodelessMatchBitmaskFieldText = 1 << 1,
|
||||
FBSDKCodelessMatchBitmaskFieldTag = 1 << 2,
|
||||
FBSDKCodelessMatchBitmaskFieldDescription = 1 << 3,
|
||||
FBSDKCodelessMatchBitmaskFieldHint = 1 << 4
|
||||
};
|
||||
|
||||
@interface FBSDKCodelessPathComponent : NSObject
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *className;
|
||||
@property (nonatomic, copy, readonly) NSString *text;
|
||||
@property (nonatomic, copy, readonly) NSString *hint;
|
||||
@property (nonatomic, copy, readonly) NSString *desc; // description
|
||||
@property (nonatomic, readonly) int index;
|
||||
@property (nonatomic, readonly) int tag;
|
||||
@property (nonatomic, readonly) int section;
|
||||
@property (nonatomic, readonly) int row;
|
||||
@property (nonatomic, readonly) int matchBitmask;
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary*)dict;
|
||||
|
||||
@end
|
||||
@ -0,0 +1,58 @@
|
||||
// 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 "FBSDKCodelessPathComponent.h"
|
||||
|
||||
#import "FBSDKCodelessMacros.h"
|
||||
|
||||
@implementation FBSDKCodelessPathComponent
|
||||
|
||||
- (instancetype)initWithJSON:(NSDictionary *)dict {
|
||||
if (self = [super init]) {
|
||||
_className = [[dict objectForKey:CODELESS_MAPPING_CLASS_NAME_KEY] copy];
|
||||
_text = [[dict objectForKey:CODELESS_MAPPING_TEXT_KEY] copy];
|
||||
_hint = [[dict objectForKey:CODELESS_MAPPING_HINT_KEY] copy];
|
||||
_desc = [[dict objectForKey:CODELESS_MAPPING_DESC_KEY] copy];
|
||||
|
||||
|
||||
if ([dict objectForKey:CODELESS_MAPPING_INDEX_KEY]) {
|
||||
_index = [[dict objectForKey:CODELESS_MAPPING_INDEX_KEY] intValue];
|
||||
} else {
|
||||
_index = -1;
|
||||
}
|
||||
|
||||
if ([dict objectForKey:CODELESS_MAPPING_SECTION_KEY]) {
|
||||
_section = [[dict objectForKey:CODELESS_MAPPING_SECTION_KEY] intValue];
|
||||
} else {
|
||||
_section = -1;
|
||||
}
|
||||
|
||||
if ([dict objectForKey:CODELESS_MAPPING_ROW_KEY]) {
|
||||
_row = [[dict objectForKey:CODELESS_MAPPING_ROW_KEY] intValue];
|
||||
} else {
|
||||
_row = -1;
|
||||
}
|
||||
|
||||
_tag = [[dict objectForKey:CODELESS_MAPPING_TAG_KEY] intValue];
|
||||
_matchBitmask = [[dict objectForKey:CODELESS_MAPPING_MATCH_BITMASK_KEY] intValue];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
37
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKEventBinding.h
generated
Normal file
37
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKEventBinding.h
generated
Normal file
@ -0,0 +1,37 @@
|
||||
// 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>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FBSDKEventBinding : NSObject
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *eventName;
|
||||
@property (nonatomic, copy, readonly) NSString *eventType;
|
||||
@property (nonatomic, copy, readonly) NSString *appVersion;
|
||||
@property (nonatomic, readonly) NSArray *path;
|
||||
@property (nonatomic, copy, readonly) NSString *pathType;
|
||||
@property (nonatomic, readonly) NSArray *parameters;
|
||||
|
||||
+ (BOOL)isViewMatchPath:(UIView *)view path:(NSArray *)path;
|
||||
+ (BOOL)isPath:(NSArray *)path matchViewPath:(NSArray *)viewPath;
|
||||
- (FBSDKEventBinding *)initWithJSON:(NSDictionary *)dict;
|
||||
- (void)trackEvent:(id)sender;
|
||||
|
||||
@end
|
||||
276
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKEventBinding.m
generated
Normal file
276
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKEventBinding.m
generated
Normal file
@ -0,0 +1,276 @@
|
||||
// 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 "FBSDKEventBinding.h"
|
||||
|
||||
#import <FBSDKCoreKit/FBSDKAppEvents.h>
|
||||
|
||||
#import "FBSDKAppEventsUtility.h"
|
||||
#import "FBSDKCodelessMacros.h"
|
||||
#import "FBSDKCodelessParameterComponent.h"
|
||||
#import "FBSDKCodelessPathComponent.h"
|
||||
#import "FBSDKSwizzler.h"
|
||||
#import "FBSDKViewHierarchy.h"
|
||||
|
||||
#define CODELESS_PATH_TYPE_ABSOLUTE @"absolute"
|
||||
#define CODELESS_PATH_TYPE_RELATIVE @"relative"
|
||||
#define CODELESS_CODELESS_EVENT_KEY @"_is_fb_codeless"
|
||||
#define PARAMETER_NAME_PRICE @"_valueToSum"
|
||||
|
||||
@implementation FBSDKEventBinding
|
||||
|
||||
- (FBSDKEventBinding *)initWithJSON:(NSDictionary *)dict
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_eventName = [[dict objectForKey:CODELESS_MAPPING_EVENT_NAME_KEY] copy];
|
||||
_eventType = [[dict objectForKey:CODELESS_MAPPING_EVENT_TYPE_KEY] copy];
|
||||
_appVersion = [[dict objectForKey:CODELESS_MAPPING_APP_VERSION_KEY] copy];
|
||||
_pathType = [[dict objectForKey:CODELESS_MAPPING_PATH_TYPE_KEY] copy];
|
||||
|
||||
NSArray *pathComponents = [dict objectForKey:CODELESS_MAPPING_PATH_KEY];
|
||||
NSMutableArray *mut = [NSMutableArray array];
|
||||
for (NSDictionary *info in pathComponents) {
|
||||
FBSDKCodelessPathComponent *component = [[FBSDKCodelessPathComponent alloc]
|
||||
initWithJSON:info];
|
||||
[mut addObject:component];
|
||||
}
|
||||
_path = [mut copy];
|
||||
|
||||
NSArray *parameters = [dict objectForKey:CODELESS_MAPPING_PARAMETERS_KEY];
|
||||
mut = [NSMutableArray array];
|
||||
for (NSDictionary *info in parameters) {
|
||||
FBSDKCodelessParameterComponent *component = [[FBSDKCodelessParameterComponent alloc]
|
||||
initWithJSON:info];
|
||||
[mut addObject:component];
|
||||
}
|
||||
_parameters = [mut copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)trackEvent:(id)sender
|
||||
{
|
||||
UIView *sourceView = [sender isKindOfClass:[UIView class]] ? (UIView *)sender : nil;
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
[params setObject:@"1" forKey:CODELESS_CODELESS_EVENT_KEY];
|
||||
for (FBSDKCodelessParameterComponent *component in self.parameters) {
|
||||
NSString *text = component.value;
|
||||
if (!text || text.length == 0) {
|
||||
text = [FBSDKEventBinding findParameterOfPath:component.path
|
||||
pathType:component.pathType
|
||||
sourceView:sourceView];
|
||||
}
|
||||
if (text) {
|
||||
if ([component.name isEqualToString:PARAMETER_NAME_PRICE]) {
|
||||
NSNumber *value = [FBSDKAppEventsUtility getNumberValue:text];
|
||||
[params setObject:value forKey:component.name];
|
||||
} else {
|
||||
[params setObject:text forKey:component.name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[FBSDKAppEvents logEvent:_eventName parameters:[params copy]];
|
||||
}
|
||||
|
||||
+ (BOOL)matchAnyView:(NSArray *)views
|
||||
pathComponent:(FBSDKCodelessPathComponent *)component
|
||||
{
|
||||
for (NSObject *view in views) {
|
||||
if ([self match:view pathComponent:component]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (BOOL)match:(NSObject *)view
|
||||
pathComponent:(FBSDKCodelessPathComponent *)component
|
||||
{
|
||||
NSString *className = NSStringFromClass([view class]);
|
||||
if (![className isEqualToString:component.className]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (component.index >= 0) {
|
||||
NSObject *parent = [FBSDKViewHierarchy getParent:view];
|
||||
if (parent) {
|
||||
NSArray *children = [FBSDKViewHierarchy getChildren:[FBSDKViewHierarchy getParent:view]];
|
||||
NSUInteger index = [children indexOfObject:view];
|
||||
if (index == NSNotFound || index != component.index) {
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
if (0 != component.index) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((component.matchBitmask & FBSDKCodelessMatchBitmaskFieldText) > 0) {
|
||||
NSString *text = [FBSDKViewHierarchy getText:view];
|
||||
BOOL match = ((text.length == 0 && component.text.length == 0)
|
||||
|| [text isEqualToString:component.text]);
|
||||
if (!match) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if ((component.matchBitmask & FBSDKCodelessMatchBitmaskFieldTag) > 0
|
||||
&& [view isKindOfClass:[UIView class]]
|
||||
&& component.tag != ((UIView *)view).tag) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ((component.matchBitmask & FBSDKCodelessMatchBitmaskFieldHint) > 0) {
|
||||
NSString *hint = [FBSDKViewHierarchy getHint:view];
|
||||
BOOL match = ((hint.length == 0 && component.hint.length == 0)
|
||||
|| [hint isEqualToString:component.hint]);
|
||||
if (!match) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (BOOL)isViewMatchPath:(UIView *)view path:(NSArray *)path
|
||||
{
|
||||
NSArray *viewPath = [FBSDKViewHierarchy getPath:view];
|
||||
BOOL isMatch = [self isPath:path matchViewPath:viewPath];
|
||||
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
+ (BOOL)isPath:(NSArray *)path matchViewPath:(NSArray *)viewPath {
|
||||
for (NSInteger i = 0; i < MIN(path.count, viewPath.count); i++) {
|
||||
NSInteger idxPath = path.count - i - 1;
|
||||
NSInteger idxViewPath = viewPath.count - i - 1;
|
||||
|
||||
FBSDKCodelessPathComponent *pathComponent = [path objectAtIndex:idxPath];
|
||||
FBSDKCodelessPathComponent *viewPathComponent = [viewPath objectAtIndex:idxViewPath];
|
||||
|
||||
if (![pathComponent.className isEqualToString:viewPathComponent.className]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (pathComponent.index >= 0
|
||||
&& pathComponent.index != viewPathComponent.index) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ((pathComponent.matchBitmask & FBSDKCodelessMatchBitmaskFieldText) > 0) {
|
||||
NSString *text = viewPathComponent.text;
|
||||
BOOL match = ((text.length == 0 && pathComponent.text.length == 0)
|
||||
|| [text isEqualToString:pathComponent.text]);
|
||||
if (!match) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pathComponent.matchBitmask & FBSDKCodelessMatchBitmaskFieldTag) > 0
|
||||
&& pathComponent.tag != viewPathComponent.tag) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ((pathComponent.matchBitmask & FBSDKCodelessMatchBitmaskFieldHint) > 0) {
|
||||
NSString *hint = viewPathComponent.hint;
|
||||
BOOL match = ((hint.length == 0 && pathComponent.hint.length == 0)
|
||||
|| [hint isEqualToString:pathComponent.hint]);
|
||||
if (!match) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (NSObject *)findViewByPath:(NSArray *)path parent:(NSObject *)parent level:(int)level {
|
||||
if (level >= path.count) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
FBSDKCodelessPathComponent *pathComponent = [path objectAtIndex:level];
|
||||
|
||||
// If found parent, skip to next level
|
||||
if ([pathComponent.className isEqualToString:CODELESS_MAPPING_PARENT_CLASS_NAME]) {
|
||||
NSObject *nextParent = [FBSDKViewHierarchy getParent:parent];
|
||||
|
||||
return [FBSDKEventBinding findViewByPath:path parent:nextParent level:level + 1];
|
||||
} else if ([pathComponent.className isEqualToString:CODELESS_MAPPING_CURRENT_CLASS_NAME]) {
|
||||
return parent;
|
||||
}
|
||||
|
||||
NSArray *children;
|
||||
if (parent) {
|
||||
children = [FBSDKViewHierarchy getChildren:parent];
|
||||
} else {
|
||||
UIWindow *window = [UIApplication sharedApplication].delegate.window;
|
||||
if (window) {
|
||||
children = @[window];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (path.count - 1 == level) {
|
||||
int index = pathComponent.index;
|
||||
if (index >= 0) {
|
||||
NSObject *child = index < children.count ? [children objectAtIndex:index] : nil;
|
||||
if ([self match:child pathComponent:pathComponent]) {
|
||||
return child;
|
||||
}
|
||||
} else {
|
||||
for (NSObject *child in children) {
|
||||
if ([self match:child pathComponent:pathComponent]) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (NSObject *child in children) {
|
||||
NSObject *result = [self findViewByPath:path parent:child level:level + 1];
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// MARK: - find event parameters via relative path
|
||||
+ (NSString *)findParameterOfPath:(NSArray *)path
|
||||
pathType:(NSString *)pathType
|
||||
sourceView:(UIView *)sourceView {
|
||||
if (0 == path.count) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
UIView *rootView = sourceView;
|
||||
if (![pathType isEqualToString:CODELESS_PATH_TYPE_RELATIVE]) {
|
||||
rootView = nil;
|
||||
}
|
||||
|
||||
NSObject *foundObj = [self findViewByPath:path parent:rootView level:0];
|
||||
|
||||
return [FBSDKViewHierarchy getText:foundObj];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -0,0 +1,28 @@
|
||||
// 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 FBSDKEventBindingManager : NSObject
|
||||
|
||||
- (FBSDKEventBindingManager*)initWithJSON:(NSDictionary*)dict;
|
||||
- (void)start;
|
||||
- (void)updateBindings:(NSArray *)bindings;
|
||||
+ (NSArray *)parseArray:(NSArray *)array;
|
||||
|
||||
@end
|
||||
@ -0,0 +1,380 @@
|
||||
// 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 "FBSDKEventBindingManager.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "FBSDKCodelessMacros.h"
|
||||
#import "FBSDKCodelessPathComponent.h"
|
||||
#import "FBSDKEventBinding.h"
|
||||
#import "FBSDKSwizzler.h"
|
||||
#import "FBSDKTypeUtility.h"
|
||||
#import "FBSDKViewHierarchy.h"
|
||||
|
||||
#define ReactNativeEventNameKey @"eventName"
|
||||
#define ReactNativeViewTagKey @"viewTag"
|
||||
#define ReactNativeTouchEndEventName @"touchEnd"
|
||||
|
||||
#define ReactNativeClassRCTTextView @"RCTTextView"
|
||||
#define ReactNativeClassRCTImageView @"RCTImageVIew"
|
||||
#define ReactNativeClassRCTEventDispatcher @"RCTEventDispatcher"
|
||||
#define ReactNativeClassRCTTouchEvent @"RCTTouchEvent"
|
||||
|
||||
static void fb_dispatch_on_main_thread(dispatch_block_t block) {
|
||||
dispatch_async(dispatch_get_main_queue(), block);
|
||||
}
|
||||
|
||||
static void fb_dispatch_on_default_thread(dispatch_block_t block) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
|
||||
}
|
||||
|
||||
@interface FBSDKEventBindingManager ()
|
||||
{
|
||||
BOOL isStarted;
|
||||
NSMutableDictionary *reactBindings;
|
||||
NSSet *validClasses;
|
||||
BOOL hasReactNative;
|
||||
NSArray *eventBindings;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation FBSDKEventBindingManager
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
isStarted = false;
|
||||
hasReactNative = NO;
|
||||
reactBindings = [NSMutableDictionary dictionary];
|
||||
|
||||
NSMutableSet *classes = [NSMutableSet set];
|
||||
[classes addObject:[UIControl class]];
|
||||
[classes addObject:[UITableView class]];
|
||||
[classes addObject:[UICollectionView class]];
|
||||
// ReactNative
|
||||
Class classRCTRootView = NSClassFromString(ReactNativeClassRCTRootView);
|
||||
if (classRCTRootView != nil) {
|
||||
hasReactNative = YES;
|
||||
Class classRCTView = NSClassFromString(ReactNativeClassRCTView);
|
||||
Class classRCTTextView = NSClassFromString(ReactNativeClassRCTTextView);
|
||||
Class classRCTImageView = NSClassFromString(ReactNativeClassRCTImageView);
|
||||
if (classRCTView) {
|
||||
[classes addObject:classRCTView];
|
||||
}
|
||||
if (classRCTTextView) {
|
||||
[classes addObject:classRCTTextView];
|
||||
}
|
||||
if (classRCTImageView) {
|
||||
[classes addObject:classRCTImageView];
|
||||
}
|
||||
}
|
||||
validClasses = [NSSet setWithSet:classes];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSArray *)parseArray:(NSArray *)array {
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
|
||||
for (NSDictionary *json in array) {
|
||||
FBSDKEventBinding *binding = [[FBSDKEventBinding alloc] initWithJSON:json];
|
||||
[result addObject:binding];
|
||||
}
|
||||
|
||||
return [result copy];
|
||||
}
|
||||
|
||||
- (FBSDKEventBindingManager*)initWithJSON:(NSDictionary*)dict
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
NSArray *eventBindingsDict = [FBSDKTypeUtility arrayValue:dict[@"event_bindings"]];
|
||||
NSMutableArray *bindings = [NSMutableArray array];
|
||||
for (NSDictionary *d in eventBindingsDict) {
|
||||
FBSDKEventBinding *e = [[FBSDKEventBinding alloc] initWithJSON:d];
|
||||
[bindings addObject:e];
|
||||
}
|
||||
eventBindings = [bindings copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wundeclared-selector"
|
||||
- (void)start
|
||||
{
|
||||
if (isStarted) {
|
||||
return;
|
||||
}
|
||||
isStarted = true;
|
||||
|
||||
void (^blockToSuperview)(id view) = ^(id view) {
|
||||
[self matchView:view delegate:nil];
|
||||
};
|
||||
|
||||
void (^blockToWindow)(id view) = ^(id view) {
|
||||
[self matchView:view delegate:nil];
|
||||
};
|
||||
|
||||
[FBSDKSwizzler swizzleSelector:@selector(didMoveToSuperview)
|
||||
onClass:[UIControl class]
|
||||
withBlock:blockToSuperview named:@"map_control"];
|
||||
[FBSDKSwizzler swizzleSelector:@selector(didMoveToWindow)
|
||||
onClass:[UIControl class]
|
||||
withBlock:blockToWindow named:@"map_control"];
|
||||
|
||||
|
||||
// ReactNative
|
||||
if (hasReactNative) { // If app is built via ReactNative
|
||||
Class classRCTView = NSClassFromString(ReactNativeClassRCTView);
|
||||
Class classRCTTextView = NSClassFromString(ReactNativeClassRCTTextView);
|
||||
Class classRCTImageView = NSClassFromString(ReactNativeClassRCTImageView);
|
||||
Class classRCTEventDispatcher = NSClassFromString(ReactNativeClassRCTEventDispatcher);
|
||||
|
||||
// All react-native views would be added tp RCTRootView, so no need to check didMoveToWindow
|
||||
[FBSDKSwizzler swizzleSelector:@selector(didMoveToSuperview)
|
||||
onClass:classRCTView
|
||||
withBlock:blockToSuperview
|
||||
named:@"match_react_native"];
|
||||
[FBSDKSwizzler swizzleSelector:@selector(didMoveToSuperview)
|
||||
onClass:classRCTTextView
|
||||
withBlock:blockToSuperview
|
||||
named:@"match_react_native"];
|
||||
[FBSDKSwizzler swizzleSelector:@selector(didMoveToSuperview)
|
||||
onClass:classRCTImageView
|
||||
withBlock:blockToSuperview
|
||||
named:@"match_react_native"];
|
||||
|
||||
[FBSDKSwizzler swizzleSelector:@selector(dispatchEvent:) onClass:classRCTEventDispatcher withBlock:^(id dispatcher, SEL command, id event){
|
||||
if ([event isKindOfClass:NSClassFromString(ReactNativeClassRCTTouchEvent)]) {
|
||||
@try {
|
||||
NSString *eventName = [event valueForKeyPath:ReactNativeEventNameKey];
|
||||
NSNumber *viewTag = [event valueForKeyPath:ReactNativeViewTagKey];
|
||||
|
||||
if ([eventName isEqualToString:ReactNativeTouchEndEventName]
|
||||
&& nil != viewTag) {
|
||||
FBSDKEventBinding *eventBinding = [self->reactBindings objectForKey:viewTag];
|
||||
if (eventBinding) {
|
||||
[eventBinding trackEvent:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
@catch(NSException *exception) {
|
||||
// Catch exception here to prevent LytroKit from crashing app
|
||||
}
|
||||
}
|
||||
} named:@"dispatch_rn_event"];
|
||||
}
|
||||
|
||||
// UITableView
|
||||
void (^tableViewBlock)(UITableView *tableView,
|
||||
SEL cmd,
|
||||
id<UITableViewDelegate> delegate) =
|
||||
^(UITableView *tableView, SEL cmd, id<UITableViewDelegate> delegate) {
|
||||
if (!delegate) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self matchView:tableView delegate:delegate];
|
||||
};
|
||||
[FBSDKSwizzler swizzleSelector:@selector(setDelegate:)
|
||||
onClass:[UITableView class]
|
||||
withBlock:tableViewBlock
|
||||
named:@"match_table_view"];
|
||||
// UICollectionView
|
||||
void (^collectionViewBlock)(UICollectionView *collectionView,
|
||||
SEL cmd,
|
||||
id<UICollectionViewDelegate> delegate) =
|
||||
^(UICollectionView *collectionView, SEL cmd, id<UICollectionViewDelegate> delegate) {
|
||||
if (nil == delegate) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self matchView:collectionView delegate:delegate];
|
||||
};
|
||||
[FBSDKSwizzler swizzleSelector:@selector(setDelegate:)
|
||||
onClass:[UICollectionView class]
|
||||
withBlock:collectionViewBlock
|
||||
named:@"handle_collection_view"];
|
||||
}
|
||||
|
||||
- (void)rematchBindings {
|
||||
if (0 == eventBindings.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray *windows = [UIApplication sharedApplication].windows;
|
||||
for (UIWindow *window in windows) {
|
||||
[self matchSubviewsIn:window];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)matchSubviewsIn:(UIView *)view {
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (UIView *subview in view.subviews) {
|
||||
BOOL isValidClass = NO;
|
||||
for (Class cls in validClasses) {
|
||||
if ([subview isKindOfClass:cls]) {
|
||||
isValidClass = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValidClass) {
|
||||
if ([subview isKindOfClass:[UITableView class]]) {
|
||||
UITableView *tableView = (UITableView *)subview;
|
||||
if (tableView.delegate) {
|
||||
[self matchView:subview delegate:tableView.delegate];
|
||||
}
|
||||
} else if ([subview isKindOfClass:[UICollectionView class]]) {
|
||||
UICollectionView *collectionView = (UICollectionView *)subview;
|
||||
if (collectionView.delegate) {
|
||||
[self matchView:subview delegate:collectionView.delegate];
|
||||
}
|
||||
} else {
|
||||
[self matchView:subview delegate:nil];
|
||||
}
|
||||
}
|
||||
|
||||
if (![subview isKindOfClass:[UIControl class]]) {
|
||||
[self matchSubviewsIn:subview];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the view is matched to any event
|
||||
- (void)matchView:(UIView *)view delegate:(id)delegate {
|
||||
if (0 == eventBindings.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
fb_dispatch_on_main_thread(^{
|
||||
NSArray *path = [FBSDKViewHierarchy getPath:view];
|
||||
|
||||
fb_dispatch_on_default_thread(^{
|
||||
if ([view isKindOfClass:[UIControl class]]) {
|
||||
UIControl *control = (UIControl *)view;
|
||||
for (FBSDKEventBinding *binding in self->eventBindings) {
|
||||
if ([FBSDKEventBinding isPath:binding.path matchViewPath:path]) {
|
||||
fb_dispatch_on_main_thread(^{
|
||||
[control addTarget:binding
|
||||
action:@selector(trackEvent:)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (self->hasReactNative
|
||||
&& [view respondsToSelector:@selector(reactTag)]) {
|
||||
NSNumber *reactTag = [view performSelector:@selector(reactTag)];
|
||||
for (FBSDKEventBinding *binding in self->eventBindings) {
|
||||
if ([FBSDKEventBinding isPath:binding.path matchViewPath:path]) {
|
||||
fb_dispatch_on_main_thread(^{
|
||||
if (reactTag && [reactTag isKindOfClass:[NSNumber class]]) {
|
||||
[self->reactBindings setObject:binding forKey:reactTag];
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if ([view isKindOfClass:[UITableView class]]
|
||||
&& [delegate conformsToProtocol:@protocol(UITableViewDelegate)]) {
|
||||
fb_dispatch_on_default_thread(^{
|
||||
NSMutableSet *matchedBindings = [NSMutableSet set];
|
||||
for (FBSDKEventBinding *binding in self->eventBindings) {
|
||||
if (binding.path.count > 1) {
|
||||
NSArray *shortPath = [binding.path
|
||||
subarrayWithRange:NSMakeRange(0, binding.path.count - 1)];
|
||||
if ([FBSDKEventBinding isPath:shortPath matchViewPath:path]) {
|
||||
[matchedBindings addObject:binding];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedBindings.count > 0) {
|
||||
NSArray *bindings = [matchedBindings allObjects];
|
||||
void (^block)(id, SEL, id, id) = ^(id target, SEL command, UITableView *tableView, NSIndexPath *indexPath) {
|
||||
fb_dispatch_on_main_thread(^{
|
||||
for (FBSDKEventBinding *binding in bindings) {
|
||||
FBSDKCodelessPathComponent *component = binding.path.lastObject;
|
||||
if ((component.section == -1 || component.section == indexPath.section)
|
||||
&& (component.row == -1 || component.row == indexPath.row)) {
|
||||
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
|
||||
[binding trackEvent:cell];
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
[FBSDKSwizzler swizzleSelector:@selector(tableView:didSelectRowAtIndexPath:)
|
||||
onClass:[delegate class]
|
||||
withBlock:block
|
||||
named:@"handle_table_view"];
|
||||
}
|
||||
});
|
||||
} else if ([view isKindOfClass:[UICollectionView class]]
|
||||
&& [delegate conformsToProtocol:@protocol(UICollectionViewDelegate)]) {
|
||||
fb_dispatch_on_default_thread(^{
|
||||
NSMutableSet *matchedBindings = [NSMutableSet set];
|
||||
for (FBSDKEventBinding *binding in self->eventBindings) {
|
||||
if (binding.path.count > 1) {
|
||||
NSArray *shortPath = [binding.path
|
||||
subarrayWithRange:NSMakeRange(0, binding.path.count - 1)];
|
||||
if ([FBSDKEventBinding isPath:shortPath matchViewPath:path]) {
|
||||
[matchedBindings addObject:binding];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedBindings.count > 0) {
|
||||
NSArray *bindings = [matchedBindings allObjects];
|
||||
void (^block)(id, SEL, id, id) = ^(id target, SEL command, UICollectionView *collectionView, NSIndexPath *indexPath) {
|
||||
fb_dispatch_on_main_thread(^{
|
||||
for (FBSDKEventBinding *binding in bindings) {
|
||||
FBSDKCodelessPathComponent *component = binding.path.lastObject;
|
||||
if ((component.section == -1 || component.section == indexPath.section)
|
||||
&& (component.row == -1 || component.row == indexPath.row)) {
|
||||
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
|
||||
[binding trackEvent:cell];
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
[FBSDKSwizzler swizzleSelector:@selector(collectionView:didSelectItemAtIndexPath:)
|
||||
onClass:[delegate class]
|
||||
withBlock:block
|
||||
named:@"handle_collection_view"];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
- (void)updateBindings:(NSArray *)bindings {
|
||||
eventBindings = bindings;
|
||||
[reactBindings removeAllObjects];
|
||||
fb_dispatch_on_main_thread(^{
|
||||
[self rematchBindings];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
33
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKViewHierarchy.h
generated
Normal file
33
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKViewHierarchy.h
generated
Normal file
@ -0,0 +1,33 @@
|
||||
// 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>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FBSDKViewHierarchy : NSObject
|
||||
|
||||
+ (NSObject *)getParent:(NSObject *)obj;
|
||||
+ (NSArray *)getChildren:(NSObject *)obj;
|
||||
+ (NSArray *)getPath:(NSObject *)obj;
|
||||
|
||||
+ (NSString *)getText:(NSObject *)obj;
|
||||
+ (NSString *)getHint:(NSObject *)obj;
|
||||
+ (UITableView *)getParentTableView:(UIView *)cell;
|
||||
+ (UICollectionView *)getParentCollectionView:(UIView *)cell;
|
||||
|
||||
@end
|
||||
394
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKViewHierarchy.m
generated
Normal file
394
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/Codeless/FBSDKViewHierarchy.m
generated
Normal file
@ -0,0 +1,394 @@
|
||||
// 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 "FBSDKViewHierarchy.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#import "FBSDKCodelessMacros.h"
|
||||
#import "FBSDKCodelessPathComponent.h"
|
||||
#import "FBSDKCoreKit+Internal.h"
|
||||
|
||||
#define MAX_VIEW_HIERARCHY_LEVEL 35
|
||||
|
||||
@implementation FBSDKViewHierarchy
|
||||
|
||||
+ (NSArray*)getChildren:(NSObject*)obj {
|
||||
if ([obj isKindOfClass:[UIControl class]]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableArray *children = [NSMutableArray array];
|
||||
|
||||
// children of window should be viewcontroller
|
||||
if ([obj isKindOfClass:[UIWindow class]]) {
|
||||
UIViewController *rootVC = ((UIWindow *)obj).rootViewController;
|
||||
NSArray *subviews = [(UIWindow *)obj subviews];
|
||||
for (UIView *child in subviews) {
|
||||
if (child != rootVC.view) {
|
||||
UIViewController *vc = [FBSDKViewHierarchy getParentViewController:child];
|
||||
if (vc != nil && vc.view == child) {
|
||||
[children addObject:vc];
|
||||
} else {
|
||||
[children addObject:child];
|
||||
}
|
||||
} else {
|
||||
if (rootVC) {
|
||||
[children addObject:rootVC];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UIView class]]) {
|
||||
NSArray *subviews = [[(UIView *)obj subviews] copy];
|
||||
for (UIView *child in subviews) {
|
||||
UIViewController *vc = [FBSDKViewHierarchy getParentViewController:child];
|
||||
if (vc && vc.view == child) {
|
||||
[children addObject:vc];
|
||||
} else {
|
||||
[children addObject:child];
|
||||
}
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UINavigationController class]]) {
|
||||
UIViewController *vc = [(UINavigationController*)obj visibleViewController];
|
||||
UIViewController *tc = [(UINavigationController*)obj topViewController];
|
||||
NSArray *nextChildren = [FBSDKViewHierarchy getChildren:((UIViewController*)obj).view];
|
||||
for (NSObject *child in nextChildren) {
|
||||
if (tc && [self isView:child superViewOfView:tc.view]) {
|
||||
[children addObject:tc];
|
||||
} else if (vc && [self isView:child superViewOfView:vc.view]) {
|
||||
[children addObject:vc];
|
||||
} else {
|
||||
if (child != vc.view && child != tc.view) {
|
||||
[children addObject:child];
|
||||
} else {
|
||||
if (vc && child == vc.view) {
|
||||
[children addObject:vc];
|
||||
} else if (tc && child == tc.view) {
|
||||
[children addObject:tc];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vc && ![children containsObject:vc]) {
|
||||
[children addObject:vc];
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UITabBarController class]]) {
|
||||
UIViewController *vc = [(UITabBarController *)obj selectedViewController];
|
||||
NSArray *nextChildren = [FBSDKViewHierarchy getChildren:((UIViewController*)obj).view];
|
||||
for (NSObject *child in nextChildren) {
|
||||
if (vc && [self isView:child superViewOfView:vc.view]) {
|
||||
[children addObject:vc];
|
||||
} else {
|
||||
if (vc && child == vc.view) {
|
||||
[children addObject:vc];
|
||||
} else {
|
||||
[children addObject:child];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vc && ![children containsObject:vc]) {
|
||||
[children addObject:vc];
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UIViewController class]]) {
|
||||
UIViewController *vc = (UIViewController *)obj;
|
||||
if (vc.isViewLoaded) {
|
||||
NSArray *nextChildren = [FBSDKViewHierarchy getChildren:vc.view];
|
||||
if (nextChildren.count > 0) {
|
||||
[children addObjectsFromArray:nextChildren];
|
||||
}
|
||||
}
|
||||
for (NSObject *child in [vc childViewControllers]) {
|
||||
[children addObject:child];
|
||||
}
|
||||
UIViewController *presentedVC = vc.presentedViewController;
|
||||
if (presentedVC) {
|
||||
[children addObject:presentedVC];
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
+ (NSObject *)getParent:(NSObject *)obj
|
||||
{
|
||||
if ([obj isKindOfClass:[UIView class]]) {
|
||||
UIView *superview = [(UIView *)obj superview];
|
||||
UIViewController *superviewViewController = [FBSDKViewHierarchy
|
||||
getParentViewController:superview];
|
||||
if (superviewViewController && superviewViewController.view == superview) {
|
||||
return superviewViewController;
|
||||
}
|
||||
if (superview && superview != obj) {
|
||||
return superview;
|
||||
}
|
||||
}
|
||||
else if ([obj isKindOfClass:[UIViewController class]]) {
|
||||
UIViewController *vc = (UIViewController *)obj;
|
||||
UIViewController *parentVC = [vc parentViewController];
|
||||
UIViewController *presentingVC = [vc presentingViewController];
|
||||
UINavigationController *nav = [vc navigationController];
|
||||
UITabBarController *tab = [vc tabBarController];
|
||||
|
||||
if (nav) {
|
||||
return nav;
|
||||
}
|
||||
|
||||
if (tab) {
|
||||
return tab;
|
||||
}
|
||||
|
||||
if (parentVC) {
|
||||
return parentVC;
|
||||
}
|
||||
|
||||
if (presentingVC && [presentingVC presentedViewController] == vc) {
|
||||
return presentingVC;
|
||||
}
|
||||
|
||||
// Return parent of view of UIViewController
|
||||
NSObject *viewParent = [FBSDKViewHierarchy getParent:vc.view];
|
||||
if (viewParent) {
|
||||
return viewParent;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSArray *)getPath:(NSObject *)obj {
|
||||
return [FBSDKViewHierarchy getPath:obj limit:MAX_VIEW_HIERARCHY_LEVEL];
|
||||
}
|
||||
|
||||
+ (NSArray *)getPath:(NSObject *)obj limit:(int)limit {
|
||||
if (!obj || limit <= 0) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableArray *path;
|
||||
|
||||
NSObject *parent = [FBSDKViewHierarchy getParent:obj];
|
||||
if (parent) {
|
||||
NSArray *parentPath = [FBSDKViewHierarchy getPath:parent limit:limit - 1];
|
||||
path = [NSMutableArray arrayWithArray:parentPath];
|
||||
} else {
|
||||
path = [NSMutableArray array];
|
||||
}
|
||||
|
||||
NSMutableDictionary *componentInfo = [NSMutableDictionary dictionary];
|
||||
[componentInfo setObject:NSStringFromClass([obj class])
|
||||
forKey:CODELESS_MAPPING_CLASS_NAME_KEY];
|
||||
|
||||
NSString *text = [FBSDKViewHierarchy getText:obj];
|
||||
if (text) {
|
||||
[componentInfo setObject:text forKey:CODELESS_MAPPING_TEXT_KEY];
|
||||
}
|
||||
|
||||
if (parent != nil) {
|
||||
NSArray *children = [FBSDKViewHierarchy getChildren:parent];
|
||||
NSUInteger index = [children indexOfObject:obj];
|
||||
if (index != NSNotFound) {
|
||||
[componentInfo setObject:@(index)
|
||||
forKey:CODELESS_MAPPING_INDEX_KEY];
|
||||
}
|
||||
} else {
|
||||
[componentInfo setObject:@0 forKey:CODELESS_MAPPING_INDEX_KEY];
|
||||
}
|
||||
|
||||
if ([obj isKindOfClass:[UIView class]]) {
|
||||
[componentInfo setObject:@(((UIView *)obj).tag)
|
||||
forKey:CODELESS_MAPPING_TAG_KEY];
|
||||
|
||||
// Handle UITableViewCell & UICollectionViewCell
|
||||
if ([obj isKindOfClass:[UITableViewCell class]]) {
|
||||
UITableView *tableView = [FBSDKViewHierarchy getParentTableView:(UIView *)obj];
|
||||
NSIndexPath *indexPath = [tableView indexPathForCell:(UITableViewCell *)obj];
|
||||
if (indexPath) {
|
||||
[componentInfo setObject:@(indexPath.section)
|
||||
forKey:CODELESS_MAPPING_SECTION_KEY];
|
||||
[componentInfo setObject:@(indexPath.row)
|
||||
forKey:CODELESS_MAPPING_ROW_KEY];
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UICollectionViewCell class]]) {
|
||||
UICollectionView *collectionView = [FBSDKViewHierarchy getParentCollectionView:(UIView *)obj];
|
||||
NSIndexPath *indexPath = [collectionView indexPathForCell:(UICollectionViewCell *)obj];
|
||||
if (indexPath) {
|
||||
[componentInfo setObject:@(indexPath.section)
|
||||
forKey:CODELESS_MAPPING_SECTION_KEY];
|
||||
[componentInfo setObject:@(indexPath.row)
|
||||
forKey:CODELESS_MAPPING_ROW_KEY];
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UITextField class]]) {
|
||||
NSString *hint = [FBSDKViewHierarchy getHint:obj];
|
||||
if (hint) {
|
||||
[componentInfo setObject:hint forKey:CODELESS_MAPPING_HINT_KEY];
|
||||
}
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UINavigationController class]]) {
|
||||
NSString *hint = [FBSDKViewHierarchy getHint:obj];
|
||||
if (hint) {
|
||||
[componentInfo setObject:hint forKey:CODELESS_MAPPING_HINT_KEY];
|
||||
}
|
||||
}
|
||||
|
||||
FBSDKCodelessPathComponent *pathComponent = [[FBSDKCodelessPathComponent alloc]
|
||||
initWithJSON:componentInfo];
|
||||
[path addObject:pathComponent];
|
||||
|
||||
return [NSArray arrayWithArray:path];
|
||||
}
|
||||
|
||||
+ (NSString *)getText:(NSObject *)obj {
|
||||
NSString *text = nil;
|
||||
|
||||
if ([obj isKindOfClass:[UIButton class]]) {
|
||||
text = [(UIButton *)obj currentTitle];
|
||||
} else if ([obj isKindOfClass:[UITextView class]] ||
|
||||
[obj isKindOfClass:[UITextField class]] ||
|
||||
[obj isKindOfClass:[UILabel class]]) {
|
||||
text = [(UILabel *)obj text];
|
||||
} else if ([obj isKindOfClass:[UIPickerView class]]) {
|
||||
UIPickerView *picker = (UIPickerView *)obj;
|
||||
NSInteger sections = [picker numberOfComponents];
|
||||
NSMutableArray *titles = [NSMutableArray array];
|
||||
|
||||
for (NSInteger i = 0; i < sections; i++) {
|
||||
NSInteger row = [picker selectedRowInComponent:i];
|
||||
NSString *title;
|
||||
if ([picker.delegate
|
||||
respondsToSelector:@selector(pickerView:titleForRow:forComponent:)]) {
|
||||
title = [picker.delegate pickerView:picker titleForRow:row forComponent:i];
|
||||
} else if ([picker.delegate
|
||||
respondsToSelector:@selector(pickerView:attributedTitleForRow:forComponent:)]) {
|
||||
title = [[picker.delegate
|
||||
pickerView:picker
|
||||
attributedTitleForRow:row forComponent:i] string];
|
||||
}
|
||||
[titles addObject:title ?: @""];
|
||||
}
|
||||
|
||||
if (titles.count > 0) {
|
||||
text = [FBSDKInternalUtility JSONStringForObject:titles
|
||||
error:NULL
|
||||
invalidObjectHandler:NULL];
|
||||
}
|
||||
} else if ([obj isKindOfClass:[UIDatePicker class]]) {
|
||||
UIDatePicker *picker = (UIDatePicker *)obj;
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ssZ"];
|
||||
text = [formatter stringFromDate:picker.date];
|
||||
} else if ([obj isKindOfClass:NSClassFromString(@"RCTTextView")]) {
|
||||
NSTextStorage *textStorage = [FBSDKAppEventsUtility getVariable:@"_textStorage"
|
||||
fromInstance:obj];
|
||||
if (textStorage) {
|
||||
text = [textStorage string];
|
||||
}
|
||||
} else if ([obj isKindOfClass:NSClassFromString(@"RCTBaseTextInputView")]) {
|
||||
NSAttributedString *attributedText = [FBSDKAppEventsUtility getVariable:@"attributedText"
|
||||
fromInstance:obj];
|
||||
text = [attributedText string];
|
||||
}
|
||||
|
||||
if ([obj conformsToProtocol:@protocol(UITextInput)]) {
|
||||
id<UITextInput> input = (id<UITextInput>)obj;
|
||||
if ([input isSecureTextEntry]) {
|
||||
text = nil;
|
||||
} else {
|
||||
switch (input.keyboardType) {
|
||||
case UIKeyboardTypePhonePad:
|
||||
case UIKeyboardTypeEmailAddress:
|
||||
text = nil;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return text.length > 0 ? text : nil;
|
||||
}
|
||||
|
||||
+ (NSString *)getHint:(NSObject *)obj {
|
||||
NSString *hint = nil;
|
||||
|
||||
if ([obj isKindOfClass:[UITextField class]]) {
|
||||
hint = [(UITextField *)obj placeholder];
|
||||
} else if ([obj isKindOfClass:[UINavigationController class]]) {
|
||||
UIViewController *top = [(UINavigationController *)obj topViewController];
|
||||
if (top) {
|
||||
hint = NSStringFromClass([top class]);
|
||||
}
|
||||
}
|
||||
|
||||
return hint.length > 0 ? hint : nil;
|
||||
}
|
||||
|
||||
+ (BOOL)isView:(NSObject *)obj1 superViewOfView:(UIView *)obj2 {
|
||||
if (![obj1 isKindOfClass:[UIView class]]
|
||||
|| ![obj2 isKindOfClass:[UIView class]]) {
|
||||
return NO;
|
||||
}
|
||||
UIView *view1 = (UIView *)obj1;
|
||||
UIView *view2 = (UIView *)obj2;
|
||||
UIView *superview = view2;
|
||||
while (superview) {
|
||||
superview = [superview superview];
|
||||
if (superview == view1) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (UIViewController *)getParentViewController:(UIView *)view {
|
||||
UIResponder *parentResponder = view;
|
||||
|
||||
while (parentResponder) {
|
||||
parentResponder = [parentResponder nextResponder];
|
||||
if ([parentResponder isKindOfClass:[UIViewController class]]) {
|
||||
return (UIViewController *)parentResponder;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (UITableView *)getParentTableView:(UIView *)cell {
|
||||
UIView *superview = cell.superview;
|
||||
while (superview) {
|
||||
if ([superview isKindOfClass:[UITableView class]]) {
|
||||
return (UITableView *)superview;
|
||||
}
|
||||
superview = [superview superview];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (UICollectionView *)getParentCollectionView:(UIView *)cell {
|
||||
UIView *superview = cell.superview;
|
||||
while (superview) {
|
||||
if ([superview isKindOfClass:[UICollectionView class]]) {
|
||||
return (UICollectionView *)superview;
|
||||
}
|
||||
superview = [superview superview];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@ -188,6 +188,16 @@ FBSDK_EXTERN NSString *const FBSDKAppEventNameFBSDKLikeControlNetworkUnavailable
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventParameterDialogErrorMessage;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventParameterLogTime;
|
||||
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesHandlerKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesActionKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesEventKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesParamsKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesPixelTrackKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesPixelTrackCustomKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesPixelTrackSingleKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesPixelTrackSingleCustomKey;
|
||||
FBSDK_EXTERN NSString *const FBSDKAppEventsWKWebViewMessagesPixelIDKey;
|
||||
|
||||
@interface FBSDKAppEvents (Internal)
|
||||
|
||||
+ (void)logImplicitEvent:(NSString *)eventName
|
||||
@ -197,5 +207,6 @@ FBSDK_EXTERN NSString *const FBSDKAppEventParameterLogTime;
|
||||
|
||||
+ (FBSDKAppEvents *)singleton;
|
||||
- (void)flushForReason:(FBSDKAppEventsFlushReason)flushReason;
|
||||
- (void)registerNotifications;
|
||||
|
||||
@end
|
||||
|
||||
@ -118,7 +118,7 @@
|
||||
_numSkipped++;
|
||||
} else {
|
||||
[_mutableEvents addObject:@{
|
||||
@"event" : eventDictionary,
|
||||
@"event" : [eventDictionary mutableCopy],
|
||||
FBSDK_APPEVENTSTATE_ISIMPLICIT_KEY : @(isImplicit)
|
||||
}];
|
||||
}
|
||||
|
||||
24
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsUninstall.h
generated
Normal file
24
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsUninstall.h
generated
Normal file
@ -0,0 +1,24 @@
|
||||
// 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 FBSDKAppEventsUninstall : NSObject
|
||||
|
||||
@end
|
||||
118
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsUninstall.m
generated
Normal file
118
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKAppEventsUninstall.m
generated
Normal file
@ -0,0 +1,118 @@
|
||||
// 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 "FBSDKAppEventsUninstall.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
|
||||
#import "FBSDKAppEventsUtility.h"
|
||||
#import "FBSDKGraphRequest.h"
|
||||
#import "FBSDKLogger.h"
|
||||
#import "FBSDKServerConfigurationManager.h"
|
||||
#import "FBSDKSettings.h"
|
||||
#import "FBSDKSwizzler.h"
|
||||
|
||||
#define UNINSTALL_TRACKING_DEVICE_ID_KEY @"device_id"
|
||||
#define UNINSTALL_TRACKING_PLATFORM_KEY @"platform"
|
||||
#define UNINSTALL_TRACKING_DEVICE_TOKEN_KEY @"device_token"
|
||||
#define UNINSTALL_TRACKING_TOKEN_ENDPOINT @"app_push_device_token"
|
||||
|
||||
@implementation FBSDKAppEventsUninstall
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
[FBSDKAppEventsUninstall installSwizzler];
|
||||
}
|
||||
|
||||
+ (NSString *)stringWithDeviceToken:(NSData *)deviceToken {
|
||||
const char *data = [deviceToken bytes];
|
||||
NSMutableString *token = [NSMutableString string];
|
||||
|
||||
for (NSUInteger i = 0; i < [deviceToken length]; i++) {
|
||||
[token appendFormat:@"%02.2hhX", data[i]];
|
||||
}
|
||||
|
||||
return [token copy];
|
||||
}
|
||||
|
||||
+ (void)installSwizzler
|
||||
{
|
||||
Class cls = [[UIApplication sharedApplication].delegate class];
|
||||
SEL selector = @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:);
|
||||
BOOL hasMethod = class_getInstanceMethod(cls, selector) != nil;
|
||||
void (^block)(id) = ^(NSData *deviceToken) {
|
||||
NSString *tokenString = [self stringWithDeviceToken:deviceToken];
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorInformational
|
||||
logEntry:[NSString stringWithFormat:@"Register token from Swizzling: %@", tokenString]];
|
||||
// try upload token immediately after receiving it from swizzling
|
||||
[self updateAndUploadToken:tokenString];
|
||||
};
|
||||
|
||||
if (!hasMethod)
|
||||
{
|
||||
void (^registerBlock)(id, id, id) = ^(id _, id __, NSData *deviceToken)
|
||||
{
|
||||
block(deviceToken);
|
||||
};
|
||||
IMP imp = imp_implementationWithBlock(registerBlock);
|
||||
struct objc_method_description desc = protocol_getMethodDescription(@protocol(UIApplicationDelegate),
|
||||
selector, NO, YES);
|
||||
const char *types = desc.types;
|
||||
class_addMethod(cls, selector, imp, types);
|
||||
} else
|
||||
{
|
||||
void (^registerBlock)(id, SEL, id, id) = ^(id _, SEL __, id ___, NSData *deviceToken)
|
||||
{
|
||||
block(deviceToken);
|
||||
};
|
||||
[FBSDKSwizzler swizzleSelector:selector
|
||||
onClass:cls
|
||||
withBlock:registerBlock
|
||||
named:@"map_control"];
|
||||
}
|
||||
}
|
||||
|
||||
// Token is updated when (changed OR not uploaded)
|
||||
// Token is uploaded when enabled AND (changed OR not uploaded)
|
||||
+ (void)updateAndUploadToken:(NSString *)tokenString
|
||||
{
|
||||
if (!tokenString) {
|
||||
return;
|
||||
}
|
||||
|
||||
[FBSDKServerConfigurationManager loadServerConfigurationWithCompletionBlock:^(FBSDKServerConfiguration *serverConfiguration, NSError *error) {
|
||||
if (serverConfiguration.uninstallTrackingEnabled) {
|
||||
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
|
||||
initWithGraphPath:[NSString stringWithFormat:@"%@/%@",
|
||||
[FBSDKSettings appID], UNINSTALL_TRACKING_TOKEN_ENDPOINT]
|
||||
parameters:@{
|
||||
UNINSTALL_TRACKING_DEVICE_TOKEN_KEY: tokenString,
|
||||
UNINSTALL_TRACKING_PLATFORM_KEY: @"ios",
|
||||
// advertiserID could be 0s if user select limit ad tracking
|
||||
UNINSTALL_TRACKING_DEVICE_ID_KEY: [FBSDKAppEventsUtility advertiserID]?:@""
|
||||
}
|
||||
HTTPMethod:@"POST"];
|
||||
[request startWithCompletionHandler:nil];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -53,5 +53,7 @@ typedef NS_ENUM(NSUInteger, FBSDKAppEventsFlushReason)
|
||||
+ (NSString *)tokenStringToUseFor:(FBSDKAccessToken *)token;
|
||||
+ (long)unixTimeNow;
|
||||
+ (BOOL)validateIdentifier:(NSString *)identifier;
|
||||
+ (id)getVariable:(NSString *)variableName fromInstance:(NSObject *)instance;
|
||||
+ (NSNumber *)getNumberValue:(NSString *)text;
|
||||
|
||||
@end
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
#import "FBSDKAppEventsUtility.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import <AdSupport/AdSupport.h>
|
||||
|
||||
#import "FBSDKAccessToken.h"
|
||||
@ -66,6 +68,10 @@
|
||||
if (userID) {
|
||||
parameters[@"app_user_id"] = userID;
|
||||
}
|
||||
NSString *userData = [FBSDKAppEvents getUserData];
|
||||
if (userData){
|
||||
parameters[@"ud"] = userData;
|
||||
}
|
||||
|
||||
[FBSDKAppEventsDeviceInfo extendDictionaryWithDeviceInfo:parameters];
|
||||
|
||||
@ -334,6 +340,49 @@ restOfStringCharacterSet:(NSCharacterSet *)restOfStringCharacterSet
|
||||
return (long)round([[NSDate date] timeIntervalSince1970]);
|
||||
}
|
||||
|
||||
+ (id)getVariable:(NSString *)variableName fromInstance:(NSObject *)instance {
|
||||
Ivar ivar = class_getInstanceVariable([instance class], [variableName UTF8String]);
|
||||
if (ivar != NULL) {
|
||||
const char *encoding = ivar_getTypeEncoding(ivar);
|
||||
if (encoding != NULL && encoding[0] == '@') {
|
||||
return object_getIvar(instance, ivar);
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSNumber *)getNumberValue:(NSString *)text {
|
||||
NSNumber *value = @0;
|
||||
|
||||
NSLocale *locale = [NSLocale currentLocale];
|
||||
|
||||
NSString *ds = [locale objectForKey:NSLocaleDecimalSeparator] ?: @".";
|
||||
NSString *gs = [locale objectForKey:NSLocaleGroupingSeparator] ?: @",";
|
||||
NSString *separators = [ds stringByAppendingString:gs];
|
||||
|
||||
NSString *regex = [NSString stringWithFormat:@"[+-]?([0-9]+[%1$@]?)?[%1$@]?([0-9]+[%1$@]?)+", separators];
|
||||
NSRegularExpression *re = [NSRegularExpression regularExpressionWithPattern:regex
|
||||
options:0
|
||||
error:nil];
|
||||
NSTextCheckingResult *match = [re firstMatchInString:text
|
||||
options:0
|
||||
range:NSMakeRange(0, text.length)];
|
||||
if (match) {
|
||||
NSString *validText = [text substringWithRange:match.range];
|
||||
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
|
||||
formatter.locale = locale;
|
||||
formatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||||
|
||||
value = [formatter numberFromString:validText];
|
||||
if (nil == value) {
|
||||
value = @([validText floatValue]);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
FBSDK_NO_DESIGNATED_INITIALIZER();
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
// 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.
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
@interface FBSDKHybridAppEventsScriptMessageHandler : NSObject <WKScriptMessageHandler>
|
||||
|
||||
@end
|
||||
#endif
|
||||
@ -0,0 +1,62 @@
|
||||
// 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 "FBSDKHybridAppEventsScriptMessageHandler.h"
|
||||
|
||||
#import <FBSDKCoreKit/FBSDKAppEvents.h>
|
||||
|
||||
#import "FBSDKAppEvents+Internal.h"
|
||||
|
||||
NSString *const FBSDKAppEventsWKWebViewMessagesPixelReferralParamKey = @"_fb_pixel_referral_id";
|
||||
|
||||
@class WKUserContentController;
|
||||
|
||||
@implementation FBSDKHybridAppEventsScriptMessageHandler
|
||||
|
||||
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
|
||||
|
||||
if ([message.name isEqualToString:FBSDKAppEventsWKWebViewMessagesHandlerKey]) {
|
||||
NSString *event = message.body[FBSDKAppEventsWKWebViewMessagesEventKey];
|
||||
if ([event length] > 0) {
|
||||
NSString *stringedParams = message.body[FBSDKAppEventsWKWebViewMessagesParamsKey];
|
||||
NSMutableDictionary <NSObject *, NSObject *> *params = nil;
|
||||
NSError *jsonParseError = nil;
|
||||
if ([stringedParams isKindOfClass:[NSString class]]) {
|
||||
params = [NSJSONSerialization JSONObjectWithData:[stringedParams dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:&jsonParseError
|
||||
];
|
||||
}
|
||||
NSString *pixelID = message.body[FBSDKAppEventsWKWebViewMessagesPixelIDKey];
|
||||
if (pixelID == nil) {
|
||||
[FBSDKAppEventsUtility logAndNotify:@"Can't bridge an event without a referral Pixel ID. Check your webview Pixel configuration."];
|
||||
return;
|
||||
}
|
||||
if (jsonParseError != nil || ![params isKindOfClass:[NSDictionary class]] || params == nil) {
|
||||
[FBSDKAppEventsUtility logAndNotify:@"Could not find parameters for your Pixel request. Check your webview Pixel configuration."];
|
||||
params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:pixelID, FBSDKAppEventsWKWebViewMessagesPixelReferralParamKey, nil];
|
||||
}
|
||||
else {
|
||||
[params setObject:pixelID forKey: FBSDKAppEventsWKWebViewMessagesPixelReferralParamKey];
|
||||
}
|
||||
[FBSDKAppEvents logEvent:event parameters:params];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@ -27,8 +27,12 @@
|
||||
|
||||
static NSString *const FBSDKAppEventParameterImplicitlyLoggedPurchase = @"_implicitlyLogged";
|
||||
static NSString *const FBSDKAppEventNamePurchaseFailed = @"fb_mobile_purchase_failed";
|
||||
static NSString *const FBSDKAppEventNamePurchaseRestored = @"fb_mobile_purchase_restored";
|
||||
static NSString *const FBSDKAppEventParameterNameInAppPurchaseType = @"fb_iap_product_type";
|
||||
static NSString *const FBSDKAppEventParameterNameProductTitle = @"fb_content_title";
|
||||
static NSString *const FBSDKAppEventParameterNameTransactionID = @"fb_transaction_id";
|
||||
static NSString *const FBSDKAppEventParameterNameTransactionDate = @"fb_transaction_date";
|
||||
static NSString *const FBSDKAppEventParameterNameSubscriptionPeriod = @"fb_iap_subs_period";
|
||||
static int const FBSDKMaxParameterValueLength = 100;
|
||||
static NSMutableArray *g_pendingRequestors;
|
||||
|
||||
@ -110,10 +114,10 @@ static NSMutableArray *g_pendingRequestors;
|
||||
case SKPaymentTransactionStatePurchasing:
|
||||
case SKPaymentTransactionStatePurchased:
|
||||
case SKPaymentTransactionStateFailed:
|
||||
case SKPaymentTransactionStateRestored:
|
||||
[self handleTransaction:transaction];
|
||||
break;
|
||||
case SKPaymentTransactionStateDeferred:
|
||||
case SKPaymentTransactionStateRestored:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -188,6 +192,9 @@ static NSMutableArray *g_pendingRequestors;
|
||||
{
|
||||
NSString *eventName = nil;
|
||||
NSString *transactionID = nil;
|
||||
NSString *transactionDate = nil;
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ssZ"];
|
||||
switch (self.transaction.transactionState) {
|
||||
case SKPaymentTransactionStatePurchasing:
|
||||
eventName = FBSDKAppEventNameInitiatedCheckout;
|
||||
@ -195,12 +202,16 @@ static NSMutableArray *g_pendingRequestors;
|
||||
case SKPaymentTransactionStatePurchased:
|
||||
eventName = FBSDKAppEventNamePurchased;
|
||||
transactionID = self.transaction.transactionIdentifier;
|
||||
transactionDate = [formatter stringFromDate:self.transaction.transactionDate];
|
||||
break;
|
||||
case SKPaymentTransactionStateFailed:
|
||||
eventName = FBSDKAppEventNamePurchaseFailed;
|
||||
break;
|
||||
case SKPaymentTransactionStateDeferred:
|
||||
case SKPaymentTransactionStateRestored:
|
||||
eventName = FBSDKAppEventNamePurchaseRestored;
|
||||
transactionDate = [formatter stringFromDate:self.transaction.transactionDate];
|
||||
break;
|
||||
case SKPaymentTransactionStateDeferred:
|
||||
return;
|
||||
}
|
||||
if (!eventName) {
|
||||
@ -213,6 +224,7 @@ static NSMutableArray *g_pendingRequestors;
|
||||
NSMutableDictionary *eventParameters = [NSMutableDictionary dictionaryWithDictionary: @{
|
||||
FBSDKAppEventParameterNameContentID: payment.productIdentifier ?: @"",
|
||||
FBSDKAppEventParameterNameNumItems: @(payment.quantity),
|
||||
FBSDKAppEventParameterNameTransactionDate: transactionDate ?: @"",
|
||||
}];
|
||||
double totalAmount = 0;
|
||||
if (product) {
|
||||
@ -223,6 +235,29 @@ static NSMutableArray *g_pendingRequestors;
|
||||
FBSDKAppEventParameterNameProductTitle: [self getTruncatedString:product.localizedTitle],
|
||||
FBSDKAppEventParameterNameDescription: [self getTruncatedString:product.localizedDescription],
|
||||
}];
|
||||
#if !TARGET_OS_TV
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_2
|
||||
if (@available(iOS 11.2, *)) {
|
||||
BOOL isSubscription = (product.subscriptionPeriod != nil) && ((unsigned long)product.subscriptionPeriod.numberOfUnits > 0);
|
||||
if (isSubscription) {
|
||||
// subs inapp
|
||||
SKProductSubscriptionPeriod *period = product.subscriptionPeriod;
|
||||
NSString *unit = nil;
|
||||
switch (period.unit) {
|
||||
case SKProductPeriodUnitDay: unit = @"D"; break;
|
||||
case SKProductPeriodUnitWeek: unit = @"W"; break;
|
||||
case SKProductPeriodUnitMonth: unit = @"M"; break;
|
||||
case SKProductPeriodUnitYear: unit = @"Y"; break;
|
||||
}
|
||||
NSString *p = [NSString stringWithFormat:@"P%lu%@", (unsigned long)period.numberOfUnits, unit];
|
||||
[eventParameters setObject:p forKey:FBSDKAppEventParameterNameSubscriptionPeriod];
|
||||
[eventParameters setObject:@"subs" forKey:FBSDKAppEventParameterNameInAppPurchaseType];
|
||||
} else {
|
||||
[eventParameters setObject:@"inapp" forKey:FBSDKAppEventParameterNameInAppPurchaseType];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (transactionID) {
|
||||
[eventParameters setObject:transactionID forKey:FBSDKAppEventParameterNameTransactionID];
|
||||
}
|
||||
@ -279,7 +314,7 @@ static NSMutableArray *g_pendingRequestors;
|
||||
}
|
||||
}
|
||||
|
||||
[eventParameters setObject:@"1"forKey:FBSDKAppEventParameterImplicitlyLoggedPurchase];
|
||||
[eventParameters setObject:@"1" forKey:FBSDKAppEventParameterImplicitlyLoggedPurchase];
|
||||
[FBSDKAppEvents logEvent:eventName
|
||||
valueToSum:valueToSum
|
||||
parameters:eventParameters];
|
||||
|
||||
42
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKUserDataStore.h
generated
Normal file
42
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKUserDataStore.h
generated
Normal file
@ -0,0 +1,42 @@
|
||||
// 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>
|
||||
|
||||
#import <FBSDKCoreKit/FBSDKMacros.h>
|
||||
|
||||
@interface FBSDKUserDataStore : NSObject
|
||||
|
||||
+ (void)initStore;
|
||||
|
||||
+ (void)setUserDataAndHash:(NSDictionary *)ud;
|
||||
|
||||
+ (void)setUserDataAndHash:(nullable NSString *)email
|
||||
firstName:(nullable NSString *)firstName
|
||||
lastName:(nullable NSString *)lastName
|
||||
phone:(nullable NSString *)phone
|
||||
dateOfBirth:(nullable NSString *)dateOfBirth
|
||||
gender:(nullable NSString *)gender
|
||||
city:(nullable NSString *)city
|
||||
state:(nullable NSString *)state
|
||||
zip:(nullable NSString *)zip
|
||||
country:(nullable NSString *)country;
|
||||
|
||||
+ (NSString *) getHashedUserData;
|
||||
|
||||
@end
|
||||
216
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKUserDataStore.m
generated
Normal file
216
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/AppEvents/FBSDKUserDataStore.m
generated
Normal file
@ -0,0 +1,216 @@
|
||||
// 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 "FBSDKUserDataStore.h"
|
||||
|
||||
#import <FBSDKSettings.h>
|
||||
|
||||
#import "FBSDKAppEventsUtility.h"
|
||||
#import "FBSDKLogger.h"
|
||||
#import "FBSDKUtility.h"
|
||||
|
||||
#define USER_DATA_KEY @"com.facebook.appevents.UserDataStore.userData"
|
||||
|
||||
static NSString *const FBSDKEmail = @"em";
|
||||
static NSString *const FBSDKFirstName = @"fn";
|
||||
static NSString *const FBSDKLastName = @"ln";
|
||||
static NSString *const FBSDKPhone = @"ph";
|
||||
static NSString *const FBSDKDateOfBirth = @"db";
|
||||
static NSString *const FBSDKGender = @"ge";
|
||||
static NSString *const FBSDKCity = @"ct";
|
||||
static NSString *const FBSDKState = @"st";
|
||||
static NSString *const FBSDKZip = @"zp";
|
||||
static NSString *const FBSDKCountry = @"country";
|
||||
|
||||
static NSString *hashedUserData;
|
||||
static volatile bool initialized = false;
|
||||
|
||||
@implementation FBSDKUserDataStore
|
||||
|
||||
+ (void)initStore
|
||||
{
|
||||
if (initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
[FBSDKUserDataStore initAndWait];
|
||||
}
|
||||
|
||||
+ (void)initAndWait
|
||||
{
|
||||
if (initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
hashedUserData = [defaults stringForKey:USER_DATA_KEY];
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
+ (void)setUserDataAndHash:(NSDictionary *)ud
|
||||
{
|
||||
if (!initialized){
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"initStore should have been called before calling setUserData"];
|
||||
[FBSDKUserDataStore initAndWait];
|
||||
}
|
||||
|
||||
hashedUserData = [FBSDKUserDataStore hashUserData:ud];
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults setObject:(hashedUserData) forKey:(USER_DATA_KEY)];
|
||||
}
|
||||
|
||||
+ (void)setUserDataAndHash:(nullable NSString *)email
|
||||
firstName:(nullable NSString *)firstName
|
||||
lastName:(nullable NSString *)lastName
|
||||
phone:(nullable NSString *)phone
|
||||
dateOfBirth:(nullable NSString *)dateOfBirth
|
||||
gender:(nullable NSString *)gender
|
||||
city:(nullable NSString *)city
|
||||
state:(nullable NSString *)state
|
||||
zip:(nullable NSString *)zip
|
||||
country:(nullable NSString *)country
|
||||
{
|
||||
if (!initialized){
|
||||
[FBSDKUserDataStore initAndWait];
|
||||
}
|
||||
|
||||
NSMutableDictionary *ud = [[NSMutableDictionary alloc] init];
|
||||
if (email != nil) {
|
||||
ud[FBSDKEmail] = email;
|
||||
}
|
||||
if (firstName != nil) {
|
||||
ud[FBSDKFirstName] = firstName;
|
||||
}
|
||||
if (lastName != nil) {
|
||||
ud[FBSDKLastName] = lastName;
|
||||
}
|
||||
if (phone != nil) {
|
||||
ud[FBSDKPhone] = phone;
|
||||
}
|
||||
if (dateOfBirth != nil) {
|
||||
ud[FBSDKDateOfBirth] = dateOfBirth;
|
||||
}
|
||||
if (gender != nil) {
|
||||
ud[FBSDKGender] = gender;
|
||||
}
|
||||
if (city != nil) {
|
||||
ud[FBSDKCity] = city;
|
||||
}
|
||||
if (state != nil) {
|
||||
ud[FBSDKState] = state;
|
||||
}
|
||||
if (zip != nil) {
|
||||
ud[FBSDKZip] = zip;
|
||||
}
|
||||
if (country != nil) {
|
||||
ud[FBSDKCountry] = country;
|
||||
}
|
||||
|
||||
hashedUserData = [FBSDKUserDataStore hashUserData:ud];
|
||||
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults setObject:(hashedUserData) forKey:(USER_DATA_KEY)];
|
||||
}
|
||||
|
||||
+ (NSString *)getHashedUserData
|
||||
{
|
||||
if (!initialized){
|
||||
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
|
||||
logEntry:@"initStore should have been called before calling setUserID"];
|
||||
[FBSDKUserDataStore initAndWait];
|
||||
}
|
||||
|
||||
return hashedUserData;
|
||||
}
|
||||
|
||||
+ (NSString *)hashUserData:(NSDictionary *)ud
|
||||
{
|
||||
if (ud == nil){
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSMutableDictionary *encryptUserData = [NSMutableDictionary dictionaryWithCapacity:[ud count]];
|
||||
|
||||
for (NSString *key in ud){
|
||||
NSString *const value = ud[key];
|
||||
if ([FBSDKUserDataStore maybeSHA256Hashed:value]){
|
||||
encryptUserData[key] = value;
|
||||
} else {
|
||||
NSString *const normalizedValue = [FBSDKUserDataStore normalizeData:key data:value];
|
||||
NSString *const encryptedValue = [FBSDKUserDataStore encryptData:normalizedValue];
|
||||
if (encryptedValue != nil){
|
||||
encryptUserData[key] = encryptedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSError *error;
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:encryptUserData
|
||||
options:0
|
||||
error:&error];
|
||||
if (jsonData){
|
||||
return [[NSString alloc] initWithData:jsonData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
} else {
|
||||
[FBSDKAppEventsUtility logAndNotify:[NSString stringWithFormat:@"invalid json object: %@", error]];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)encryptData:(NSString *)data
|
||||
{
|
||||
if (data == nil || [data length] == 0){
|
||||
return nil;
|
||||
}
|
||||
return [FBSDKUtility SHA256Hash:data];
|
||||
}
|
||||
|
||||
+ (NSString *)normalizeData:(NSString *)type data:(NSString *)data{
|
||||
NSString *normalizedData = @"";
|
||||
if ([type isEqualToString:FBSDKEmail] || [type isEqualToString:FBSDKFirstName]
|
||||
|| [type isEqualToString:FBSDKLastName] || [type isEqualToString:FBSDKCity]
|
||||
|| [type isEqualToString:FBSDKState] || [type isEqualToString:FBSDKCountry]) {
|
||||
normalizedData = [data stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
normalizedData = [normalizedData lowercaseString];
|
||||
} else if ([type isEqualToString:FBSDKPhone]){
|
||||
NSError *error = nil;
|
||||
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[^0-9]"
|
||||
options:NSRegularExpressionCaseInsensitive
|
||||
error:&error
|
||||
];
|
||||
normalizedData = [regex stringByReplacingMatchesInString:data
|
||||
options:0
|
||||
range:NSMakeRange(0, [data length])
|
||||
withTemplate:@""
|
||||
];
|
||||
} else if ([type isEqualToString:FBSDKGender]){
|
||||
NSString *temp = [data stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
temp = [temp lowercaseString];
|
||||
normalizedData = [temp length] > 0 ? [temp substringToIndex:1]: @"";
|
||||
}
|
||||
|
||||
return normalizedData;
|
||||
}
|
||||
|
||||
+ (BOOL)maybeSHA256Hashed:(NSString *)data
|
||||
{
|
||||
NSRange range = [data rangeOfString:@"[A-Fa-f0-9]{64}" options:NSRegularExpressionSearch];
|
||||
return ([data length] == 64) && (range.location != NSNotFound);
|
||||
}
|
||||
|
||||
@end
|
||||
@ -22,29 +22,29 @@
|
||||
|
||||
/**
|
||||
Decodes a base-64 encoded string.
|
||||
- Parameter string: The base-64 encoded string.
|
||||
- Returns: NSData containing the decoded bytes.
|
||||
@param string The base-64 encoded string.
|
||||
@return NSData containing the decoded bytes.
|
||||
*/
|
||||
+ (NSData *)decodeAsData:(NSString *)string;
|
||||
|
||||
/**
|
||||
Decodes a base-64 encoded string into a string.
|
||||
- Parameter string: The base-64 encoded string.
|
||||
- Returns: NSString with the decoded UTF-8 value.
|
||||
@param string The base-64 encoded string.
|
||||
@return NSString with the decoded UTF-8 value.
|
||||
*/
|
||||
+ (NSString *)decodeAsString:(NSString *)string;
|
||||
|
||||
/**
|
||||
Encodes data into a string.
|
||||
- Parameter data: The data to be encoded.
|
||||
- Returns: The base-64 encoded string.
|
||||
@param data The data to be encoded.
|
||||
@return The base-64 encoded string.
|
||||
*/
|
||||
+ (NSString *)encodeData:(NSData *)data;
|
||||
|
||||
/**
|
||||
Encodes string into a base-64 representation.
|
||||
- Parameter string: The string to be encoded.
|
||||
- Returns: The base-64 encoded string.
|
||||
@param string The string to be encoded.
|
||||
@return The base-64 encoded string.
|
||||
*/
|
||||
+ (NSString *)encodeString:(NSString *)string;
|
||||
|
||||
|
||||
@ -290,7 +290,7 @@ static const struct
|
||||
if ([invalidObject isKindOfClass:[NSData class]]) {
|
||||
NSData *data = (NSData *)invalidObject;
|
||||
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
|
||||
if (didAddToPasteboard || !enablePasteboard || !_pasteboard || (data.length < _dataLengthThreshold)) {
|
||||
if (didAddToPasteboard || !enablePasteboard || !self->_pasteboard || (data.length < self->_dataLengthThreshold)) {
|
||||
dictionary[FBSDKBridgeAPIProtocolNativeV1DataKeys.isBase64] = @YES;
|
||||
dictionary[FBSDKBridgeAPIProtocolNativeV1DataKeys.tag] = dataTag;
|
||||
[FBSDKInternalUtility dictionary:dictionary
|
||||
@ -299,18 +299,18 @@ static const struct
|
||||
} else {
|
||||
dictionary[FBSDKBridgeAPIProtocolNativeV1DataKeys.isPasteboard] = @YES;
|
||||
dictionary[FBSDKBridgeAPIProtocolNativeV1DataKeys.tag] = dataTag;
|
||||
dictionary[FBSDKBridgeAPIProtocolNativeV1DataKeys.value] = _pasteboard.name;
|
||||
[_pasteboard setData:data forPasteboardType:FBSDKBridgeAPIProtocolNativeV1DataPasteboardKey];
|
||||
dictionary[FBSDKBridgeAPIProtocolNativeV1DataKeys.value] = self->_pasteboard.name;
|
||||
[self->_pasteboard setData:data forPasteboardType:FBSDKBridgeAPIProtocolNativeV1DataPasteboardKey];
|
||||
// this version of the protocol only supports a single item on the pasteboard, so if when we add an item, make
|
||||
// sure we don't add another item
|
||||
didAddToPasteboard = YES;
|
||||
// if we are adding this to the general pasteboard, then we want to remove it when we are done with the share.
|
||||
// the Facebook app will not clear the value with this version of the protocol, so we should do it when the app
|
||||
// becomes active again
|
||||
NSString *pasteboardName = _pasteboard.name;
|
||||
NSString *pasteboardName = self->_pasteboard.name;
|
||||
if ([pasteboardName isEqualToString:UIPasteboardNameGeneral] ||
|
||||
[pasteboardName isEqualToString:UIPasteboardNameFind]) {
|
||||
[[self class] clearData:data fromPasteboardOnApplicationDidBecomeActive:_pasteboard];
|
||||
[[self class] clearData:data fromPasteboardOnApplicationDidBecomeActive:self->_pasteboard];
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
// 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 "FBSDKAppLinkReturnToRefererView.h"
|
||||
|
||||
@interface FBSDKAppLinkReturnToRefererView (Internal)
|
||||
|
||||
- (CGFloat)statusBarHeight;
|
||||
|
||||
@end
|
||||
40
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKAppLink_Internal.h
generated
Normal file
40
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKAppLink_Internal.h
generated
Normal file
@ -0,0 +1,40 @@
|
||||
// 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 "FBSDKAppLink.h"
|
||||
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkDataParameterName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkTargetKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkUserAgentKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkExtrasKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkVersionKeyName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkRefererAppLink;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkRefererAppName;
|
||||
FOUNDATION_EXPORT NSString *const FBSDKAppLinkRefererUrl;
|
||||
|
||||
@interface FBSDKAppLink (Internal)
|
||||
|
||||
+ (instancetype)appLinkWithSourceURL:(NSURL *)sourceURL
|
||||
targets:(NSArray<FBSDKAppLinkTarget *> *)targets
|
||||
webURL:(NSURL *)webURL
|
||||
isBackToReferrer:(BOOL)isBackToReferrer;
|
||||
|
||||
/*! return if this AppLink is to go back to referrer. */
|
||||
@property (nonatomic, assign, readonly, getter=isBackToReferrer) BOOL backToReferrer;
|
||||
|
||||
@end
|
||||
@ -21,6 +21,8 @@
|
||||
#import <FBSDKCoreKit/FBSDKCoreKit.h>
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
#import "AppEvents/Codeless/FBSDKViewHierarchy.h"
|
||||
#import "AppEvents/Codeless/FBSDKCodelessMacros.h"
|
||||
#import "BridgeAPI/FBSDKBridgeAPIProtocol.h"
|
||||
#import "BridgeAPI/FBSDKBridgeAPIProtocolType.h"
|
||||
#import "BridgeAPI/FBSDKBridgeAPIRequest.h"
|
||||
@ -62,6 +64,7 @@
|
||||
#import "FBSDKLogger.h"
|
||||
#import "FBSDKMath.h"
|
||||
#import "FBSDKSettings+Internal.h"
|
||||
#import "FBSDKSwizzler.h"
|
||||
#import "FBSDKTypeUtility.h"
|
||||
#import "Network/FBSDKGraphRequest+Internal.h"
|
||||
#import "Network/FBSDKGraphRequestConnection+Internal.h"
|
||||
|
||||
@ -36,22 +36,22 @@
|
||||
|
||||
/**
|
||||
Start the mDNS advertisement service for a device request
|
||||
- Parameter loginCode: The login code associated with the action for the device request.
|
||||
- Returns: True if the service broadcast was successfully started.
|
||||
@param loginCode The login code associated with the action for the device request.
|
||||
@return True if the service broadcast was successfully started.
|
||||
*/
|
||||
+ (BOOL)startAdvertisementService:(NSString *)loginCode withDelegate:(id<NSNetServiceDelegate>)delegate;
|
||||
|
||||
/**
|
||||
Check if a service delegate is registered with particular advertisement service
|
||||
- Parameter delegate: The delegate to check if registered.
|
||||
- Parameter service: The advertisement service to check for.
|
||||
- Returns: True if the service is the one the delegate registered with.
|
||||
@param delegate The delegate to check if registered.
|
||||
@param service The advertisement service to check for.
|
||||
@return True if the service is the one the delegate registered with.
|
||||
*/
|
||||
+ (BOOL)isDelegate:(id<NSNetServiceDelegate>)delegate forAdvertisementService:(NSNetService *)service;
|
||||
|
||||
/**
|
||||
Stop the mDNS advertisement service for a device request
|
||||
- Parameter delegate: The delegate registered with the service.
|
||||
@param delegate The delegate registered with the service.
|
||||
*/
|
||||
+ (void)cleanUpAdvertisementService:(id<NSNetServiceDelegate>)delegate;
|
||||
|
||||
|
||||
@ -37,91 +37,91 @@
|
||||
/**
|
||||
Load the kSecRandomDefault value from the Security Framework
|
||||
|
||||
- Returns: The kSecRandomDefault value or nil.
|
||||
@return The kSecRandomDefault value or nil.
|
||||
*/
|
||||
+ (SecRandomRef)loadkSecRandomDefault;
|
||||
|
||||
/**
|
||||
Load the kSecAttrAccessible value from the Security Framework
|
||||
|
||||
- Returns: The kSecAttrAccessible value or nil.
|
||||
@return The kSecAttrAccessible value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecAttrAccessible;
|
||||
|
||||
/**
|
||||
Load the kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly value from the Security Framework
|
||||
|
||||
- Returns: The kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly value or nil.
|
||||
@return The kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
|
||||
|
||||
/**
|
||||
Load the kSecAttrAccount value from the Security Framework
|
||||
|
||||
- Returns: The kSecAttrAccount value or nil.
|
||||
@return The kSecAttrAccount value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecAttrAccount;
|
||||
|
||||
/**
|
||||
Load the kSecAttrService value from the Security Framework
|
||||
|
||||
- Returns: The kSecAttrService value or nil.
|
||||
@return The kSecAttrService value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecAttrService;
|
||||
|
||||
/**
|
||||
Load the kSecAttrGeneric value from the Security Framework
|
||||
|
||||
- Returns: The kSecAttrGeneric value or nil.
|
||||
@return The kSecAttrGeneric value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecAttrGeneric;
|
||||
|
||||
/**
|
||||
Load the kSecValueData value from the Security Framework
|
||||
|
||||
- Returns: The kSecValueData value or nil.
|
||||
@return The kSecValueData value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecValueData;
|
||||
|
||||
/**
|
||||
Load the kSecClassGenericPassword value from the Security Framework
|
||||
|
||||
- Returns: The kSecClassGenericPassword value or nil.
|
||||
@return The kSecClassGenericPassword value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecClassGenericPassword;
|
||||
|
||||
/**
|
||||
Load the kSecAttrAccessGroup value from the Security Framework
|
||||
|
||||
- Returns: The kSecAttrAccessGroup value or nil.
|
||||
@return The kSecAttrAccessGroup value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecAttrAccessGroup;
|
||||
|
||||
/**
|
||||
Load the kSecMatchLimitOne value from the Security Framework
|
||||
|
||||
- Returns: The kSecMatchLimitOne value or nil.
|
||||
@return The kSecMatchLimitOne value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecMatchLimitOne;
|
||||
|
||||
/**
|
||||
Load the kSecMatchLimit value from the Security Framework
|
||||
|
||||
- Returns: The kSecMatchLimit value or nil.
|
||||
@return The kSecMatchLimit value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecMatchLimit;
|
||||
|
||||
/**
|
||||
Load the kSecReturnData value from the Security Framework
|
||||
|
||||
- Returns: The kSecReturnData value or nil.
|
||||
@return The kSecReturnData value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecReturnData;
|
||||
|
||||
/**
|
||||
Load the kSecClass value from the Security Framework
|
||||
|
||||
- Returns: The kSecClass value or nil.
|
||||
@return The kSecClass value or nil.
|
||||
*/
|
||||
+ (CFTypeRef)loadkSecClass;
|
||||
|
||||
@ -227,3 +227,8 @@ FBSDK_EXTERN CFStringRef fbsdkdfl_UTTypeCopyPreferredTagWithClass(CFStringRef in
|
||||
FBSDK_EXTERN CFStringRef fbsdkdfl_kUTTagClassMIMEType(void);
|
||||
FBSDK_EXTERN CFStringRef fbsdkdfl_kUTTypeJPEG(void);
|
||||
FBSDK_EXTERN CFStringRef fbsdkdfl_kUTTypePNG(void);
|
||||
|
||||
#pragma mark - WebKit Classes
|
||||
|
||||
FBSDK_EXTERN Class fbsdkdfl_WKWebViewClass(void);
|
||||
FBSDK_EXTERN Class fbsdkdfl_WKUserScriptClass(void);
|
||||
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
/*
|
||||
download an image or retrieve it from cache
|
||||
- Parameter url: the url to download
|
||||
- Parameter ttl: the amount of time (in seconds) that using a cached version is acceptable.
|
||||
- Parameter completion: the callback with the image - for simplicity nil is returned rather than surfacing an error.
|
||||
@param url the url to download
|
||||
@param ttl the amount of time (in seconds) that using a cached version is acceptable.
|
||||
@param completion the callback with the image - for simplicity nil is returned rather than surfacing an error.
|
||||
*/
|
||||
- (void)downloadImageWithURL:(NSURL *)url ttl:(NSTimeInterval)ttl completion:(void(^)(UIImage* image))completion;
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ static NSString *const kCachedResponseUserInfoKeyTimestamp = @"timestamp";
|
||||
data:data
|
||||
userInfo:@{ kCachedResponseUserInfoKeyTimestamp : [NSDate date] }
|
||||
storagePolicy:NSURLCacheStorageAllowed];
|
||||
[_urlCache storeCachedResponse:responseToCache forRequest:request];
|
||||
[self->_urlCache storeCachedResponse:responseToCache forRequest:request];
|
||||
completionWrapper(responseToCache);
|
||||
} else if (completion != NULL) {
|
||||
completion(nil);
|
||||
|
||||
@ -43,11 +43,11 @@ typedef NS_ENUM(int32_t, FBSDKUIKitVersion)
|
||||
|
||||
/**
|
||||
Constructs an URL for the current app.
|
||||
- Parameter host: The host for the URL.
|
||||
- Parameter path: The path for the URL.
|
||||
- Parameter queryParameters: The query parameters for the URL. This will be converted into a query string.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: The app URL.
|
||||
@param host The host for the URL.
|
||||
@param path The path for the URL.
|
||||
@param queryParameters The query parameters for the URL. This will be converted into a query string.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return The app URL.
|
||||
*/
|
||||
+ (NSURL *)appURLWithHost:(NSString *)host
|
||||
path:(NSString *)path
|
||||
@ -56,15 +56,15 @@ typedef NS_ENUM(int32_t, FBSDKUIKitVersion)
|
||||
|
||||
/**
|
||||
Parses an FB url's query params (and potentially fragment) into a dictionary.
|
||||
- Parameter url: The FB url.
|
||||
- Returns: A dictionary with the key/value pairs.
|
||||
@param url The FB url.
|
||||
@return A dictionary with the key/value pairs.
|
||||
*/
|
||||
+ (NSDictionary *)dictionaryFromFBURL:(NSURL *)url;
|
||||
|
||||
/**
|
||||
Adds an object to an array if it is not nil.
|
||||
- Parameter array: The array to add the object to.
|
||||
- Parameter object: The object to add to the array.
|
||||
@param array The array to add the object to.
|
||||
@param object The object to add to the array.
|
||||
*/
|
||||
+ (void)array:(NSMutableArray *)array addObject:(id)object;
|
||||
|
||||
@ -78,8 +78,8 @@ typedef NS_ENUM(int32_t, FBSDKUIKitVersion)
|
||||
|
||||
/**
|
||||
Converts simple value types to the string equivalent for serializing to a request query or body.
|
||||
- Parameter value: The value to be converted.
|
||||
- Returns: The value that may have been converted if able (otherwise the input param).
|
||||
@param value The value to be converted.
|
||||
@return The value that may have been converted if able (otherwise the input param).
|
||||
*/
|
||||
+ (id)convertRequestValue:(id)value;
|
||||
|
||||
@ -87,17 +87,17 @@ typedef NS_ENUM(int32_t, FBSDKUIKitVersion)
|
||||
Gets the milliseconds since the Unix Epoch.
|
||||
|
||||
Changes in the system clock will affect this value.
|
||||
- Returns: The number of milliseconds since the Unix Epoch.
|
||||
@return The number of milliseconds since the Unix Epoch.
|
||||
*/
|
||||
+ (uint64_t)currentTimeInMilliseconds;
|
||||
|
||||
/**
|
||||
Sets an object for a key in a dictionary if it is not nil.
|
||||
- Parameter dictionary: The dictionary to set the value for.
|
||||
- Parameter object: The value to set after serializing to JSON.
|
||||
- Parameter key: The key to set the value for.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: NO if an error occurred while serializing the object, otherwise YES.
|
||||
@param dictionary The dictionary to set the value for.
|
||||
@param object The value to set after serializing to JSON.
|
||||
@param key The key to set the value for.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return NO if an error occurred while serializing the object, otherwise YES.
|
||||
*/
|
||||
+ (BOOL)dictionary:(NSMutableDictionary *)dictionary
|
||||
setJSONStringForObject:(id)object
|
||||
@ -106,19 +106,19 @@ setJSONStringForObject:(id)object
|
||||
|
||||
/**
|
||||
Sets an object for a key in a dictionary if it is not nil.
|
||||
- Parameter dictionary: The dictionary to set the value for.
|
||||
- Parameter object: The value to set.
|
||||
- Parameter key: The key to set the value for.
|
||||
@param dictionary The dictionary to set the value for.
|
||||
@param object The value to set.
|
||||
@param key The key to set the value for.
|
||||
*/
|
||||
+ (void)dictionary:(NSMutableDictionary *)dictionary setObject:(id)object forKey:(id<NSCopying>)key;
|
||||
|
||||
/**
|
||||
Constructs a Facebook URL.
|
||||
- Parameter hostPrefix: The prefix for the host, such as 'm', 'graph', etc.
|
||||
- Parameter path: The path for the URL. This may or may not include a version.
|
||||
- Parameter queryParameters: The query parameters for the URL. This will be converted into a query string.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: The Facebook URL.
|
||||
@param hostPrefix The prefix for the host, such as 'm', 'graph', etc.
|
||||
@param path The path for the URL. This may or may not include a version.
|
||||
@param queryParameters The query parameters for the URL. This will be converted into a query string.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return The Facebook URL.
|
||||
*/
|
||||
+ (NSURL *)facebookURLWithHostPrefix:(NSString *)hostPrefix
|
||||
path:(NSString *)path
|
||||
@ -127,12 +127,12 @@ setJSONStringForObject:(id)object
|
||||
|
||||
/**
|
||||
Constructs a Facebook URL.
|
||||
- Parameter hostPrefix: The prefix for the host, such as 'm', 'graph', etc.
|
||||
- Parameter path: The path for the URL. This may or may not include a version.
|
||||
- Parameter queryParameters: The query parameters for the URL. This will be converted into a query string.
|
||||
- Parameter defaultVersion: A version to add to the URL if none is found in the path.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: The Facebook URL.
|
||||
@param hostPrefix The prefix for the host, such as 'm', 'graph', etc.
|
||||
@param path The path for the URL. This may or may not include a version.
|
||||
@param queryParameters The query parameters for the URL. This will be converted into a query string.
|
||||
@param defaultVersion A version to add to the URL if none is found in the path.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return The Facebook URL.
|
||||
*/
|
||||
+ (NSURL *)facebookURLWithHostPrefix:(NSString *)hostPrefix
|
||||
path:(NSString *)path
|
||||
@ -142,52 +142,52 @@ setJSONStringForObject:(id)object
|
||||
|
||||
/**
|
||||
Tests whether the supplied URL is a valid URL for opening in the browser.
|
||||
- Parameter URL: The URL to test.
|
||||
- Returns: YES if the URL refers to an http or https resource, otherwise NO.
|
||||
@param URL The URL to test.
|
||||
@return YES if the URL refers to an http or https resource, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)isBrowserURL:(NSURL *)URL;
|
||||
|
||||
/**
|
||||
Tests whether the supplied bundle identifier references a Facebook app.
|
||||
- Parameter bundleIdentifier: The bundle identifier to test.
|
||||
- Returns: YES if the bundle identifier refers to a Facebook app, otherwise NO.
|
||||
@param bundleIdentifier The bundle identifier to test.
|
||||
@return YES if the bundle identifier refers to a Facebook app, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)isFacebookBundleIdentifier:(NSString *)bundleIdentifier;
|
||||
|
||||
/**
|
||||
Tests whether the operating system is at least the specified version.
|
||||
- Parameter version: The version to test against.
|
||||
- Returns: YES if the operating system is greater than or equal to the specified version, otherwise NO.
|
||||
@param version The version to test against.
|
||||
@return YES if the operating system is greater than or equal to the specified version, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)isOSRunTimeVersionAtLeast:(NSOperatingSystemVersion)version;
|
||||
|
||||
/**
|
||||
Tests whether the supplied bundle identifier references the Safari app.
|
||||
- Parameter bundleIdentifier: The bundle identifier to test.
|
||||
- Returns: YES if the bundle identifier refers to the Safari app, otherwise NO.
|
||||
@param bundleIdentifier The bundle identifier to test.
|
||||
@return YES if the bundle identifier refers to the Safari app, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)isSafariBundleIdentifier:(NSString *)bundleIdentifier;
|
||||
|
||||
/**
|
||||
Tests whether the UIKit version that the current app was linked to is at least the specified version.
|
||||
- Parameter version: The version to test against.
|
||||
- Returns: YES if the linked UIKit version is greater than or equal to the specified version, otherwise NO.
|
||||
@param version The version to test against.
|
||||
@return YES if the linked UIKit version is greater than or equal to the specified version, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)isUIKitLinkTimeVersionAtLeast:(FBSDKUIKitVersion)version;
|
||||
|
||||
/**
|
||||
Tests whether the UIKit version in the runtime is at least the specified version.
|
||||
- Parameter version: The version to test against.
|
||||
- Returns: YES if the runtime UIKit version is greater than or equal to the specified version, otherwise NO.
|
||||
@param version The version to test against.
|
||||
@return YES if the runtime UIKit version is greater than or equal to the specified version, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)isUIKitRunTimeVersionAtLeast:(FBSDKUIKitVersion)version;
|
||||
|
||||
/**
|
||||
Converts an object into a JSON string.
|
||||
- Parameter object: The object to convert to JSON.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Parameter invalidObjectHandler: Handles objects that are invalid, returning a replacement value or nil to ignore.
|
||||
- Returns: A JSON string or nil if the object cannot be converted to JSON.
|
||||
@param object The object to convert to JSON.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@param invalidObjectHandler Handles objects that are invalid, returning a replacement value or nil to ignore.
|
||||
@return A JSON string or nil if the object cannot be converted to JSON.
|
||||
*/
|
||||
+ (NSString *)JSONStringForObject:(id)object
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
@ -197,17 +197,17 @@ setJSONStringForObject:(id)object
|
||||
Checks equality between 2 objects.
|
||||
|
||||
Checks for pointer equality, nils, isEqual:.
|
||||
- Parameter object: The first object to compare.
|
||||
- Parameter other: The second object to compare.
|
||||
- Returns: YES if the objects are equal, otherwise NO.
|
||||
@param object The first object to compare.
|
||||
@param other The second object to compare.
|
||||
@return YES if the objects are equal, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)object:(id)object isEqualToObject:(id)other;
|
||||
|
||||
/**
|
||||
Converts a JSON string into an object
|
||||
- Parameter string: The JSON string to convert.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: An NSDictionary, NSArray, NSString or NSNumber containing the object representation, or nil if the string
|
||||
@param string The JSON string to convert.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return An NSDictionary, NSArray, NSString or NSNumber containing the object representation, or nil if the string
|
||||
cannot be converted.
|
||||
*/
|
||||
+ (id)objectForJSONString:(NSString *)string error:(NSError *__autoreleasing *)errorRef;
|
||||
@ -219,10 +219,10 @@ setJSONStringForObject:(id)object
|
||||
|
||||
/**
|
||||
Constructs a query string from a dictionary.
|
||||
- Parameter dictionary: The dictionary with key/value pairs for the query string.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Parameter invalidObjectHandler: Handles objects that are invalid, returning a replacement value or nil to ignore.
|
||||
- Returns: Query string representation of the parameters.
|
||||
@param dictionary The dictionary with key/value pairs for the query string.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@param invalidObjectHandler Handles objects that are invalid, returning a replacement value or nil to ignore.
|
||||
@return Query string representation of the parameters.
|
||||
*/
|
||||
+ (NSString *)queryStringWithDictionary:(NSDictionary *)dictionary
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
@ -237,18 +237,18 @@ setJSONStringForObject:(id)object
|
||||
then we need to use the legacy layout code. Otherwise if the application was linked with UIKit on iOS 8 or later and
|
||||
the application is running on iOS 8 or later, UIKit handles all of the rotation complexity and the origin is always in
|
||||
the top-left and no rotation transform is necessary.
|
||||
- Returns: YES if if the orientation must be manually adjusted, otherwise NO.
|
||||
@return YES if if the orientation must be manually adjusted, otherwise NO.
|
||||
*/
|
||||
+ (BOOL)shouldManuallyAdjustOrientation;
|
||||
|
||||
/**
|
||||
Constructs an NSURL.
|
||||
- Parameter scheme: The scheme for the URL.
|
||||
- Parameter host: The host for the URL.
|
||||
- Parameter path: The path for the URL.
|
||||
- Parameter queryParameters: The query parameters for the URL. This will be converted into a query string.
|
||||
- Parameter errorRef: If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
- Returns: The URL.
|
||||
@param scheme The scheme for the URL.
|
||||
@param host The host for the URL.
|
||||
@param path The path for the URL.
|
||||
@param queryParameters The query parameters for the URL. This will be converted into a query string.
|
||||
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
|
||||
@return The URL.
|
||||
*/
|
||||
+ (NSURL *)URLWithScheme:(NSString *)scheme
|
||||
host:(NSString *)host
|
||||
@ -263,9 +263,9 @@ setJSONStringForObject:(id)object
|
||||
|
||||
/**
|
||||
Extracts permissions from a response fetched from me/permissions
|
||||
- Parameter responseObject: the response
|
||||
- Parameter grantedPermissions: the set to add granted permissions to
|
||||
- Parameter declinedPermissions: the set to add declined permissions to.
|
||||
@param responseObject the response
|
||||
@param grantedPermissions the set to add granted permissions to
|
||||
@param declinedPermissions the set to add declined permissions to.
|
||||
*/
|
||||
+ (void)extractPermissionsFromResponse:(NSDictionary *)responseObject
|
||||
grantedPermissions:(NSMutableSet *)grantedPermissions
|
||||
@ -273,13 +273,13 @@ setJSONStringForObject:(id)object
|
||||
|
||||
/**
|
||||
Registers a transient object so that it will not be deallocated until unregistered
|
||||
- Parameter object: The transient object
|
||||
@param object The transient object
|
||||
*/
|
||||
+ (void)registerTransientObject:(id)object;
|
||||
|
||||
/**
|
||||
Unregisters a transient object that was previously registered with registerTransientObject:
|
||||
- Parameter object: The transient object
|
||||
@param object The transient object
|
||||
*/
|
||||
+ (void)unregisterTransientObject:(__weak id)object;
|
||||
|
||||
|
||||
33
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKMeasurementEvent_Internal.h
generated
Normal file
33
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKMeasurementEvent_Internal.h
generated
Normal file
@ -0,0 +1,33 @@
|
||||
// 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 "FBSDKMeasurementEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
Provides methods for posting notifications from the Bolts framework
|
||||
*/
|
||||
@interface FBSDKMeasurementEvent (Internal)
|
||||
|
||||
+ (void)postNotificationForEventName:(NSString *)name
|
||||
args:(NSDictionary<NSString *, id> *)args;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
38
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKSwizzler.h
generated
Normal file
38
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKSwizzler.h
generated
Normal file
@ -0,0 +1,38 @@
|
||||
// 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>
|
||||
|
||||
// Cast to turn things that are not ids into NSMapTable keys
|
||||
#define MAPTABLE_ID(x) (__bridge id)((void *)x)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wstrict-prototypes"
|
||||
|
||||
typedef void (^swizzleBlock)();
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// Rename to avoid duplicate symbol errors
|
||||
@interface FBSDKSwizzler : NSObject
|
||||
|
||||
+ (void)swizzleSelector:(SEL)aSelector onClass:(Class)aClass withBlock:(swizzleBlock)block named:(NSString *)aName;
|
||||
+ (void)unswizzleSelector:(SEL)aSelector onClass:(Class)aClass named:(NSString *)aName;
|
||||
+ (void)printSwizzles;
|
||||
|
||||
@end
|
||||
310
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKSwizzler.m
generated
Normal file
310
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKSwizzler.m
generated
Normal file
@ -0,0 +1,310 @@
|
||||
// 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 "FBSDKSwizzler.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#define MIN_ARGS 2
|
||||
#define MAX_ARGS 5
|
||||
|
||||
@interface FBSDKSwizzle : NSObject
|
||||
|
||||
@property (nonatomic, assign) Class class;
|
||||
@property (nonatomic, assign) SEL selector;
|
||||
@property (nonatomic, assign) IMP originalMethod;
|
||||
@property (nonatomic, assign) uint numArgs;
|
||||
@property (nonatomic, copy) NSMapTable *blocks;
|
||||
|
||||
- (instancetype)initWithBlock:(swizzleBlock)aBlock
|
||||
named:(NSString *)aName
|
||||
forClass:(Class)aClass
|
||||
selector:(SEL)aSelector
|
||||
originalMethod:(IMP)aMethod
|
||||
withNumArgs:(uint)numArgs;
|
||||
|
||||
@end
|
||||
|
||||
static NSMapTable *swizzles;
|
||||
|
||||
static FBSDKSwizzle* fb_findSwizzle(id self, SEL _cmd){
|
||||
Method aMethod = class_getInstanceMethod([self class], _cmd);
|
||||
FBSDKSwizzle *swizzle = (FBSDKSwizzle *)[swizzles objectForKey:MAPTABLE_ID(aMethod)];
|
||||
Class this_class = [self class];
|
||||
while (!swizzle && class_getSuperclass(this_class)){
|
||||
this_class = class_getSuperclass(this_class);
|
||||
aMethod = class_getInstanceMethod(this_class, _cmd);
|
||||
swizzle = (FBSDKSwizzle *)[swizzles objectForKey:MAPTABLE_ID(aMethod)];
|
||||
}
|
||||
return swizzle;
|
||||
}
|
||||
|
||||
static void fb_swizzledMethod_2(id self, SEL _cmd)
|
||||
{
|
||||
FBSDKSwizzle *swizzle = fb_findSwizzle(self, _cmd);
|
||||
if (swizzle) {
|
||||
((void(*)(id, SEL))swizzle.originalMethod)(self, _cmd);
|
||||
|
||||
NSEnumerator *blocks = [swizzle.blocks objectEnumerator];
|
||||
swizzleBlock block;
|
||||
while ((block = [blocks nextObject])) {
|
||||
block(self, _cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_swizzledMethod_3(id self, SEL _cmd, id arg)
|
||||
{
|
||||
FBSDKSwizzle *swizzle = fb_findSwizzle(self, _cmd);
|
||||
if (swizzle) {
|
||||
((void(*)(id, SEL, id))swizzle.originalMethod)(self, _cmd, arg);
|
||||
|
||||
NSEnumerator *blocks = [swizzle.blocks objectEnumerator];
|
||||
swizzleBlock block;
|
||||
while ((block = [blocks nextObject])) {
|
||||
block(self, _cmd, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_swizzledMethod_4(id self, SEL _cmd, id arg, id arg2)
|
||||
{
|
||||
FBSDKSwizzle *swizzle = fb_findSwizzle(self, _cmd);
|
||||
if (swizzle) {
|
||||
((void(*)(id, SEL, id, id))swizzle.originalMethod)(self, _cmd, arg, arg2);
|
||||
|
||||
NSEnumerator *blocks = [swizzle.blocks objectEnumerator];
|
||||
swizzleBlock block;
|
||||
while ((block = [blocks nextObject])) {
|
||||
block(self, _cmd, arg, arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_swizzledMethod_5(id self, SEL _cmd, id arg, id arg2, id arg3)
|
||||
{
|
||||
FBSDKSwizzle *swizzle = fb_findSwizzle(self, _cmd);
|
||||
if (swizzle) {
|
||||
((void(*)(id, SEL, id, id, id))swizzle.originalMethod)(self, _cmd, arg, arg2, arg3);
|
||||
|
||||
NSEnumerator *blocks = [swizzle.blocks objectEnumerator];
|
||||
swizzleBlock block;
|
||||
while ((block = [blocks nextObject])) {
|
||||
block(self, _cmd, arg, arg2, arg3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void fb_swizzleMethod_4_io(id self, SEL _cmd, NSInteger arg, id arg2)
|
||||
{
|
||||
FBSDKSwizzle *swizzle = fb_findSwizzle(self, _cmd);
|
||||
if (swizzle) {
|
||||
((void(*)(id, SEL, NSInteger, id))swizzle.originalMethod)(self, _cmd, arg, arg2);
|
||||
|
||||
NSEnumerator *blocks = [swizzle.blocks objectEnumerator];
|
||||
swizzleBlock block;
|
||||
while ((block = [blocks nextObject])) {
|
||||
block(self, _cmd, arg, arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wstrict-prototypes"
|
||||
|
||||
static void (*fb_swizzledMethods[MAX_ARGS - MIN_ARGS + 1])() = {fb_swizzledMethod_2, fb_swizzledMethod_3, fb_swizzledMethod_4, fb_swizzledMethod_5};
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@implementation FBSDKSwizzler
|
||||
|
||||
+ (void)setup {
|
||||
if (!swizzles) {
|
||||
swizzles = [NSMapTable mapTableWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||
valueOptions:(NSPointerFunctionsStrongMemory | NSPointerFunctionsObjectPointerPersonality)];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)printSwizzles
|
||||
{
|
||||
NSEnumerator *en = [swizzles objectEnumerator];
|
||||
FBSDKSwizzle *swizzle;
|
||||
while ((swizzle = (FBSDKSwizzle *)[en nextObject])) {
|
||||
NSLog(@"%@", swizzle);
|
||||
}
|
||||
}
|
||||
|
||||
+ (FBSDKSwizzle *)swizzleForMethod:(Method)aMethod
|
||||
{
|
||||
return (FBSDKSwizzle *)[swizzles objectForKey:MAPTABLE_ID(aMethod)];
|
||||
}
|
||||
|
||||
+ (void)removeSwizzleForMethod:(Method)aMethod
|
||||
{
|
||||
[swizzles removeObjectForKey:MAPTABLE_ID(aMethod)];
|
||||
}
|
||||
|
||||
+ (void)setSwizzle:(FBSDKSwizzle *)swizzle forMethod:(Method)aMethod
|
||||
{
|
||||
[swizzles setObject:swizzle forKey:MAPTABLE_ID(aMethod)];
|
||||
}
|
||||
|
||||
+ (BOOL)isLocallyDefinedMethod:(Method)aMethod onClass:(Class)aClass
|
||||
{
|
||||
uint count;
|
||||
BOOL isLocal = NO;
|
||||
Method *methods = class_copyMethodList(aClass, &count);
|
||||
for (NSUInteger i = 0; i < count; i++) {
|
||||
if (aMethod == methods[i]) {
|
||||
isLocal = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(methods);
|
||||
return isLocal;
|
||||
}
|
||||
|
||||
+ (void)swizzleSelector:(SEL)aSelector onClass:(Class)aClass withBlock:(swizzleBlock)aBlock named:(NSString *)aName
|
||||
{
|
||||
[FBSDKSwizzler setup];
|
||||
Method aMethod = class_getInstanceMethod(aClass, aSelector);
|
||||
if (aMethod) {
|
||||
uint numArgs = method_getNumberOfArguments(aMethod);
|
||||
if (numArgs >= MIN_ARGS && numArgs <= MAX_ARGS) {
|
||||
|
||||
BOOL isLocal = [self isLocallyDefinedMethod:aMethod onClass:aClass];
|
||||
IMP swizzledMethod = (IMP)fb_swizzledMethods[numArgs - 2];
|
||||
// Check whether the first parameter is integer
|
||||
if (4 == numArgs) {
|
||||
NSString *firstType = [NSString stringWithUTF8String:method_copyArgumentType(aMethod, 2)];
|
||||
NSString *integerTypes = @"islq";
|
||||
if ([integerTypes containsString:[firstType lowercaseString]]) {
|
||||
swizzledMethod = (IMP)fb_swizzleMethod_4_io;
|
||||
}
|
||||
}
|
||||
|
||||
FBSDKSwizzle *swizzle = [self swizzleForMethod:aMethod];
|
||||
|
||||
if (isLocal) {
|
||||
if (!swizzle) {
|
||||
IMP originalMethod = method_getImplementation(aMethod);
|
||||
|
||||
// Replace the local implementation of this method with the swizzled one
|
||||
method_setImplementation(aMethod,swizzledMethod);
|
||||
|
||||
// Create and add the swizzle
|
||||
swizzle = [[FBSDKSwizzle alloc] initWithBlock:aBlock named:aName forClass:aClass selector:aSelector originalMethod:originalMethod withNumArgs:numArgs];
|
||||
[self setSwizzle:swizzle forMethod:aMethod];
|
||||
|
||||
} else {
|
||||
[swizzle.blocks setObject:aBlock forKey:aName];
|
||||
}
|
||||
} else {
|
||||
IMP originalMethod = swizzle ? swizzle.originalMethod : method_getImplementation(aMethod);
|
||||
|
||||
// Add the swizzle as a new local method on the class.
|
||||
if (!class_addMethod(aClass, aSelector, swizzledMethod, method_getTypeEncoding(aMethod))) {
|
||||
return;
|
||||
}
|
||||
// Now re-get the Method, it should be the one we just added.
|
||||
Method newMethod = class_getInstanceMethod(aClass, aSelector);
|
||||
if (aMethod == newMethod) {
|
||||
return;
|
||||
}
|
||||
|
||||
FBSDKSwizzle *newSwizzle = [[FBSDKSwizzle alloc] initWithBlock:aBlock named:aName forClass:aClass selector:aSelector originalMethod:originalMethod withNumArgs:numArgs];
|
||||
[self setSwizzle:newSwizzle forMethod:newMethod];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)unswizzleSelector:(SEL)aSelector onClass:(Class)aClass
|
||||
{
|
||||
Method aMethod = class_getInstanceMethod(aClass, aSelector);
|
||||
FBSDKSwizzle *swizzle = [self swizzleForMethod:aMethod];
|
||||
if (swizzle) {
|
||||
method_setImplementation(aMethod, swizzle.originalMethod);
|
||||
[self removeSwizzleForMethod:aMethod];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the named swizzle from the given class/selector. If aName is nil, remove all
|
||||
swizzles for this class/selector
|
||||
*/
|
||||
+ (void)unswizzleSelector:(SEL)aSelector onClass:(Class)aClass named:(NSString *)aName
|
||||
{
|
||||
Method aMethod = class_getInstanceMethod(aClass, aSelector);
|
||||
FBSDKSwizzle *swizzle = [self swizzleForMethod:aMethod];
|
||||
if (swizzle) {
|
||||
if (aName) {
|
||||
[swizzle.blocks removeObjectForKey:aName];
|
||||
}
|
||||
if (!aName || swizzle.blocks.count == 0) {
|
||||
method_setImplementation(aMethod, swizzle.originalMethod);
|
||||
[self removeSwizzleForMethod:aMethod];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation FBSDKSwizzle
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.blocks = [NSMapTable mapTableWithKeyOptions:(NSPointerFunctionsStrongMemory
|
||||
| NSPointerFunctionsObjectPersonality)
|
||||
valueOptions:(NSPointerFunctionsStrongMemory
|
||||
| NSPointerFunctionsObjectPointerPersonality)];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBlock:(swizzleBlock)aBlock
|
||||
named:(NSString *)aName
|
||||
forClass:(Class)aClass
|
||||
selector:(SEL)aSelector
|
||||
originalMethod:(IMP)aMethod
|
||||
withNumArgs:(uint)numArgs
|
||||
{
|
||||
if ((self = [self init])) {
|
||||
self.class = aClass;
|
||||
self.selector = aSelector;
|
||||
self.numArgs = numArgs;
|
||||
self.originalMethod = aMethod;
|
||||
[self.blocks setObject:aBlock forKey:aName];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
NSString *descriptors = @"";
|
||||
NSString *key;
|
||||
NSEnumerator *keys = [self.blocks keyEnumerator];
|
||||
while ((key = [keys nextObject])) {
|
||||
descriptors = [descriptors stringByAppendingFormat:@"\t%@ : %@\n", key, [self.blocks objectForKey:key]];
|
||||
}
|
||||
return [NSString stringWithFormat:@"Swizzle on %@::%@ [\n%@]", NSStringFromClass(self.class), NSStringFromSelector(self.selector), descriptors];
|
||||
}
|
||||
|
||||
@end
|
||||
@ -32,11 +32,11 @@ typedef void (^FBSDKGraphRequestAccessToAccountsHandler)(NSString *oauthToken, N
|
||||
|
||||
/*
|
||||
Requests access to the device's Facebook account for the given parameters.
|
||||
- Parameter permissions: the permissions
|
||||
- Parameter defaultAudience: the default audience
|
||||
- Parameter isReauthorize: a flag describing if this is a reauth request
|
||||
- Parameter appID: the app id
|
||||
- Parameter handler: the handler that will be invoked on completion (dispatched to the main thread). the oauthToken is nil on failure.
|
||||
@param permissions the permissions
|
||||
@param defaultAudience the default audience
|
||||
@param isReauthorize a flag describing if this is a reauth request
|
||||
@param appID the app id
|
||||
@param handler the handler that will be invoked on completion (dispatched to the main thread). the oauthToken is nil on failure.
|
||||
*/
|
||||
- (void)requestAccessToFacebookAccountStore:(NSSet *)permissions
|
||||
defaultAudience:(NSString *)defaultAudience
|
||||
@ -47,7 +47,7 @@ typedef void (^FBSDKGraphRequestAccessToAccountsHandler)(NSString *oauthToken, N
|
||||
/*
|
||||
Sends a message to the device account store to renew the Facebook account credentials
|
||||
|
||||
- Parameter handler: the handler that is invoked on completion
|
||||
@param handler the handler that is invoked on completion
|
||||
*/
|
||||
- (void)renewSystemAuthorization:(void(^)(ACAccountCredentialRenewResult result, NSError *error))handler;
|
||||
|
||||
|
||||
@ -257,7 +257,8 @@ static FBSDKSystemAccountStoreAdapter *_singletonInstance = nil;
|
||||
appID:currentToken.appID
|
||||
userID:currentToken.userID
|
||||
expirationDate:[NSDate distantFuture]
|
||||
refreshDate:[NSDate date]];
|
||||
refreshDate:[NSDate date]
|
||||
dataAccessExpirationDate:[NSDate distantFuture]];
|
||||
[FBSDKAccessToken setCurrentAccessToken:updatedToken];
|
||||
}
|
||||
if (handler) {
|
||||
|
||||
23
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKURL_Internal.h
generated
Normal file
23
Example/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/Internal/FBSDKURL_Internal.h
generated
Normal file
@ -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 "FBSDKURL.h"
|
||||
|
||||
@interface FBSDKURL (Internal)
|
||||
+ (FBSDKURL *)URLForRenderBackToReferrerBarURL:(NSURL *)url;
|
||||
@end
|
||||
@ -80,7 +80,7 @@
|
||||
{
|
||||
NSData *data = UIImageJPEGRepresentation(image, [FBSDKSettings JPEGCompressionQuality]);
|
||||
[self _appendWithKey:key filename:key contentType:@"image/jpeg" contentBlock:^{
|
||||
[_data appendData:data];
|
||||
[self->_data appendData:data];
|
||||
}];
|
||||
_json = nil;
|
||||
[logger appendFormat:@"\n %@:\t<Image - %lu kB>", key, (unsigned long)([data length] / 1024)];
|
||||
@ -91,7 +91,7 @@
|
||||
logger:(FBSDKLogger *)logger
|
||||
{
|
||||
[self _appendWithKey:key filename:key contentType:@"content/unknown" contentBlock:^{
|
||||
[_data appendData:data];
|
||||
[self->_data appendData:data];
|
||||
}];
|
||||
_json = nil;
|
||||
[logger appendFormat:@"\n %@:\t<Data - %lu kB>", key, (unsigned long)([data length] / 1024)];
|
||||
@ -105,7 +105,7 @@
|
||||
NSString *contentType = dataAttachment.contentType ?: @"content/unknown";
|
||||
NSData *data = dataAttachment.data;
|
||||
[self _appendWithKey:key filename:filename contentType:contentType contentBlock:^{
|
||||
[_data appendData:data];
|
||||
[self->_data appendData:data];
|
||||
}];
|
||||
_json = nil;
|
||||
[logger appendFormat:@"\n %@:\t<Data - %lu kB>", key, (unsigned long)([data length] / 1024)];
|
||||
|
||||
@ -50,6 +50,7 @@ static int const FBSDKTokenRefreshRetrySeconds = 60 * 60; // hour
|
||||
__block NSMutableSet *declinedPermissions = nil;
|
||||
__block NSString *tokenString = nil;
|
||||
__block NSNumber *expirationDateNumber = nil;
|
||||
__block NSNumber *dataAccessExpirationDateNumber = nil;
|
||||
__block int expectingCallbacksCount = 2;
|
||||
void (^expectingCallbackComplete)(void) = ^{
|
||||
if (--expectingCallbacksCount == 0) {
|
||||
@ -60,13 +61,20 @@ static int const FBSDKTokenRefreshRetrySeconds = 60 * 60; // hour
|
||||
[NSDate dateWithTimeIntervalSince1970:[expirationDateNumber doubleValue]] :
|
||||
[NSDate distantFuture]);
|
||||
}
|
||||
NSDate *dataExpirationDate = currentToken.dataAccessExpirationDate;
|
||||
if (dataAccessExpirationDateNumber) {
|
||||
dataExpirationDate = ([dataAccessExpirationDateNumber doubleValue] > 0 ?
|
||||
[NSDate dateWithTimeIntervalSince1970:[dataAccessExpirationDateNumber doubleValue]] :
|
||||
[NSDate distantFuture]);
|
||||
}
|
||||
FBSDKAccessToken *refreshedToken = [[FBSDKAccessToken alloc] initWithTokenString:tokenString ?: currentToken.tokenString
|
||||
permissions:[(permissions ?: currentToken.permissions) allObjects]
|
||||
declinedPermissions:[(declinedPermissions ?: currentToken.declinedPermissions) allObjects]
|
||||
appID:currentToken.appID
|
||||
userID:currentToken.userID
|
||||
expirationDate:expirationDate
|
||||
refreshDate:[NSDate date]];
|
||||
refreshDate:[NSDate date]
|
||||
dataAccessExpirationDate:dataExpirationDate];
|
||||
if (expectedToken == currentToken) {
|
||||
[FBSDKAccessToken setCurrentAccessToken:refreshedToken];
|
||||
}
|
||||
@ -81,6 +89,7 @@ static int const FBSDKTokenRefreshRetrySeconds = 60 * 60; // hour
|
||||
[connection addRequest:extendRequest completionHandler:^(FBSDKGraphRequestConnection *innerConnection, id result, NSError *error) {
|
||||
tokenString = result[@"access_token"];
|
||||
expirationDateNumber = result[@"expires_at"];
|
||||
dataAccessExpirationDateNumber = result[@"data_access_expiration_time"];
|
||||
expectingCallbackComplete();
|
||||
}];
|
||||
FBSDKGraphRequest *permissionsRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/permissions"
|
||||
@ -126,7 +135,9 @@ static int const FBSDKTokenRefreshRetrySeconds = 60 * 60; // hour
|
||||
|
||||
+ (void)addServerConfigurationPiggyback:(FBSDKGraphRequestConnection *)connection
|
||||
{
|
||||
if (![[FBSDKServerConfigurationManager cachedServerConfiguration] isDefaults]) {
|
||||
if (![[FBSDKServerConfigurationManager cachedServerConfiguration] isDefaults]
|
||||
&& [[NSDate date] timeIntervalSinceDate:[FBSDKServerConfigurationManager cachedServerConfiguration].timestamp]
|
||||
< FBSDK_SERVER_CONFIGURATION_MANAGER_CACHE_TIMEOUT) {
|
||||
return;
|
||||
}
|
||||
NSString *appID = [FBSDKSettings appID];
|
||||
|
||||
@ -120,10 +120,10 @@ static NSString *const kErrorCategoryLogin = @"login";
|
||||
for (NSDictionary *codeSubcodesDictionary in dictionary[@"items"]) {
|
||||
NSString *code = [codeSubcodesDictionary[@"code"] stringValue];
|
||||
|
||||
NSMutableDictionary *currentSubcodes = _configurationDictionary[code];
|
||||
NSMutableDictionary *currentSubcodes = self->_configurationDictionary[code];
|
||||
if (!currentSubcodes) {
|
||||
currentSubcodes = [NSMutableDictionary dictionary];
|
||||
_configurationDictionary[code] = currentSubcodes;
|
||||
self->_configurationDictionary[code] = currentSubcodes;
|
||||
}
|
||||
|
||||
NSArray *subcodes = codeSubcodesDictionary[@"subcodes"];
|
||||
|
||||
@ -53,9 +53,10 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationSmartLoginOptions)
|
||||
advertisingIDEnabled:(BOOL)advertisingIDEnabled
|
||||
implicitLoggingEnabled:(BOOL)implicitLoggingEnabled
|
||||
implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
appIndexingTriggerEnabled:(BOOL)appIndexingTriggerEnabled
|
||||
codelessEventsEnabled:(BOOL)codelessEventsEnabled
|
||||
systemAuthenticationEnabled:(BOOL)systemAuthenticationEnabled
|
||||
nativeAuthFlowEnabled:(BOOL)nativeAuthFlowEnabled
|
||||
uninstallTrackingEnabled:(BOOL)uninstallTrackingEnabled
|
||||
dialogConfigurations:(NSDictionary *)dialogConfigurations
|
||||
dialogFlows:(NSDictionary *)dialogFlows
|
||||
timestamp:(NSDate *)timestamp
|
||||
@ -67,6 +68,8 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
smartLoginBookmarkIconURL:(NSURL *)smartLoginBookmarkIconURL
|
||||
smartLoginMenuIconURL:(NSURL *)smartLoginMenuIconURL
|
||||
updateMessage:(NSString *)updateMessage
|
||||
eventBindings:(NSArray *)eventBindings
|
||||
codelessSetupEnabled:(BOOL)codelessSetupEnabled
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@property (nonatomic, assign, readonly, getter=isAdvertisingIDEnabled) BOOL advertisingIDEnabled;
|
||||
@ -77,10 +80,11 @@ NS_DESIGNATED_INITIALIZER;
|
||||
@property (nonatomic, strong, readonly) FBSDKErrorConfiguration *errorConfiguration;
|
||||
@property (nonatomic, assign, readonly, getter=isImplicitLoggingSupported) BOOL implicitLoggingEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isImplicitPurchaseLoggingSupported) BOOL implicitPurchaseLoggingEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isAppIndexingTriggerEnabled) BOOL appIndexingTriggerEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isCodelessEventsEnabled) BOOL codelessEventsEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isLoginTooltipEnabled) BOOL loginTooltipEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isNativeAuthFlowEnabled) BOOL nativeAuthFlowEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isSystemAuthenticationEnabled) BOOL systemAuthenticationEnabled;
|
||||
@property (nonatomic, assign, readonly, getter=isUninstallTrackingEnabled) BOOL uninstallTrackingEnabled;
|
||||
@property (nonatomic, copy, readonly) NSString *loginTooltipText;
|
||||
@property (nonatomic, copy, readonly) NSDate *timestamp;
|
||||
@property (nonatomic, assign) NSTimeInterval sessionTimoutInterval;
|
||||
@ -89,6 +93,8 @@ NS_DESIGNATED_INITIALIZER;
|
||||
@property (nonatomic, copy, readonly) NSURL *smartLoginBookmarkIconURL;
|
||||
@property (nonatomic, copy, readonly) NSURL *smartLoginMenuIconURL;
|
||||
@property (nonatomic, copy, readonly) NSString *updateMessage;
|
||||
@property (nonatomic, copy, readonly) NSArray *eventBindings;
|
||||
@property (nonatomic, assign, readonly, getter=isCodelessSetupEnabled) BOOL codelessSetupEnabled;
|
||||
@property (nonatomic, readonly) NSInteger version;
|
||||
|
||||
- (FBSDKDialogConfiguration *)dialogConfigurationForDialogName:(NSString *)dialogName;
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
#define FBSDK_SERVER_CONFIGURATION_IMPLICIT_LOGGING_ENABLED_KEY @"implicitLoggingEnabled"
|
||||
#define FBSDK_SERVER_CONFIGURATION_DEFAULT_SHARE_MODE_KEY @"defaultShareMode"
|
||||
#define FBSDK_SERVER_CONFIGURATION_IMPLICIT_PURCHASE_LOGGING_ENABLED_KEY @"implicitPurchaseLoggingEnabled"
|
||||
#define FBSDK_SERVER_CONFIGURATION_APP_INDEXING_TRIGGER_ENABLED_KEY @"appIndexingTriggerEnabled"
|
||||
#define FBSDK_SERVER_CONFIGURATION_CODELESS_EVENTS_ENABLED_KEY @"codelessEventsEnabled"
|
||||
#define FBSDK_SERVER_CONFIGURATION_LOGIN_TOOLTIP_ENABLED_KEY @"loginTooltipEnabled"
|
||||
#define FBSDK_SERVER_CONFIGURATION_LOGIN_TOOLTIP_TEXT_KEY @"loginTooltipText"
|
||||
#define FBSDK_SERVER_CONFIGURATION_SYSTEM_AUTHENTICATION_ENABLED_KEY @"systemAuthenticationEnabled"
|
||||
@ -43,7 +43,10 @@
|
||||
#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_EVENT_BINDINGS @"eventBindings"
|
||||
#define FBSDK_SERVER_CONFIGURATION_CODELESS_SETUP_ENABLED_KEY @"codelessSetupEnabled"
|
||||
#define FBSDK_SERVER_CONFIGURATION_VERSION_KEY @"version"
|
||||
#define FBSDK_SERVER_CONFIGURATION_TRACK_UNINSTALL_ENABLED_KEY @"trackAppUninstallEnabled"
|
||||
|
||||
#pragma mark - Dialog Names
|
||||
|
||||
@ -89,9 +92,10 @@ const NSInteger FBSDKServerConfigurationVersion = 2;
|
||||
advertisingIDEnabled:(BOOL)advertisingIDEnabled
|
||||
implicitLoggingEnabled:(BOOL)implicitLoggingEnabled
|
||||
implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
appIndexingTriggerEnabled:(BOOL)appIndexingTriggerEnabled
|
||||
codelessEventsEnabled:(BOOL)codelessEventsEnabled
|
||||
systemAuthenticationEnabled:(BOOL)systemAuthenticationEnabled
|
||||
nativeAuthFlowEnabled:(BOOL)nativeAuthFlowEnabled
|
||||
uninstallTrackingEnabled:(BOOL)uninstallTrackingEnabled
|
||||
dialogConfigurations:(NSDictionary *)dialogConfigurations
|
||||
dialogFlows:(NSDictionary *)dialogFlows
|
||||
timestamp:(NSDate *)timestamp
|
||||
@ -103,6 +107,8 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
smartLoginBookmarkIconURL:(NSURL *)smartLoginBookmarkIconURL
|
||||
smartLoginMenuIconURL:(NSURL *)smartLoginMenuIconURL
|
||||
updateMessage:(NSString *)updateMessage
|
||||
eventBindings:(NSArray *)eventBindings
|
||||
codelessSetupEnabled:(BOOL)codelessSetupEnabled
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_appID = [appID copy];
|
||||
@ -113,8 +119,9 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
_advertisingIDEnabled = advertisingIDEnabled;
|
||||
_implicitLoggingEnabled = implicitLoggingEnabled;
|
||||
_implicitPurchaseLoggingEnabled = implicitPurchaseLoggingEnabled;
|
||||
_appIndexingTriggerEnabled = appIndexingTriggerEnabled;
|
||||
_codelessEventsEnabled = codelessEventsEnabled;
|
||||
_systemAuthenticationEnabled = systemAuthenticationEnabled;
|
||||
_uninstallTrackingEnabled = uninstallTrackingEnabled;
|
||||
_nativeAuthFlowEnabled = nativeAuthFlowEnabled;
|
||||
_dialogConfigurations = [dialogConfigurations copy];
|
||||
_dialogFlows = [dialogFlows copy];
|
||||
@ -127,6 +134,8 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
_smartLoginMenuIconURL = [smartLoginMenuIconURL copy];
|
||||
_smartLoginBookmarkIconURL = [smartLoginBookmarkIconURL copy];
|
||||
_updateMessage = [updateMessage copy];
|
||||
_eventBindings = eventBindings;
|
||||
_codelessSetupEnabled = codelessSetupEnabled;
|
||||
_version = FBSDKServerConfigurationVersion;
|
||||
}
|
||||
return self;
|
||||
@ -183,10 +192,12 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
BOOL implicitLoggingEnabled = [decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_IMPLICIT_LOGGING_ENABLED_KEY];
|
||||
BOOL implicitPurchaseLoggingEnabled =
|
||||
[decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_IMPLICIT_PURCHASE_LOGGING_ENABLED_KEY];
|
||||
BOOL appIndexingTriggerEnabled =
|
||||
[decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_APP_INDEXING_TRIGGER_ENABLED_KEY];
|
||||
BOOL codelessEventsEnabled =
|
||||
[decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_CODELESS_EVENTS_ENABLED_KEY];
|
||||
BOOL systemAuthenticationEnabled =
|
||||
[decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_SYSTEM_AUTHENTICATION_ENABLED_KEY];
|
||||
BOOL uninstallTrackingEnabled =
|
||||
[decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_TRACK_UNINSTALL_ENABLED_KEY];
|
||||
FBSDKServerConfigurationSmartLoginOptions smartLoginOptions = [decoder decodeIntegerForKey:FBSDK_SERVER_CONFIGURATION_SMART_LOGIN_OPTIONS_KEY];
|
||||
BOOL nativeAuthFlowEnabled = [decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_NATIVE_AUTH_FLOW_ENABLED_KEY];
|
||||
NSDate *timestamp = [decoder decodeObjectOfClass:[NSDate class] forKey:FBSDK_SERVER_CONFIGURATION_TIMESTAMP_KEY];
|
||||
@ -209,6 +220,8 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
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];
|
||||
NSArray *eventBindings = [decoder decodeObjectOfClass:[NSArray class] forKey:FBSDK_SERVER_CONFIGURATION_EVENT_BINDINGS];
|
||||
BOOL codelessSetupEnabled = [decoder decodeBoolForKey:FBSDK_SERVER_CONFIGURATION_CODELESS_SETUP_ENABLED_KEY];
|
||||
NSInteger version = [decoder decodeIntegerForKey:FBSDK_SERVER_CONFIGURATION_VERSION_KEY];
|
||||
FBSDKServerConfiguration *configuration = [self initWithAppID:appID
|
||||
appName:appName
|
||||
@ -218,9 +231,10 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
advertisingIDEnabled:advertisingIDEnabled
|
||||
implicitLoggingEnabled:implicitLoggingEnabled
|
||||
implicitPurchaseLoggingEnabled:implicitPurchaseLoggingEnabled
|
||||
appIndexingTriggerEnabled:appIndexingTriggerEnabled
|
||||
codelessEventsEnabled:codelessEventsEnabled
|
||||
systemAuthenticationEnabled:systemAuthenticationEnabled
|
||||
nativeAuthFlowEnabled:nativeAuthFlowEnabled
|
||||
uninstallTrackingEnabled:uninstallTrackingEnabled
|
||||
dialogConfigurations:dialogConfigurations
|
||||
dialogFlows:dialogFlows
|
||||
timestamp:timestamp
|
||||
@ -232,6 +246,8 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
smartLoginBookmarkIconURL:smartLoginBookmarkIconURL
|
||||
smartLoginMenuIconURL:smartLoginMenuIconURL
|
||||
updateMessage:updateMessage
|
||||
eventBindings:eventBindings
|
||||
codelessSetupEnabled:codelessSetupEnabled
|
||||
];
|
||||
configuration->_version = version;
|
||||
return configuration;
|
||||
@ -249,9 +265,11 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
[encoder encodeBool:_implicitLoggingEnabled forKey:FBSDK_SERVER_CONFIGURATION_IMPLICIT_LOGGING_ENABLED_KEY];
|
||||
[encoder encodeBool:_implicitPurchaseLoggingEnabled
|
||||
forKey:FBSDK_SERVER_CONFIGURATION_IMPLICIT_PURCHASE_LOGGING_ENABLED_KEY];
|
||||
[encoder encodeBool:_appIndexingTriggerEnabled
|
||||
forKey:FBSDK_SERVER_CONFIGURATION_APP_INDEXING_TRIGGER_ENABLED_KEY];
|
||||
[encoder encodeBool:_codelessEventsEnabled
|
||||
forKey:FBSDK_SERVER_CONFIGURATION_CODELESS_EVENTS_ENABLED_KEY];
|
||||
[encoder encodeBool:_loginTooltipEnabled forKey:FBSDK_SERVER_CONFIGURATION_LOGIN_TOOLTIP_ENABLED_KEY];
|
||||
[encoder encodeBool:_uninstallTrackingEnabled
|
||||
forKey:FBSDK_SERVER_CONFIGURATION_TRACK_UNINSTALL_ENABLED_KEY];
|
||||
[encoder encodeObject:_loginTooltipText forKey:FBSDK_SERVER_CONFIGURATION_LOGIN_TOOLTIP_TEXT_KEY];
|
||||
[encoder encodeBool:_nativeAuthFlowEnabled forKey:FBSDK_SERVER_CONFIGURATION_NATIVE_AUTH_FLOW_ENABLED_KEY];
|
||||
[encoder encodeBool:_systemAuthenticationEnabled forKey:FBSDK_SERVER_CONFIGURATION_SYSTEM_AUTHENTICATION_ENABLED_KEY];
|
||||
@ -262,6 +280,8 @@ implicitPurchaseLoggingEnabled:(BOOL)implicitPurchaseLoggingEnabled
|
||||
[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 encodeObject:_eventBindings forKey:FBSDK_SERVER_CONFIGURATION_EVENT_BINDINGS];
|
||||
[encoder encodeBool:_codelessSetupEnabled forKey:FBSDK_SERVER_CONFIGURATION_CODELESS_SETUP_ENABLED_KEY];
|
||||
[encoder encodeInteger:_version forKey:FBSDK_SERVER_CONFIGURATION_VERSION_KEY];
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#import "FBSDKServerConfiguration.h"
|
||||
|
||||
#define FBSDK_SERVER_CONFIGURATION_MANAGER_CACHE_TIMEOUT (60 * 60)
|
||||
typedef void(^FBSDKServerConfigurationManagerLoadBlock)(FBSDKServerConfiguration *serverConfiguration, NSError *error);
|
||||
|
||||
@interface FBSDKServerConfigurationManager : NSObject
|
||||
|
||||
@ -18,6 +18,9 @@
|
||||
|
||||
#import "FBSDKServerConfigurationManager+Internal.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "FBSDKAppEventsUtility.h"
|
||||
#import "FBSDKGraphRequest+Internal.h"
|
||||
#import "FBSDKGraphRequest.h"
|
||||
#import "FBSDKImageDownloader.h"
|
||||
@ -30,7 +33,6 @@
|
||||
|
||||
// one hour
|
||||
#define DEFAULT_SESSION_TIMEOUT_INTERVAL 60
|
||||
#define FBSDK_SERVER_CONFIGURATION_MANAGER_CACHE_TIMEOUT (60 * 60)
|
||||
|
||||
#define FBSDK_SERVER_CONFIGURATION_USER_DEFAULTS_KEY @"com.facebook.sdk:serverConfiguration%@"
|
||||
|
||||
@ -51,6 +53,8 @@
|
||||
#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"
|
||||
#define FBSDK_SERVER_CONFIGURATION_EVENT_BINDINGS_FIELD @"auto_event_mapping_ios"
|
||||
#define FBSDK_SERVER_CONFIGURATION_CODELESS_SETUP_ENABLED_FIELD @"auto_event_setup_enabled"
|
||||
|
||||
@implementation FBSDKServerConfigurationManager
|
||||
|
||||
@ -61,13 +65,15 @@ static NSError *_serverConfigurationError;
|
||||
static NSDate *_serverConfigurationErrorTimestamp;
|
||||
static const NSTimeInterval kTimeout = 4.0;
|
||||
static BOOL _printedUpdateMessage;
|
||||
static BOOL _requeryFinishedForAppStart;
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
{
|
||||
FBSDKServerConfigurationManagerAppEventsFeaturesNone = 0,
|
||||
FBSDKServerConfigurationManagerAppEventsFeaturesAdvertisingIDEnabled = 1 << 0,
|
||||
FBSDKServerConfigurationManagerAppEventsFeaturesImplicitPurchaseLoggingEnabled = 1 << 1,
|
||||
FBSDKServerConfigurationManagerAppEventsFeaturesAppIndexingTriggerEnabled = 1 << 6,
|
||||
FBSDKServerConfigurationManagerAppEventsFeaturesCodelessEventsTriggerEnabled = 1 << 5,
|
||||
FBSDKServerConfigurationManagerAppEventsFeaturesUninstallTrackingEnabled = 1 << 7,
|
||||
};
|
||||
|
||||
#pragma mark - Public Class Methods
|
||||
@ -132,8 +138,9 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
}
|
||||
}
|
||||
|
||||
if ((_serverConfiguration && [self _serverConfigurationTimestampIsValid:_serverConfiguration.timestamp] && _serverConfiguration.version >= FBSDKServerConfigurationVersion) ||
|
||||
(_serverConfigurationErrorTimestamp && [self _serverConfigurationTimestampIsValid:_serverConfigurationErrorTimestamp])) {
|
||||
if (_requeryFinishedForAppStart &&
|
||||
((_serverConfiguration && [self _serverConfigurationTimestampIsValid:_serverConfiguration.timestamp] && _serverConfiguration.version >= FBSDKServerConfigurationVersion) ||
|
||||
(_serverConfigurationErrorTimestamp && [self _serverConfigurationTimestampIsValid:_serverConfigurationErrorTimestamp]))) {
|
||||
// we have a valid server configuration, use that
|
||||
loadBlock = [self _wrapperBlockForLoadBlock:completionBlock];
|
||||
} else {
|
||||
@ -150,6 +157,7 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
FBSDKGraphRequestConnection *requestConnection = [[FBSDKGraphRequestConnection alloc] init];
|
||||
requestConnection.timeout = kTimeout;
|
||||
[requestConnection addRequest:request completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
|
||||
_requeryFinishedForAppStart = YES;
|
||||
[self processLoadRequestResponse:result error:error appID:appID];
|
||||
}];
|
||||
[requestConnection start];
|
||||
@ -173,9 +181,10 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
|
||||
NSDictionary *resultDictionary = [FBSDKTypeUtility dictionaryValue:result];
|
||||
NSUInteger appEventsFeatures = [FBSDKTypeUtility unsignedIntegerValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_APP_EVENTS_FEATURES_FIELD]];
|
||||
BOOL advertisingIDEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesAdvertisingIDEnabled);
|
||||
BOOL implicitPurchaseLoggingEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesImplicitPurchaseLoggingEnabled);
|
||||
BOOL appIndexingTriggerEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesAppIndexingTriggerEnabled);
|
||||
BOOL advertisingIDEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesAdvertisingIDEnabled) != 0;
|
||||
BOOL implicitPurchaseLoggingEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesImplicitPurchaseLoggingEnabled) != 0;
|
||||
BOOL codelessEventsEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesCodelessEventsTriggerEnabled) != 0;
|
||||
BOOL uninstallTrackingEnabled = (appEventsFeatures & FBSDKServerConfigurationManagerAppEventsFeaturesUninstallTrackingEnabled) != 0;
|
||||
NSString *appName = [FBSDKTypeUtility stringValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_APP_NAME_FIELD]];
|
||||
BOOL loginTooltipEnabled = [FBSDKTypeUtility boolValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_LOGIN_TOOLTIP_ENABLED_FIELD]];
|
||||
NSString *loginTooltipText = [FBSDKTypeUtility stringValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_LOGIN_TOOLTIP_TEXT_FIELD]];
|
||||
@ -194,6 +203,8 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
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]];
|
||||
NSArray *eventBindings = [FBSDKTypeUtility arrayValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_EVENT_BINDINGS_FIELD]];
|
||||
BOOL codelessSetupEnabled = [FBSDKTypeUtility boolValue:resultDictionary[FBSDK_SERVER_CONFIGURATION_CODELESS_SETUP_ENABLED_FIELD]];
|
||||
FBSDKServerConfiguration *serverConfiguration = [[FBSDKServerConfiguration alloc] initWithAppID:appID
|
||||
appName:appName
|
||||
loginTooltipEnabled:loginTooltipEnabled
|
||||
@ -202,9 +213,10 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
advertisingIDEnabled:advertisingIDEnabled
|
||||
implicitLoggingEnabled:implicitLoggingEnabled
|
||||
implicitPurchaseLoggingEnabled:implicitPurchaseLoggingEnabled
|
||||
appIndexingTriggerEnabled:appIndexingTriggerEnabled
|
||||
codelessEventsEnabled:codelessEventsEnabled
|
||||
systemAuthenticationEnabled:systemAuthenticationEnabled
|
||||
nativeAuthFlowEnabled:nativeAuthFlowEnabled
|
||||
uninstallTrackingEnabled:uninstallTrackingEnabled
|
||||
dialogConfigurations:dialogConfigurations
|
||||
dialogFlows:dialogFlows
|
||||
timestamp:[NSDate date]
|
||||
@ -216,6 +228,8 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
smartLoginBookmarkIconURL:smartLoginBookmarkIconURL
|
||||
smartLoginMenuIconURL:smartLoginMenuIconURL
|
||||
updateMessage:updateMessage
|
||||
eventBindings:eventBindings
|
||||
codelessSetupEnabled:codelessSetupEnabled
|
||||
];
|
||||
#if TARGET_OS_TV
|
||||
// don't download icons more than once a day.
|
||||
@ -258,6 +272,10 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
FBSDK_SERVER_CONFIGURATION_SYSTEM_AUTHENTICATION_ENABLED_FIELD,
|
||||
FBSDK_SERVER_CONFIGURATION_SESSION_TIMEOUT_FIELD,
|
||||
FBSDK_SERVER_CONFIGURATION_LOGGIN_TOKEN_FIELD
|
||||
#if !TARGET_OS_TV
|
||||
,FBSDK_SERVER_CONFIGURATION_EVENT_BINDINGS_FIELD
|
||||
,FBSDK_SERVER_CONFIGURATION_CODELESS_SETUP_ENABLED_FIELD
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
,FBSDK_SERVER_CONFIGURATION_UPDATE_MESSAGE_FIELD
|
||||
#endif
|
||||
@ -268,6 +286,15 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
#endif
|
||||
];
|
||||
NSDictionary *parameters = @{ @"fields": [fields componentsJoinedByString:@","] };
|
||||
if (objc_lookUpClass("FBSDKAutoLog") != nil) {
|
||||
NSString *advertiserID = [FBSDKAppEventsUtility advertiserID];
|
||||
|
||||
if (advertiserID) {
|
||||
parameters = @{ @"fields": [fields componentsJoinedByString:@","],
|
||||
@"advertiser_id": advertiserID };
|
||||
}
|
||||
}
|
||||
|
||||
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:appID
|
||||
parameters:parameters
|
||||
tokenString:nil
|
||||
@ -307,9 +334,10 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
advertisingIDEnabled:NO
|
||||
implicitLoggingEnabled:NO
|
||||
implicitPurchaseLoggingEnabled:NO
|
||||
appIndexingTriggerEnabled:NO
|
||||
codelessEventsEnabled:NO
|
||||
systemAuthenticationEnabled:NO
|
||||
nativeAuthFlowEnabled:NO
|
||||
uninstallTrackingEnabled:NO
|
||||
dialogConfigurations:nil
|
||||
dialogFlows:dialogFlows
|
||||
timestamp:nil
|
||||
@ -321,6 +349,8 @@ typedef NS_OPTIONS(NSUInteger, FBSDKServerConfigurationManagerAppEventsFeatures)
|
||||
smartLoginBookmarkIconURL:nil
|
||||
smartLoginMenuIconURL:nil
|
||||
updateMessage:nil
|
||||
eventBindings:nil
|
||||
codelessSetupEnabled:NO
|
||||
];
|
||||
}
|
||||
return _defaultServerConfiguration;
|
||||
|
||||
@ -72,7 +72,8 @@ NSString *const FBSDKTokenInformationUUIDKey = @"com.facebook.sdk:TokenInformati
|
||||
appID:dictionary[FBSDK_TOKEN_INFORMATION_APP_ID_KEY]
|
||||
userID:dictionary[FBSDK_TOKEN_INFORMATION_USER_FBID_KEY]
|
||||
expirationDate:expirationDate
|
||||
refreshDate:dictionary[FBSDK_TOKEN_INFORMATION_REFRESH_DATE_KEY]];
|
||||
refreshDate:dictionary[FBSDK_TOKEN_INFORMATION_REFRESH_DATE_KEY]
|
||||
dataAccessExpirationDate:nil];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ static FBSDKWebDialog *g_currentDialog = nil;
|
||||
{
|
||||
if (_deferVisibility) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (_dialogView) {
|
||||
if (self->_dialogView) {
|
||||
[self _showWebView];
|
||||
}
|
||||
});
|
||||
@ -151,7 +151,7 @@ static FBSDKWebDialog *g_currentDialog = nil;
|
||||
CFTimeInterval animationDuration = (animated ? [CATransactionClass animationDuration] : 0.0);
|
||||
[self _updateViewsWithScale:1.0 alpha:1.0 animationDuration:animationDuration completion:^(BOOL finished) {
|
||||
if (finished) {
|
||||
[_dialogView setNeedsDisplay];
|
||||
[self->_dialogView setNeedsDisplay];
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -208,7 +208,7 @@ static FBSDKWebDialog *g_currentDialog = nil;
|
||||
// defer so that the consumer is guaranteed to have an opportunity to set the delegate before we fail
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _dismissAnimated:YES];
|
||||
[_delegate webDialog:self didFailWithError:error];
|
||||
[self->_delegate webDialog:self didFailWithError:error];
|
||||
});
|
||||
}
|
||||
|
||||
@ -316,15 +316,15 @@ static FBSDKWebDialog *g_currentDialog = nil;
|
||||
}
|
||||
transform = CGAffineTransformScale([self _transformForOrientation], scale, scale);
|
||||
void(^updateBlock)(void) = ^{
|
||||
_dialogView.transform = transform;
|
||||
self->_dialogView.transform = transform;
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
CGRect mainFrame = _dialogView.window.screen.applicationFrame;
|
||||
CGRect mainFrame = self->_dialogView.window.screen.applicationFrame;
|
||||
#pragma clang diagnostic pop
|
||||
_dialogView.center = CGPointMake(CGRectGetMidX(mainFrame),
|
||||
self->_dialogView.center = CGPointMake(CGRectGetMidX(mainFrame),
|
||||
CGRectGetMidY(mainFrame));
|
||||
_backgroundView.alpha = alpha;
|
||||
self->_backgroundView.alpha = alpha;
|
||||
};
|
||||
if (animationDuration == 0.0) {
|
||||
updateBlock();
|
||||
|
||||
@ -565,3 +565,21 @@ CFStringRef fbsdkdfl_kUTTypePNG(void)
|
||||
{
|
||||
_fbsdkdfl_MobileCoreServices_get_and_return_k(kUTTypePNG);
|
||||
}
|
||||
|
||||
#pragma mark - WebKit Classes
|
||||
_fbsdkdfl_load_framework_once_impl_(WebKit)
|
||||
_fbsdkdfl_handle_get_impl_(WebKit)
|
||||
|
||||
#define _fbsdkdfl_WebKit_get_c(SYMBOL) _fbsdkdfl_symbol_get_c(WebKit, SYMBOL);
|
||||
|
||||
Class fbsdkdfl_WKWebViewClass(void)
|
||||
{
|
||||
_fbsdkdfl_WebKit_get_c(WKWebView);
|
||||
return c;
|
||||
}
|
||||
|
||||
Class fbsdkdfl_WKUserScriptClass(void)
|
||||
{
|
||||
_fbsdkdfl_WebKit_get_c(WKUserScript);
|
||||
return c;
|
||||
}
|
||||
|
||||
Binary file not shown.
41
Example/Pods/FBSDKCoreKit/README.md
generated
Normal file
41
Example/Pods/FBSDKCoreKit/README.md
generated
Normal file
@ -0,0 +1,41 @@
|
||||
# Facebook SDK for iOS
|
||||
|
||||
This open-source library allows you to integrate Facebook into your iOS app.
|
||||
|
||||
Learn more about the provided samples, documentation, integrating the SDK into your app, accessing source code, and more at https://developers.facebook.com/docs/ios
|
||||
|
||||
NOTE: By default, the Facebook SDK for iOS is installed in ~/Documents/FacebookSDK
|
||||
|
||||
## TRY IT OUT
|
||||
|
||||
1. Download the SDK at <https://developers.facebook.com/docs/ios> or via CocoaPods by adding the 'FBSDKCoreKit', 'FBSDKLoginKit', and 'FBSDKShareKit' pods.
|
||||
2. Test your install: build and run the project at `~/Documents/FacebookSDK/Samples/Scrumptious/Scrumptious.xcodeproj`
|
||||
3. Check-out the tutorials available online at: <https://developers.facebook.com/docs/ios/getting-started>
|
||||
4. Start coding! Visit <https://developers.facebook.com/docs/ios> for tutorials and reference documentation.
|
||||
|
||||
## FEATURES
|
||||
|
||||
- Login - <https://developers.facebook.com/docs/facebook-login>
|
||||
- Sharing - <https://developers.facebook.com/docs/sharing>
|
||||
- App Links - <https://developers.facebook.com/docs/applinks>
|
||||
- Graph API - <https://developers.facebook.com/docs/ios/graph>
|
||||
- Analytics - <https://developers.facebook.com/docs/analytics>
|
||||
|
||||
## GIVE FEEDBACK
|
||||
|
||||
Please report bugs or issues to <https://developers.facebook.com/bugs/>
|
||||
|
||||
You can also join the [Facebook Developers Group on Facebook](https://www.facebook.com/groups/fbdevelopers/) or ask questions on [Stack Overflow](http://facebook.stackoverflow.com)
|
||||
|
||||
## LICENSE
|
||||
|
||||
See the [LICENSE](LICENSE) file.
|
||||
|
||||
## DEVELOPER TERMS
|
||||
|
||||
- By enabling Facebook integrations, including through this SDK, you can share information with Facebook, including information about people’s use of your app. Facebook will use information received in accordance with our [Data Use Policy](https://www.facebook.com/about/privacy/), including to provide you with insights about the effectiveness of your ads and the use of your app. These integrations also enable us and our partners to serve ads on and off Facebook.
|
||||
- You may limit your sharing of information with us by updating the Insights control in the developer tool `https://developers.facebook.com/apps/{app_id}/settings/advanced`.
|
||||
- If you use a Facebook integration, including to share information with us, you agree and confirm that you have provided appropriate and sufficiently prominent notice to and obtained the appropriate consent from your users regarding such collection, use, and disclosure (including, at a minimum, through your privacy policy). You further agree that you will not share information with us about children under the age of 13.
|
||||
- You agree to comply with all applicable laws and regulations and also agree to our Terms <https://www.facebook.com/policies/>, including our Platform Policies <https://developers.facebook.com/policy/>.and Advertising Guidelines, as applicable <https://www.facebook.com/ad_guidelines.php>.
|
||||
|
||||
By using the Facebook SDK for iOS you agree to these terms.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user