adding pods method of package managing
This commit is contained in:
Generated
+17
@@ -0,0 +1,17 @@
|
||||
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.
|
||||
Generated
+83
@@ -0,0 +1,83 @@
|
||||
# Facebook SDK for iOS
|
||||
|
||||
[](https://cocoapods.org/pods/FBSDKCoreKit)
|
||||
[](https://circleci.com/gh/facebook/facebook-ios-sdk/tree/master)
|
||||
|
||||
[](https://cocoapods.org/pods/FBSDKCoreKit)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
|
||||
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
|
||||
|
||||
Please take a moment and [subscribe to releases](https://docs.github.com/en/enterprise/2.15/user/articles/watching-and-unwatching-repositories) so that you can be notified about new features, deprecations, and critical fixes. To see information about the latest release, consult our [changelog](CHANGELOG.md).
|
||||
|
||||
|
||||
## TRY IT OUT
|
||||
|
||||
### Swift Package Manager
|
||||
|
||||
1. In Xcode, select File > Swift Packages > Add Package Dependency.
|
||||
1. Follow the prompts using the URL for this repository
|
||||
1. Select the `Facebook`-prefixed libraries you want to use
|
||||
1. Check-out the tutorials available online at: <https://developers.facebook.com/docs/ios/getting-started>
|
||||
1. Start coding! Visit <https://developers.facebook.com/docs/ios> for tutorials and reference documentation.
|
||||
|
||||
## iOS 14 CHANGES
|
||||
|
||||
### Data Disclosure
|
||||
|
||||
Due to the release of iOS 14, tracking events that your app collects and sends to Facebook may require you to disclosed these data types in the App Store Connect questionnaire. It is your responsibility to ensure this is reflected in your application’s privacy policy. Visit our blogpost for information on affected Facebook SDKs, APIs, and products and the Apple App Store Privacy Details article to learn more about the data types you will need to disclose.
|
||||
|
||||
link to FB blogpost https://developers.facebook.com/blog/post/2020/10/22/preparing-for-apple-app-store-data-disclosure-requirements/
|
||||
|
||||
apple store details https://developer.apple.com/app-store/app-privacy-details/
|
||||
|
||||
## 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 our designated developer support team -- <https://developers.facebook.com/support/bugs/> -- as this will help us resolve them more quickly.
|
||||
|
||||
You can also visit our [Facebook Developer Community Forum](https://developers.facebook.com/community/),
|
||||
join the [Facebook Developers Group on Facebook](https://www.facebook.com/groups/fbdevelopers/),
|
||||
ask questions on [Stack Overflow](http://facebook.stackoverflow.com),
|
||||
or open an issue in this repository.
|
||||
|
||||
## CONTRIBUTE
|
||||
|
||||
Facebook welcomes contributions to our SDKs. Please see the [CONTRIBUTING](CONTRIBUTING) file.
|
||||
|
||||
## LICENSE
|
||||
|
||||
See the [LICENSE](LICENSE) file.
|
||||
|
||||
## SECURITY POLICY
|
||||
|
||||
See the [SECURITY POLICY](SECURITY.md) for more info on our bug bounty program.
|
||||
|
||||
## 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.
|
||||
@@ -0,0 +1,107 @@
|
||||
// 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 "FBSDKBase64.h"
|
||||
|
||||
@implementation FBSDKBase64
|
||||
|
||||
static FBSDKBase64 *_decoder;
|
||||
static FBSDKBase64 *_encoder;
|
||||
|
||||
#pragma mark - Class Methods
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (self == [FBSDKBase64 class]) {
|
||||
_decoder = [FBSDKBase64 new];
|
||||
_encoder = [FBSDKBase64 new];
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSData *)decodeAsData:(NSString *)string
|
||||
{
|
||||
return [_decoder decodeAsData:string];
|
||||
}
|
||||
|
||||
+ (NSString *)decodeAsString:(NSString *)string
|
||||
{
|
||||
return [_decoder decodeAsString:string];
|
||||
}
|
||||
|
||||
+ (NSString *)encodeData:(NSData *)data
|
||||
{
|
||||
return [_encoder encodeData:data];
|
||||
}
|
||||
|
||||
+ (NSString *)encodeString:(NSString *)string
|
||||
{
|
||||
return [_encoder encodeString:string];
|
||||
}
|
||||
|
||||
+ (NSString *)base64FromBase64Url:(NSString *)base64Url
|
||||
{
|
||||
NSString *base64 = [base64Url stringByReplacingOccurrencesOfString:@"-" withString:@"+"];
|
||||
base64 = [base64 stringByReplacingOccurrencesOfString:@"_" withString:@"/"];
|
||||
|
||||
return base64;
|
||||
}
|
||||
|
||||
#pragma mark - Object Lifecycle
|
||||
|
||||
#pragma mark - Implementation Methods
|
||||
|
||||
- (NSData *)decodeAsData:(NSString *)string
|
||||
{
|
||||
if (!string) {
|
||||
return nil;
|
||||
}
|
||||
// This padding will be appended before stripping unknown characters, so if there are unknown characters of count % 4
|
||||
// it will not be able to decode. Since we assume valid base64 data, we will take this as is.
|
||||
int needPadding = string.length % 4;
|
||||
if (needPadding > 0) {
|
||||
needPadding = 4 - needPadding;
|
||||
string = [string stringByPaddingToLength:string.length + needPadding withString:@"=" startingAtIndex:0];
|
||||
}
|
||||
|
||||
return [[NSData alloc] initWithBase64EncodedString:string options:NSDataBase64DecodingIgnoreUnknownCharacters];
|
||||
}
|
||||
|
||||
- (NSString *)decodeAsString:(NSString *)string
|
||||
{
|
||||
NSData *data = [self decodeAsData:string];
|
||||
if (!data) {
|
||||
return nil;
|
||||
}
|
||||
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
- (NSString *)encodeData:(NSData *)data
|
||||
{
|
||||
if (!data) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [data base64EncodedStringWithOptions:0];
|
||||
}
|
||||
|
||||
- (NSString *)encodeString:(NSString *)string
|
||||
{
|
||||
return [self encodeData:[string dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,372 @@
|
||||
// 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 "FBSDKBasicUtility.h"
|
||||
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
#import <zlib.h>
|
||||
|
||||
#import "FBSDKTypeUtility.h"
|
||||
|
||||
#define kChunkSize 1024
|
||||
|
||||
static NSString *const FBSDK_BASICUTILITY_ANONYMOUSIDFILENAME = @"com-facebook-sdk-PersistedAnonymousID.json";
|
||||
static NSString *const FBSDK_BASICUTILITY_ANONYMOUSID_KEY = @"anon_id";
|
||||
|
||||
void fb_dispatch_on_main_thread(dispatch_block_t block)
|
||||
{
|
||||
if (block != nil) {
|
||||
if ([NSThread isMainThread]) {
|
||||
block();
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fb_dispatch_on_default_thread(dispatch_block_t block)
|
||||
{
|
||||
if (block != nil) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
|
||||
}
|
||||
}
|
||||
|
||||
@protocol BASIC_FBSDKError
|
||||
|
||||
+ (NSError *)invalidArgumentErrorWithName:(NSString *)name value:(id)value message:(NSString *)message;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKBasicUtility
|
||||
|
||||
+ (NSString *)JSONStringForObject:(id)object
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
invalidObjectHandler:(FBSDKInvalidObjectHandler)invalidObjectHandler
|
||||
{
|
||||
if (invalidObjectHandler || ![FBSDKTypeUtility isValidJSONObject:object]) {
|
||||
object = [self _convertObjectToJSONObject:object invalidObjectHandler:invalidObjectHandler stop:NULL];
|
||||
if (![FBSDKTypeUtility isValidJSONObject:object]) {
|
||||
if (errorRef != NULL) {
|
||||
Class FBSDKErrorClass = NSClassFromString(@"FBSDKError");
|
||||
if ([FBSDKErrorClass respondsToSelector:@selector(invalidArgumentErrorWithName:value:message:)]) {
|
||||
*errorRef = [FBSDKErrorClass invalidArgumentErrorWithName:@"object"
|
||||
value:object
|
||||
message:@"Invalid object for JSON serialization."];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
NSData *data = [FBSDKTypeUtility dataWithJSONObject:object options:0 error:errorRef];
|
||||
if (!data) {
|
||||
return nil;
|
||||
}
|
||||
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
+ (BOOL) dictionary:(NSMutableDictionary<NSString *, id> *)dictionary
|
||||
setJSONStringForObject:(id)object
|
||||
forKey:(id<NSCopying>)key
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
{
|
||||
if (!object || !key) {
|
||||
return YES;
|
||||
}
|
||||
NSString *JSONString = [self JSONStringForObject:object error:errorRef invalidObjectHandler:NULL];
|
||||
if (!JSONString) {
|
||||
return NO;
|
||||
}
|
||||
[FBSDKTypeUtility dictionary:dictionary setObject:JSONString forKey:key];
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (id)_convertObjectToJSONObject:(id)object
|
||||
invalidObjectHandler:(FBSDKInvalidObjectHandler)invalidObjectHandler
|
||||
stop:(BOOL *)stopRef
|
||||
{
|
||||
__block BOOL stop = NO;
|
||||
if ([object isKindOfClass:[NSString class]] || [object isKindOfClass:[NSNumber class]]) {
|
||||
// good to go, keep the object
|
||||
} else if ([object isKindOfClass:[NSURL class]]) {
|
||||
object = ((NSURL *)object).absoluteString;
|
||||
} else if ([object isKindOfClass:[NSDictionary class]]) {
|
||||
NSMutableDictionary<NSString *, id> *dictionary = [NSMutableDictionary new];
|
||||
[FBSDKTypeUtility dictionary:(NSDictionary<id, id> *) object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *dictionaryStop) {
|
||||
[FBSDKTypeUtility dictionary:dictionary
|
||||
setObject:[self _convertObjectToJSONObject:obj invalidObjectHandler:invalidObjectHandler stop:&stop]
|
||||
forKey:[FBSDKTypeUtility coercedToStringValue:key]];
|
||||
if (stop) {
|
||||
*dictionaryStop = YES;
|
||||
}
|
||||
}];
|
||||
object = dictionary;
|
||||
} else if ([object isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray<id> *array = [NSMutableArray new];
|
||||
for (id obj in (NSArray *)object) {
|
||||
id convertedObj = [self _convertObjectToJSONObject:obj invalidObjectHandler:invalidObjectHandler stop:&stop];
|
||||
[FBSDKTypeUtility array:array addObject:convertedObj];
|
||||
if (stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
object = array;
|
||||
} else {
|
||||
object = invalidObjectHandler(object, stopRef);
|
||||
}
|
||||
if (stopRef != NULL) {
|
||||
*stopRef = stop;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
+ (id)objectForJSONString:(NSString *)string error:(NSError *__autoreleasing *)errorRef
|
||||
{
|
||||
NSData *data = [[FBSDKTypeUtility stringValueOrNil:string] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
if (!data) {
|
||||
if (errorRef != NULL) {
|
||||
*errorRef = nil;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
return [FBSDKTypeUtility JSONObjectWithData:data options:NSJSONReadingAllowFragments error:errorRef];
|
||||
}
|
||||
|
||||
+ (nullable NSString *)queryStringWithDictionary:(NSDictionary<NSString *, id> *)dictionary
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
invalidObjectHandler:(FBSDKInvalidObjectHandler)invalidObjectHandler
|
||||
{
|
||||
NSMutableString *queryString = [NSMutableString new];
|
||||
__block BOOL hasParameters = NO;
|
||||
if (dictionary) {
|
||||
NSMutableArray<NSString *> *keys = [dictionary.allKeys mutableCopy];
|
||||
// remove non-string keys, as they are not valid
|
||||
[keys filterUsingPredicate:[NSPredicate predicateWithBlock:^BOOL (id evaluatedObject, NSDictionary<id, id> *bindings) {
|
||||
return [evaluatedObject isKindOfClass:[NSString class]];
|
||||
}]];
|
||||
// sort the keys so that the query string order is deterministic
|
||||
[keys sortUsingSelector:@selector(compare:)];
|
||||
BOOL stop = NO;
|
||||
for (NSString *key in keys) {
|
||||
id value = [self convertRequestValue:dictionary[key]];
|
||||
if ([value isKindOfClass:[NSString class]]) {
|
||||
value = [self URLEncode:value];
|
||||
}
|
||||
if (invalidObjectHandler && ![value isKindOfClass:[NSString class]]) {
|
||||
value = invalidObjectHandler(value, &stop);
|
||||
if (stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value) {
|
||||
if (hasParameters) {
|
||||
[queryString appendString:@"&"];
|
||||
}
|
||||
[queryString appendFormat:@"%@=%@", key, value];
|
||||
hasParameters = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errorRef != NULL) {
|
||||
*errorRef = nil;
|
||||
}
|
||||
return (queryString.length ? [queryString copy] : nil);
|
||||
}
|
||||
|
||||
+ (id)convertRequestValue:(id)value
|
||||
{
|
||||
if ([value isKindOfClass:[NSNumber class]]) {
|
||||
value = ((NSNumber *)value).stringValue;
|
||||
} else if ([value isKindOfClass:[NSURL class]]) {
|
||||
value = ((NSURL *)value).absoluteString;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
+ (NSString *)URLEncode:(NSString *)value
|
||||
{
|
||||
return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(
|
||||
NULL,
|
||||
(CFStringRef)value,
|
||||
NULL, // characters to leave unescaped
|
||||
CFSTR(":!*();@/&?+$,='"),
|
||||
kCFStringEncodingUTF8
|
||||
);
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
+ (NSDictionary<NSString *, NSString *> *)dictionaryWithQueryString:(NSString *)queryString
|
||||
{
|
||||
NSMutableDictionary<NSString *, NSString *> *result = [NSMutableDictionary new];
|
||||
NSArray<NSString *> *parts = [queryString componentsSeparatedByString:@"&"];
|
||||
|
||||
for (NSString *part in parts) {
|
||||
if (part.length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NSRange index = [part rangeOfString:@"="];
|
||||
NSString *key;
|
||||
NSString *value;
|
||||
|
||||
if (index.location == NSNotFound) {
|
||||
key = part;
|
||||
value = @"";
|
||||
} else {
|
||||
key = [part substringToIndex:index.location];
|
||||
value = [part substringFromIndex:index.location + index.length];
|
||||
}
|
||||
|
||||
key = [self URLDecode:key];
|
||||
value = [self URLDecode:value];
|
||||
if (key && value) {
|
||||
[FBSDKTypeUtility dictionary:result setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (NSString *)URLDecode:(NSString *)value
|
||||
{
|
||||
value = [value stringByReplacingOccurrencesOfString:@"+" withString:@" "];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
value = [value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
#pragma clang diagnostic pop
|
||||
return value;
|
||||
}
|
||||
|
||||
+ (NSData *)gzip:(NSData *)data
|
||||
{
|
||||
const void *bytes = data.bytes;
|
||||
const NSUInteger length = data.length;
|
||||
|
||||
if (!bytes || !length) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
#if defined(__LP64__) && __LP64__
|
||||
if (length > UINT_MAX) {
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
// initialze stream
|
||||
z_stream stream;
|
||||
bzero(&stream, sizeof(z_stream));
|
||||
|
||||
if (deflateInit2(&stream, -1, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
return nil;
|
||||
}
|
||||
stream.avail_in = (uint)length;
|
||||
stream.next_in = (Bytef *)bytes;
|
||||
|
||||
int retCode;
|
||||
NSMutableData *result = [NSMutableData dataWithCapacity:(length / 4)];
|
||||
unsigned char output[kChunkSize];
|
||||
do {
|
||||
stream.avail_out = kChunkSize;
|
||||
stream.next_out = output;
|
||||
retCode = deflate(&stream, Z_FINISH);
|
||||
if (retCode != Z_OK && retCode != Z_STREAM_END) {
|
||||
deflateEnd(&stream);
|
||||
return nil;
|
||||
}
|
||||
unsigned size = kChunkSize - stream.avail_out;
|
||||
if (size > 0) {
|
||||
[result appendBytes:output length:size];
|
||||
}
|
||||
} while (retCode == Z_OK);
|
||||
|
||||
deflateEnd(&stream);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (NSString *)anonymousID
|
||||
{
|
||||
// Grab previously written anonymous ID and, if none have been generated, create and
|
||||
// persist a new one which will remain associated with this app.
|
||||
NSString *result = [[self class] retrievePersistedAnonymousID];
|
||||
if (!result) {
|
||||
// Generate a new anonymous ID. Create as a UUID, but then prepend the fairly
|
||||
// arbitrary 'XZ' to the front so it's easily distinguishable from IDFA's which
|
||||
// will only contain hex.
|
||||
result = [NSString stringWithFormat:@"XZ%@", [NSUUID UUID].UUIDString];
|
||||
|
||||
[self persistAnonymousID:result];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (NSString *)retrievePersistedAnonymousID
|
||||
{
|
||||
NSString *file = [[self class] persistenceFilePath:FBSDK_BASICUTILITY_ANONYMOUSIDFILENAME];
|
||||
NSString *content = [[NSString alloc] initWithContentsOfFile:file
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil];
|
||||
NSDictionary<NSString *, id> *results = [FBSDKBasicUtility objectForJSONString:content error:NULL];
|
||||
return results[FBSDK_BASICUTILITY_ANONYMOUSID_KEY];
|
||||
}
|
||||
|
||||
+ (NSString *)persistenceFilePath:(NSString *)filename
|
||||
{
|
||||
NSSearchPathDirectory directory = NSLibraryDirectory;
|
||||
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
|
||||
NSString *docDirectory = [FBSDKTypeUtility array:paths objectAtIndex:0];
|
||||
return [docDirectory stringByAppendingPathComponent:filename];
|
||||
}
|
||||
|
||||
+ (void)persistAnonymousID:(NSString *)anonymousID
|
||||
{
|
||||
NSDictionary<NSString *, NSString *> *data = @{ FBSDK_BASICUTILITY_ANONYMOUSID_KEY : anonymousID };
|
||||
NSString *content = [self JSONStringForObject:data error:NULL invalidObjectHandler:NULL];
|
||||
|
||||
[content writeToFile:[[self class] persistenceFilePath:FBSDK_BASICUTILITY_ANONYMOUSIDFILENAME]
|
||||
atomically:YES
|
||||
encoding:NSASCIIStringEncoding
|
||||
error:nil];
|
||||
}
|
||||
|
||||
+ (NSString *)SHA256Hash:(NSObject *)input
|
||||
{
|
||||
NSData *data = nil;
|
||||
|
||||
if ([input isKindOfClass:[NSData class]]) {
|
||||
data = (NSData *)input;
|
||||
} else if ([input isKindOfClass:[NSString class]]) {
|
||||
data = [(NSString *)input dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
uint8_t digest[CC_SHA256_DIGEST_LENGTH];
|
||||
CC_SHA256(data.bytes, (CC_LONG)data.length, digest);
|
||||
NSMutableString *hashed = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2];
|
||||
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) {
|
||||
[hashed appendFormat:@"%02x", digest[i]];
|
||||
}
|
||||
|
||||
return [hashed copy];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,484 @@
|
||||
// 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 "FBSDKCrashHandler.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <sys/utsname.h>
|
||||
|
||||
#import "FBSDKCrashObserving.h"
|
||||
#import "FBSDKFileDataExtracting.h"
|
||||
#import "FBSDKFileManaging.h"
|
||||
#import "FBSDKLibAnalyzer.h"
|
||||
#import "FBSDKTypeUtility.h"
|
||||
#import "NSBundle+InfoDictionaryProviding.h"
|
||||
|
||||
#define FBSDK_MAX_CRASH_LOGS 5
|
||||
#define FBSDK_CRASH_PATH_NAME @"instrument"
|
||||
#ifndef FBSDK_VERSION_STRING
|
||||
#define FBSDK_VERSION_STRING @"11.2.1"
|
||||
#endif
|
||||
|
||||
static NSUncaughtExceptionHandler *previousExceptionHandler = NULL;
|
||||
static NSString *mappingTableIdentifier = NULL;
|
||||
static NSString *directoryPath;
|
||||
|
||||
NSString *const kFBSDKAppVersion = @"app_version";
|
||||
NSString *const kFBSDKCallstack = @"callstack";
|
||||
NSString *const kFBSDKCrashReason = @"reason";
|
||||
NSString *const kFBSDKCrashTimestamp = @"timestamp";
|
||||
NSString *const kFBSDKDeviceModel = @"device_model";
|
||||
NSString *const kFBSDKDeviceOSVersion = @"device_os_version";
|
||||
|
||||
NSString *const kFBSDKMapingTable = @"mapping_table";
|
||||
NSString *const kFBSDKMappingTableIdentifier = @"mapping_table_identifier";
|
||||
|
||||
@interface FBSDKCrashHandler ()
|
||||
|
||||
@property (nonatomic) BOOL isTurnedOn;
|
||||
@property (nonatomic) id<FBSDKFileManaging> fileManager;
|
||||
@property (nonatomic, strong) Class<FBSDKFileDataExtracting> dataExtractor;
|
||||
@property (nonatomic) id<FBSDKInfoDictionaryProviding> bundle;
|
||||
@property (nonatomic) NSHashTable<id<FBSDKCrashObserving>> *observers;
|
||||
@property (nonatomic) NSArray<NSDictionary<NSString *, id> *> *processedCrashLogs;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKCrashHandler
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
return [self initWithFileManager:NSFileManager.defaultManager
|
||||
bundle:NSBundle.mainBundle
|
||||
fileDataExtractor:NSData.class
|
||||
];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFileManager:(id<FBSDKFileManaging>)fileManager
|
||||
bundle:(id<FBSDKInfoDictionaryProviding>)bundle
|
||||
fileDataExtractor:(nonnull Class<FBSDKFileDataExtracting>)dataExtractor
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_observers = [NSHashTable new];
|
||||
_isTurnedOn = YES;
|
||||
_fileManager = fileManager;
|
||||
_bundle = bundle;
|
||||
_dataExtractor = dataExtractor;
|
||||
|
||||
NSString *dirPath = [NSTemporaryDirectory() stringByAppendingPathComponent:FBSDK_CRASH_PATH_NAME];
|
||||
if (![_fileManager fileExistsAtPath:dirPath]) {
|
||||
[_fileManager createDirectoryAtPath:dirPath withIntermediateDirectories:NO attributes:NULL error:NULL];
|
||||
}
|
||||
directoryPath = dirPath;
|
||||
NSString *identifier = [[NSUUID UUID] UUIDString];
|
||||
mappingTableIdentifier = [identifier stringByReplacingOccurrencesOfString:@"-" withString:@""];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)shared
|
||||
{
|
||||
static dispatch_once_t nonce;
|
||||
static id instance;
|
||||
dispatch_once(&nonce, ^{
|
||||
instance = [self new];
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
#pragma mark - Public API
|
||||
|
||||
+ (NSString *)getFBSDKVersion
|
||||
{
|
||||
return FBSDK_VERSION_STRING;
|
||||
}
|
||||
|
||||
+ (void)disable
|
||||
{
|
||||
[FBSDKCrashHandler.shared disable];
|
||||
}
|
||||
|
||||
- (void)disable
|
||||
{
|
||||
self.isTurnedOn = NO;
|
||||
[FBSDKCrashHandler.shared _uninstallExceptionsHandler];
|
||||
self.observers = nil;
|
||||
}
|
||||
|
||||
+ (void)addObserver:(id<FBSDKCrashObserving>)observer
|
||||
{
|
||||
[FBSDKCrashHandler.shared addObserver:observer];
|
||||
}
|
||||
|
||||
- (void)addObserver:(id<FBSDKCrashObserving>)observer
|
||||
{
|
||||
if (!self.isTurnedOn || ![self _isSafeToGenerateMapping]) {
|
||||
return;
|
||||
}
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[FBSDKCrashHandler.shared _installExceptionsHandler];
|
||||
_processedCrashLogs = [self _getProcessedCrashLogs];
|
||||
});
|
||||
@synchronized(_observers) {
|
||||
if (![self.observers containsObject:observer]) {
|
||||
[self.observers addObject:observer];
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) {
|
||||
[self _generateMethodMapping:observer];
|
||||
});
|
||||
[self _sendCrashLogs];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)removeObserver:(id<FBSDKCrashObserving>)observer
|
||||
{
|
||||
[FBSDKCrashHandler.shared removeObserver:observer];
|
||||
}
|
||||
|
||||
- (void)removeObserver:(id<FBSDKCrashObserving>)observer
|
||||
{
|
||||
@synchronized(_observers) {
|
||||
if ([self.observers containsObject:observer]) {
|
||||
[self.observers removeObject:observer];
|
||||
if (self.observers.count == 0) {
|
||||
[FBSDKCrashHandler.shared _uninstallExceptionsHandler];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)clearCrashReportFiles
|
||||
{
|
||||
[FBSDKCrashHandler.shared clearCrashReportFiles];
|
||||
}
|
||||
|
||||
- (void)clearCrashReportFiles
|
||||
{
|
||||
NSArray<NSString *> *files = [self.fileManager contentsOfDirectoryAtPath:directoryPath error:nil];
|
||||
|
||||
for (NSUInteger i = 0; i < files.count; i++) {
|
||||
// remove all crash related files except for the current mapping table
|
||||
if ([[FBSDKTypeUtility array:files objectAtIndex:i] hasPrefix:@"crash_"] && ![[FBSDKTypeUtility array:files objectAtIndex:i] containsString:mappingTableIdentifier]) {
|
||||
[self.fileManager removeItemAtPath:[directoryPath stringByAppendingPathComponent:[FBSDKTypeUtility array:files objectAtIndex:i]] error:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# pragma mark - Handler
|
||||
|
||||
+ (void)_installExceptionsHandler
|
||||
{
|
||||
[FBSDKCrashHandler.shared _installExceptionsHandler];
|
||||
}
|
||||
|
||||
- (void)_installExceptionsHandler
|
||||
{
|
||||
NSUncaughtExceptionHandler *currentHandler = NSGetUncaughtExceptionHandler();
|
||||
|
||||
if (currentHandler != FBSDKExceptionHandler) {
|
||||
previousExceptionHandler = currentHandler;
|
||||
NSSetUncaughtExceptionHandler(&FBSDKExceptionHandler);
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)_uninstallExceptionsHandler
|
||||
{
|
||||
[FBSDKCrashHandler.shared _uninstallExceptionsHandler];
|
||||
}
|
||||
|
||||
- (void)_uninstallExceptionsHandler
|
||||
{
|
||||
NSSetUncaughtExceptionHandler(previousExceptionHandler);
|
||||
previousExceptionHandler = nil;
|
||||
}
|
||||
|
||||
static void FBSDKExceptionHandler(NSException *exception)
|
||||
{
|
||||
[FBSDKCrashHandler.shared _saveException:exception];
|
||||
if (previousExceptionHandler) {
|
||||
previousExceptionHandler(exception);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Storage & Process
|
||||
|
||||
+ (void)_saveException:(NSException *)exception
|
||||
{
|
||||
[FBSDKCrashHandler.shared _saveException:exception];
|
||||
}
|
||||
|
||||
- (void)_saveException:(NSException *)exception
|
||||
{
|
||||
if (exception.callStackSymbols && exception.name) {
|
||||
NSArray<NSString *> *stackSymbols = [NSArray arrayWithArray:exception.callStackSymbols];
|
||||
[self _saveCrashLog:@{
|
||||
kFBSDKCallstack : stackSymbols,
|
||||
kFBSDKCrashReason : exception.name,
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSArray<NSDictionary<NSString *, id> *> *)_getProcessedCrashLogs
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _getProcessedCrashLogs];
|
||||
}
|
||||
|
||||
- (NSArray<NSDictionary<NSString *, id> *> *)_getProcessedCrashLogs
|
||||
{
|
||||
NSArray<NSDictionary<NSString *, id> *> *crashLogs = [self _loadCrashLogs];
|
||||
if (0 == crashLogs.count) {
|
||||
[self clearCrashReportFiles];
|
||||
return nil;
|
||||
}
|
||||
NSMutableArray<NSDictionary<NSString *, id> *> *processedCrashLogs = [NSMutableArray array];
|
||||
|
||||
for (NSDictionary<NSString *, id> *crashLog in crashLogs) {
|
||||
NSArray<NSString *> *callstack = crashLog[kFBSDKCallstack];
|
||||
NSData *data = [self _loadLibData:crashLog];
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
NSDictionary<NSString *, id> *methodMapping = [FBSDKTypeUtility JSONObjectWithData:data
|
||||
options:kNilOptions
|
||||
error:nil];
|
||||
NSArray<NSString *> *symbolicatedCallstack = [FBSDKLibAnalyzer symbolicateCallstack:callstack methodMapping:methodMapping];
|
||||
NSMutableDictionary<NSString *, id> *symbolicatedCrashLog = [NSMutableDictionary dictionaryWithDictionary:crashLog];
|
||||
if (symbolicatedCallstack) {
|
||||
[FBSDKTypeUtility dictionary:symbolicatedCrashLog setObject:symbolicatedCallstack forKey:kFBSDKCallstack];
|
||||
[symbolicatedCrashLog removeObjectForKey:kFBSDKMappingTableIdentifier];
|
||||
[FBSDKTypeUtility array:processedCrashLogs addObject:symbolicatedCrashLog];
|
||||
}
|
||||
}
|
||||
return processedCrashLogs;
|
||||
}
|
||||
|
||||
+ (NSArray<NSDictionary<NSString *, id> *> *)_loadCrashLogs
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _loadCrashLogs];
|
||||
}
|
||||
|
||||
- (NSArray<NSDictionary<NSString *, id> *> *)_loadCrashLogs
|
||||
{
|
||||
NSArray<NSString *> *files = [self.fileManager contentsOfDirectoryAtPath:directoryPath error:NULL];
|
||||
NSArray<NSString *> *fileNames = [[self _getCrashLogFileNames:files] sortedArrayUsingComparator:^NSComparisonResult (id _Nonnull obj1, id _Nonnull obj2) {
|
||||
return [obj2 compare:obj1];
|
||||
}];
|
||||
NSMutableArray<NSDictionary<NSString *, id> *> *crashLogArray = [NSMutableArray array];
|
||||
|
||||
for (NSUInteger i = 0; i < MIN(fileNames.count, FBSDK_MAX_CRASH_LOGS); i++) {
|
||||
NSData *data = [self _loadCrashLog:[FBSDKTypeUtility array:fileNames objectAtIndex:i]];
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
NSDictionary<NSString *, id> *crashLog = [FBSDKTypeUtility JSONObjectWithData:data
|
||||
options:kNilOptions
|
||||
error:nil];
|
||||
if (crashLog) {
|
||||
[FBSDKTypeUtility array:crashLogArray addObject:crashLog];
|
||||
}
|
||||
}
|
||||
return [crashLogArray copy];
|
||||
}
|
||||
|
||||
+ (nullable NSData *)_loadCrashLog:(NSString *)fileName
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _loadCrashLog:fileName];
|
||||
}
|
||||
|
||||
- (nullable NSData *)_loadCrashLog:(NSString *)fileName
|
||||
{
|
||||
return [self.dataExtractor dataWithContentsOfFile:[directoryPath stringByAppendingPathComponent:fileName] options:NSDataReadingMappedIfSafe error:nil];
|
||||
}
|
||||
|
||||
+ (NSArray<NSString *> *)_getCrashLogFileNames:(NSArray<NSString *> *)files
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _getCrashLogFileNames:files];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)_getCrashLogFileNames:(NSArray<NSString *> *)files
|
||||
{
|
||||
NSMutableArray<NSString *> *fileNames = [NSMutableArray array];
|
||||
|
||||
for (NSString *fileName in files) {
|
||||
if ([fileName hasPrefix:@"crash_log_"] && [fileName hasSuffix:@".json"]) {
|
||||
[FBSDKTypeUtility array:fileNames addObject:fileName];
|
||||
}
|
||||
}
|
||||
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
+ (void)_saveCrashLog:(NSDictionary<NSString *, id> *)crashLog
|
||||
{
|
||||
[FBSDKCrashHandler.shared _saveCrashLog:crashLog];
|
||||
}
|
||||
|
||||
- (void)_saveCrashLog:(NSDictionary<NSString *, id> *)crashLog
|
||||
{
|
||||
NSMutableDictionary<NSString *, id> *completeCrashLog = [NSMutableDictionary dictionaryWithDictionary:crashLog];
|
||||
NSString *currentTimestamp = [NSString stringWithFormat:@"%.0lf", [[NSDate date] timeIntervalSince1970]];
|
||||
|
||||
[FBSDKTypeUtility dictionary:completeCrashLog setObject:currentTimestamp forKey:kFBSDKCrashTimestamp];
|
||||
[FBSDKTypeUtility dictionary:completeCrashLog setObject:mappingTableIdentifier forKey:kFBSDKMappingTableIdentifier];
|
||||
|
||||
NSString *version = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
||||
NSString *build = [self.bundle objectForInfoDictionaryKey:@"CFBundleVersion"];
|
||||
[FBSDKTypeUtility dictionary:completeCrashLog setObject:[NSString stringWithFormat:@"%@(%@)", version, build] forKey:kFBSDKAppVersion];
|
||||
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
[FBSDKTypeUtility dictionary:completeCrashLog setObject:@(systemInfo.machine) forKey:kFBSDKDeviceModel];
|
||||
|
||||
[FBSDKTypeUtility dictionary:completeCrashLog setObject:[UIDevice currentDevice].systemVersion forKey:kFBSDKDeviceOSVersion];
|
||||
|
||||
NSData *data = [FBSDKTypeUtility dataWithJSONObject:completeCrashLog options:0 error:nil];
|
||||
|
||||
[data writeToFile:[self _getPathToCrashFile:currentTimestamp]
|
||||
atomically:YES];
|
||||
}
|
||||
|
||||
+ (void)_sendCrashLogs
|
||||
{
|
||||
[FBSDKCrashHandler.shared _sendCrashLogs];
|
||||
}
|
||||
|
||||
- (void)_sendCrashLogs
|
||||
{
|
||||
for (id<FBSDKCrashObserving> observer in _observers) {
|
||||
if (observer) {
|
||||
NSArray<NSDictionary<NSString *, id> *> *filteredCrashLogs = [self _filterCrashLogs:observer.prefixes processedCrashLogs:_processedCrashLogs];
|
||||
[observer didReceiveCrashLogs:filteredCrashLogs];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSArray<NSDictionary<NSString *, id> *> *)_filterCrashLogs:(NSArray<NSString *> *)prefixList
|
||||
processedCrashLogs:(NSArray<NSDictionary<NSString *, id> *> *)processedCrashLogs
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _filterCrashLogs:prefixList processedCrashLogs:processedCrashLogs];
|
||||
}
|
||||
|
||||
- (NSArray<NSDictionary<NSString *, id> *> *)_filterCrashLogs:(NSArray<NSString *> *)prefixList
|
||||
processedCrashLogs:(NSArray<NSDictionary<NSString *, id> *> *)processedCrashLogs
|
||||
{
|
||||
NSMutableArray<NSDictionary<NSString *, id> *> *crashLogs = [NSMutableArray array];
|
||||
for (NSDictionary<NSString *, id> *crashLog in processedCrashLogs) {
|
||||
NSArray<NSString *> *callstack = crashLog[kFBSDKCallstack];
|
||||
if ([self _callstack:callstack containsPrefix:prefixList]) {
|
||||
[FBSDKTypeUtility array:crashLogs addObject:crashLog];
|
||||
}
|
||||
}
|
||||
return crashLogs;
|
||||
}
|
||||
|
||||
+ (BOOL)_callstack:(NSArray<NSString *> *)callstack
|
||||
containsPrefix:(NSArray<NSString *> *)prefixList
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _callstack:callstack containsPrefix:prefixList];
|
||||
}
|
||||
|
||||
- (BOOL)_callstack:(NSArray<NSString *> *)callstack
|
||||
containsPrefix:(NSArray<NSString *> *)prefixList
|
||||
{
|
||||
NSString *callStackString = [callstack componentsJoinedByString:@""];
|
||||
for (NSString *prefix in prefixList) {
|
||||
if ([callStackString containsString:prefix]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark - Method Mapping
|
||||
|
||||
+ (void)_generateMethodMapping:(id<FBSDKCrashObserving>)observer
|
||||
{
|
||||
[FBSDKCrashHandler.shared _generateMethodMapping:observer];
|
||||
}
|
||||
|
||||
- (void)_generateMethodMapping:(id<FBSDKCrashObserving>)observer
|
||||
{
|
||||
if (observer.prefixes.count == 0) {
|
||||
return;
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setObject:mappingTableIdentifier forKey:kFBSDKMappingTableIdentifier];
|
||||
NSDictionary<NSString *, NSString *> *methodMapping = [FBSDKLibAnalyzer getMethodsTable:observer.prefixes
|
||||
frameworks:observer.frameworks];
|
||||
if (methodMapping.count > 0) {
|
||||
NSData *data = [FBSDKTypeUtility dataWithJSONObject:methodMapping options:0 error:nil];
|
||||
[data writeToFile:[self _getPathToLibDataFile:mappingTableIdentifier]
|
||||
atomically:YES];
|
||||
}
|
||||
}
|
||||
|
||||
+ (nullable NSData *)_loadLibData:(NSDictionary<NSString *, id> *)crashLog
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _loadLibData:crashLog];
|
||||
}
|
||||
|
||||
- (nullable NSData *)_loadLibData:(NSDictionary<NSString *, id> *)crashLog
|
||||
{
|
||||
NSString *identifier = [FBSDKTypeUtility dictionary:crashLog objectForKey:kFBSDKMappingTableIdentifier ofType:NSObject.class];
|
||||
return [self.dataExtractor dataWithContentsOfFile:[self _getPathToLibDataFile:identifier] options:NSDataReadingMappedIfSafe error:nil];
|
||||
}
|
||||
|
||||
+ (NSString *)_getPathToCrashFile:(NSString *)timestamp
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _getPathToCrashFile:timestamp];
|
||||
}
|
||||
|
||||
- (NSString *)_getPathToCrashFile:(NSString *)timestamp
|
||||
{
|
||||
return [directoryPath stringByAppendingPathComponent:
|
||||
[NSString stringWithFormat:@"crash_log_%@.json", timestamp]];
|
||||
}
|
||||
|
||||
+ (NSString *)_getPathToLibDataFile:(NSString *)identifier
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _getPathToLibDataFile:identifier];
|
||||
}
|
||||
|
||||
- (NSString *)_getPathToLibDataFile:(NSString *)identifier
|
||||
{
|
||||
return [directoryPath stringByAppendingPathComponent:
|
||||
[NSString stringWithFormat:@"crash_lib_data_%@.json", identifier]];
|
||||
}
|
||||
|
||||
+ (BOOL)_isSafeToGenerateMapping
|
||||
{
|
||||
return [FBSDKCrashHandler.shared _isSafeToGenerateMapping];
|
||||
}
|
||||
|
||||
- (BOOL)_isSafeToGenerateMapping
|
||||
{
|
||||
#if TARGET_OS_SIMULATOR
|
||||
return YES;
|
||||
#else
|
||||
NSString *identifier = [[NSUserDefaults standardUserDefaults] objectForKey:kFBSDKMappingTableIdentifier];
|
||||
// first app start
|
||||
if (!identifier) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return [self.fileManager fileExistsAtPath:[self _getPathToLibDataFile:identifier]];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,232 @@
|
||||
// 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 "FBSDKJSONValue.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FBSDKBasicUtility.h"
|
||||
#import "FBSDKSafeCast.h"
|
||||
#import "FBSDKTypeUtility.h"
|
||||
|
||||
@interface FBSDKJSONField ()
|
||||
- (instancetype)initWithPotentialJSONField:(id)obj;
|
||||
@end
|
||||
|
||||
static NSArray<FBSDKJSONField *> *createArray(id obj)
|
||||
{
|
||||
NSArray *const original = FBSDK_CAST_TO_CLASS_OR_NIL(obj, NSArray);
|
||||
if (!original) {
|
||||
return @[];
|
||||
}
|
||||
|
||||
NSMutableArray<FBSDKJSONField *> *const fields =
|
||||
[[NSMutableArray alloc] initWithCapacity:original.count];
|
||||
|
||||
for (id field in original) {
|
||||
FBSDKJSONField *const f = [[FBSDKJSONField alloc] initWithPotentialJSONField:field];
|
||||
if (f) {
|
||||
[fields addObject:f];
|
||||
}
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
static NSDictionary<NSString *, FBSDKJSONField *> *createDictionary(id obj)
|
||||
{
|
||||
NSDictionary *const original = FBSDK_CAST_TO_CLASS_OR_NIL(obj, NSDictionary);
|
||||
if (!original) {
|
||||
return @{};
|
||||
}
|
||||
|
||||
NSMutableDictionary<NSString *, FBSDKJSONField *> *const fields =
|
||||
[[NSMutableDictionary alloc] initWithCapacity:original.count];
|
||||
|
||||
for (id key in original) {
|
||||
// This is just a sanity check. Apple should only give us string keys
|
||||
// anyway.
|
||||
if (![key respondsToSelector:@selector(isKindOfClass:)] || ![key isKindOfClass:NSString.class]) {
|
||||
continue;
|
||||
}
|
||||
NSString *const stringKey = (NSString *)key;
|
||||
|
||||
FBSDKJSONField *const typedField = [[FBSDKJSONField alloc] initWithPotentialJSONField:original[key]];
|
||||
if (typedField) {
|
||||
fields[stringKey] = typedField;
|
||||
}
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
@implementation FBSDKJSONValue
|
||||
|
||||
- (instancetype)initWithPotentialJSONObject:(id)obj
|
||||
{
|
||||
// If this isn't a real JSON object, dump it.
|
||||
if (![FBSDKTypeUtility isValidJSONObject:obj]) {
|
||||
return nil;
|
||||
}
|
||||
_rawObject = obj;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)matchArray:(void (^)(NSArray<FBSDKJSONField *> *))arrayMatcher
|
||||
dictionary:(void (^)(NSDictionary<NSString *, FBSDKJSONField *> *))dictMatcher
|
||||
{
|
||||
if (arrayMatcher && [_rawObject isKindOfClass:[NSArray class]]) {
|
||||
arrayMatcher(createArray(_rawObject));
|
||||
} else if (dictMatcher && [_rawObject isKindOfClass:[NSDictionary class]]) {
|
||||
dictMatcher(createDictionary(_rawObject));
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, FBSDKJSONField *> *_Nullable)matchDictionaryOrNil
|
||||
{
|
||||
__block NSDictionary<NSString *, FBSDKJSONField *> *result = nil;
|
||||
[self matchArray:nil dictionary:^(NSDictionary<NSString *, FBSDKJSONField *> *_Nonnull value) {
|
||||
result = value;
|
||||
}];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, id> *_Nullable)unsafe_matchDictionaryOrNil
|
||||
{
|
||||
return [_rawObject isKindOfClass:NSDictionary.class] ? _rawObject : nil;
|
||||
}
|
||||
|
||||
- (NSArray<FBSDKJSONField *> *_Nullable)matchArrayOrNil
|
||||
{
|
||||
__block NSArray<FBSDKJSONField *> *result = nil;
|
||||
[self matchArray:^(NSArray<FBSDKJSONField *> *_Nonnull value) {
|
||||
result = value;
|
||||
} dictionary:nil];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSArray *_Nullable)unsafe_matchArrayOrNil
|
||||
{
|
||||
__block BOOL isArray = NO;
|
||||
[self matchArray:^(NSArray<FBSDKJSONField *> *_Nonnull _) {
|
||||
isArray = YES;
|
||||
} dictionary:nil];
|
||||
|
||||
return [_rawObject isKindOfClass:NSArray.class] ? _rawObject : nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBSDKJSONField
|
||||
|
||||
- (instancetype)initWithPotentialJSONField:(id)obj
|
||||
{
|
||||
// If this is nil, don't wrap it.
|
||||
if (obj == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
// Per Apple's Docs, these are the only types FBSDKTypeUtility can return.
|
||||
if (
|
||||
![obj isKindOfClass:NSString.class]
|
||||
&& ![obj isKindOfClass:NSNumber.class]
|
||||
&& ![obj isKindOfClass:NSNull.class]
|
||||
&& ![obj isKindOfClass:NSDictionary.class]
|
||||
&& ![obj isKindOfClass:NSArray.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (self = [super init]) {
|
||||
_rawObject = obj;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)matchArray:(void (^)(NSArray<FBSDKJSONField *> *))arrayMatcher
|
||||
dictionary:(void (^)(NSDictionary<NSString *, FBSDKJSONField *> *_Nonnull))dictionaryMatcher
|
||||
string:(void (^)(NSString *_Nonnull))stringMatcher
|
||||
number:(void (^)(NSNumber *_Nonnull))numberMatcher
|
||||
null:(void (^)(void))nullMatcher
|
||||
{
|
||||
if (nullMatcher && [_rawObject isKindOfClass:NSNull.class]) {
|
||||
nullMatcher();
|
||||
} else if (numberMatcher && [_rawObject isKindOfClass:NSNumber.class]) {
|
||||
numberMatcher(_rawObject);
|
||||
} else if (stringMatcher && [_rawObject isKindOfClass:NSString.class]) {
|
||||
stringMatcher(_rawObject);
|
||||
} else if (arrayMatcher && [_rawObject isKindOfClass:NSArray.class]) {
|
||||
arrayMatcher(createArray(_rawObject));
|
||||
} else if (dictionaryMatcher && [_rawObject isKindOfClass:NSDictionary.class]) {
|
||||
dictionaryMatcher(createDictionary(_rawObject));
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray<FBSDKJSONField *> *_Nullable)arrayOrNil
|
||||
{
|
||||
__block NSArray<FBSDKJSONField *> *result = nil;
|
||||
[self matchArray:^(NSArray<FBSDKJSONField *> *_Nonnull a) {
|
||||
result = [a copy];
|
||||
} dictionary:nil string:nil number:nil null:nil];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSDictionary<NSString *, FBSDKJSONField *> *_Nullable)dictionaryOrNil
|
||||
{
|
||||
__block NSDictionary<NSString *, FBSDKJSONField *> *result = nil;
|
||||
[self matchArray:nil dictionary:^(NSDictionary<NSString *, FBSDKJSONField *> *_Nonnull d) {
|
||||
result = [d copy];
|
||||
} string:nil number:nil null:nil];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString *_Nullable)stringOrNil
|
||||
{
|
||||
__block NSString *result = nil;
|
||||
[self matchArray:nil dictionary:nil string:^(NSString *_Nonnull s) {
|
||||
result = [s copy];
|
||||
} number:nil null:nil];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSNumber *_Nullable)numberOrNil
|
||||
{
|
||||
__block NSNumber *result = nil;
|
||||
[self matchArray:nil dictionary:nil string:nil number:^(NSNumber *_Nonnull n) {
|
||||
result = n;
|
||||
} null:nil];
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSNull *_Nullable)nullOrNil
|
||||
{
|
||||
__block NSNull *result = nil;
|
||||
[self matchArray:nil dictionary:nil string:nil number:nil null:^{
|
||||
result = [NSNull null];
|
||||
}];
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
FBSDKJSONValue *_Nullable FBSDKCreateJSONFromString(NSString *_Nullable string, NSError *__autoreleasing *errorRef)
|
||||
{
|
||||
return
|
||||
[[FBSDKJSONValue alloc] initWithPotentialJSONObject:[FBSDKBasicUtility objectForJSONString:string error:errorRef]];
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
// 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 "FBSDKLibAnalyzer.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "FBSDKTypeUtility.h"
|
||||
|
||||
@implementation FBSDKLibAnalyzer
|
||||
|
||||
static NSMutableDictionary<NSString *, NSString *> *_methodMapping;
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
_methodMapping = [NSMutableDictionary dictionary];
|
||||
}
|
||||
|
||||
+ (NSDictionary<NSString *, NSString *> *)getMethodsTable:(NSArray<NSString *> *)prefixes
|
||||
frameworks:(NSArray<NSString *> *)frameworks
|
||||
{
|
||||
NSArray<NSString *> *allClasses = [self _getClassNames:prefixes frameworks:frameworks];
|
||||
for (NSString *className in allClasses) {
|
||||
Class class = NSClassFromString(className);
|
||||
if (class) {
|
||||
[self _addClass:class isClassMethod:NO];
|
||||
[self _addClass:object_getClass(class) isClassMethod:YES];
|
||||
}
|
||||
}
|
||||
@synchronized(_methodMapping) {
|
||||
return [_methodMapping copy];
|
||||
}
|
||||
}
|
||||
|
||||
+ (nullable NSArray<NSString *> *)symbolicateCallstack:(NSArray<NSString *> *)callstack
|
||||
methodMapping:(NSDictionary<NSString *, id> *)methodMapping
|
||||
{
|
||||
if (!callstack || !methodMapping) {
|
||||
return nil;
|
||||
}
|
||||
NSArray<NSString *> *sortedAllAddress = [methodMapping.allKeys sortedArrayUsingComparator:^NSComparisonResult (id _Nonnull obj1, id _Nonnull obj2) {
|
||||
return [obj1 compare:obj2];
|
||||
}];
|
||||
|
||||
BOOL containsFBSDKFunction = NO;
|
||||
NSInteger nonSDKMethodCount = 0;
|
||||
NSMutableArray<NSString *> *symbolicatedCallstack = [NSMutableArray array];
|
||||
|
||||
for (NSUInteger i = 0; i < callstack.count; i++) {
|
||||
NSString *rawAddress = [self _getAddress:[FBSDKTypeUtility array:callstack objectAtIndex:i]];
|
||||
if (rawAddress.length < 10) {
|
||||
continue;
|
||||
}
|
||||
NSString *addressString = [NSString stringWithFormat:@"0x%@", [rawAddress substringWithRange:NSMakeRange(rawAddress.length - 10, 10)]];
|
||||
NSString *methodAddress = [self _searchMethod:addressString sortedAllAddress:sortedAllAddress];
|
||||
|
||||
if (methodAddress) {
|
||||
containsFBSDKFunction = YES;
|
||||
nonSDKMethodCount == 0 ?: [FBSDKTypeUtility array:symbolicatedCallstack addObject:[NSString stringWithFormat:@"(%ld DEV METHODS)", (long)nonSDKMethodCount]];
|
||||
nonSDKMethodCount = 0;
|
||||
NSString *methodName = [FBSDKTypeUtility dictionary:methodMapping objectForKey:methodAddress ofType:NSObject.class];
|
||||
|
||||
// filter out cxx_destruct
|
||||
if ([methodName containsString:@".cxx_destruct"]) {
|
||||
return nil;
|
||||
}
|
||||
[FBSDKTypeUtility array:symbolicatedCallstack addObject:[NSString stringWithFormat:@"%@%@", methodName, [self _getOffset:addressString secondString:methodAddress]]];
|
||||
} else {
|
||||
nonSDKMethodCount++;
|
||||
}
|
||||
}
|
||||
nonSDKMethodCount == 0 ?: [FBSDKTypeUtility array:symbolicatedCallstack addObject:[NSString stringWithFormat:@"(%ld DEV METHODS)", (long)nonSDKMethodCount]];
|
||||
|
||||
return containsFBSDKFunction ? symbolicatedCallstack : nil;
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods
|
||||
|
||||
+ (NSArray<NSString *> *)_getClassNames:(NSArray<NSString *> *)prefixes
|
||||
frameworks:(NSArray<NSString *> *)frameworks
|
||||
{
|
||||
NSMutableArray<NSString *> *classNames = [NSMutableArray new];
|
||||
// from main bundle
|
||||
[classNames addObjectsFromArray:[self _getClassesFrom:[[NSBundle mainBundle] executablePath]
|
||||
prefixes:prefixes]];
|
||||
// from dynamic libraries
|
||||
if (frameworks.count > 0) {
|
||||
unsigned int count = 0;
|
||||
const char **images = objc_copyImageNames(&count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
NSString *image = [NSString stringWithUTF8String:images[i]];
|
||||
for (NSString *framework in frameworks) {
|
||||
if ([image containsString:framework]) {
|
||||
[classNames addObjectsFromArray:[self _getClassesFrom:image
|
||||
prefixes:nil]];
|
||||
}
|
||||
}
|
||||
}
|
||||
free(images);
|
||||
}
|
||||
|
||||
return [classNames copy];
|
||||
}
|
||||
|
||||
+ (NSArray<NSString *> *)_getClassesFrom:(NSString *)image
|
||||
prefixes:(NSArray<NSString *> *)prefixes
|
||||
{
|
||||
NSMutableArray<NSString *> *classNames = [NSMutableArray array];
|
||||
unsigned int count = 0;
|
||||
const char **classes = objc_copyClassNamesForImage([image UTF8String], &count);
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
NSString *className = [NSString stringWithUTF8String:classes[i]];
|
||||
if (prefixes.count > 0) {
|
||||
for (NSString *prefix in prefixes) {
|
||||
if ([className hasPrefix:prefix]) {
|
||||
[FBSDKTypeUtility array:classNames addObject:className];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
[FBSDKTypeUtility array:classNames addObject:className];
|
||||
}
|
||||
}
|
||||
free(classes);
|
||||
return [classNames copy];
|
||||
}
|
||||
|
||||
+ (void)_addClass:(Class)class
|
||||
isClassMethod:(BOOL)isClassMethod
|
||||
{
|
||||
unsigned int methodsCount = 0;
|
||||
Method *methods = class_copyMethodList(class, &methodsCount);
|
||||
|
||||
NSString *methodType = isClassMethod ? @"+" : @"-";
|
||||
|
||||
for (unsigned int i = 0; i < methodsCount; i++) {
|
||||
Method method = methods[i];
|
||||
|
||||
if (method) {
|
||||
SEL selector = method_getName(method);
|
||||
|
||||
IMP methodImplementation = class_getMethodImplementation(class, selector);
|
||||
NSString *methodAddress = [NSString stringWithFormat:@"0x%010lx", (unsigned long)methodImplementation];
|
||||
NSString *methodName = [NSString stringWithFormat:@"%@[%@ %@]",
|
||||
methodType,
|
||||
NSStringFromClass(class),
|
||||
NSStringFromSelector(selector)];
|
||||
|
||||
if (methodAddress && methodName) {
|
||||
@synchronized(_methodMapping) {
|
||||
[FBSDKTypeUtility dictionary:_methodMapping setObject:methodName forKey:methodAddress];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free(methods);
|
||||
}
|
||||
|
||||
+ (nullable NSString *)_getAddress:(nullable NSString *)callstackEntry
|
||||
{
|
||||
if ([callstackEntry isKindOfClass:[NSString class]]) {
|
||||
NSArray<NSString *> *components = [callstackEntry componentsSeparatedByString:@" "];
|
||||
for (NSString *component in components) {
|
||||
if ([component containsString:@"0x"]) {
|
||||
return component;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSString *)_getOffset:(NSString *)firstString
|
||||
secondString:(NSString *)secondString
|
||||
{
|
||||
unsigned long long first = 0, second = 0;
|
||||
NSScanner *scanner = [NSScanner scannerWithString:firstString];
|
||||
[scanner scanHexLongLong:&first];
|
||||
|
||||
scanner = [NSScanner scannerWithString:secondString];
|
||||
[scanner scanHexLongLong:&second];
|
||||
|
||||
unsigned long long difference = first - second;
|
||||
return [NSString stringWithFormat:@"+%llu", difference];
|
||||
}
|
||||
|
||||
+ (nullable NSString *)_searchMethod:(NSString *)address
|
||||
sortedAllAddress:(NSArray<NSString *> *)sortedAllAddress
|
||||
{
|
||||
if (0 == sortedAllAddress.count) {
|
||||
return nil;
|
||||
}
|
||||
NSString *lowestAddress = [FBSDKTypeUtility array:sortedAllAddress objectAtIndex:0];
|
||||
NSString *highestAddress = [FBSDKTypeUtility array:sortedAllAddress objectAtIndex:sortedAllAddress.count - 1];
|
||||
|
||||
if ([address compare:lowestAddress] == NSOrderedAscending || [address compare:highestAddress] == NSOrderedDescending) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ([address compare:lowestAddress] == NSOrderedSame) {
|
||||
return lowestAddress;
|
||||
}
|
||||
|
||||
if ([address compare:highestAddress] == NSOrderedSame) {
|
||||
return highestAddress;
|
||||
}
|
||||
|
||||
NSUInteger index = [sortedAllAddress indexOfObject:address
|
||||
inSortedRange:NSMakeRange(0, sortedAllAddress.count - 1)
|
||||
options:NSBinarySearchingInsertionIndex
|
||||
usingComparator:^NSComparisonResult (id _Nonnull obj1, id _Nonnull obj2) {
|
||||
return [obj1 compare:obj2];
|
||||
}];
|
||||
return [FBSDKTypeUtility array:sortedAllAddress objectAtIndex:index - 1];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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 "FBSDKSafeCast.h"
|
||||
|
||||
id _FBSDKCastToClassOrNilUnsafeInternal(id object, Class klass)
|
||||
{
|
||||
return [(NSObject *)object isKindOfClass:klass] ? object : nil;
|
||||
}
|
||||
|
||||
id _FBSDKCastToProtocolOrNilUnsafeInternal(id object, Protocol *protocol)
|
||||
{
|
||||
return [(NSObject *)object conformsToProtocol:protocol] ? object : nil;
|
||||
}
|
||||
@@ -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 "FBSDKTypeUtility.h"
|
||||
|
||||
@implementation FBSDKTypeUtility
|
||||
|
||||
#pragma mark - Class Methods
|
||||
|
||||
+ (NSArray *)arrayValue:(id)object
|
||||
{
|
||||
return (NSArray *)[self _objectValue:object ofClass:[NSArray class]];
|
||||
}
|
||||
|
||||
+ (nullable id)array:(NSArray *)array objectAtIndex:(NSUInteger)index
|
||||
{
|
||||
if ([self arrayValue:array] && index < array.count) {
|
||||
return [array objectAtIndex:index];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)array:(NSMutableArray *)array addObject:(id)object
|
||||
{
|
||||
if (object && [array isKindOfClass:NSMutableArray.class]) {
|
||||
[array addObject:object];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)array:(NSMutableArray *)array addObject:(nullable id)object atIndex:(NSUInteger)index
|
||||
{
|
||||
if (object && [array isKindOfClass:NSMutableArray.class]) {
|
||||
if (index < array.count) {
|
||||
[array insertObject:object atIndex:index];
|
||||
} else if (index == array.count) {
|
||||
[array addObject:object];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)boolValue:(id)object
|
||||
{
|
||||
if ([object isKindOfClass:[NSNumber class]]) {
|
||||
// @0 or @NO returns NO, otherwise YES
|
||||
return ((NSNumber *)object).boolValue;
|
||||
} else if ([object isKindOfClass:[NSString class]]) {
|
||||
// Returns YES on encountering one of "Y", "y", "T", "t", or a digit 1-9, otherwise NO
|
||||
return ((NSString *)object).boolValue;
|
||||
} else {
|
||||
return ([self objectValue:object] != nil);
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSDictionary *)dictionaryValue:(id)object
|
||||
{
|
||||
return (NSDictionary *)[self _objectValue:object ofClass:[NSDictionary class]];
|
||||
}
|
||||
|
||||
+ (id)dictionary:(NSDictionary *)dictionary objectForKey:(NSString *)key ofType:(Class)type
|
||||
{
|
||||
id potentialValue = [[self dictionaryValue:dictionary] objectForKey:key];
|
||||
|
||||
if ([potentialValue isKindOfClass:type]) {
|
||||
return potentialValue;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)dictionary:(NSMutableDictionary *)dictionary setObject:(id)object forKey:(id<NSCopying>)key
|
||||
{
|
||||
if (object && key) {
|
||||
dictionary[key] = object;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)dictionary:(NSDictionary *)dictionary enumerateKeysAndObjectsUsingBlock:(void(NS_NOESCAPE ^)(id key, id obj, BOOL *stop))block
|
||||
{
|
||||
NSDictionary *validDictionary = [self dictionaryValue:dictionary];
|
||||
if (validDictionary) {
|
||||
[validDictionary enumerateKeysAndObjectsUsingBlock:block];
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSNumber *)numberValue:(id)object
|
||||
{
|
||||
return [self _objectValue:object ofClass:NSNumber.class];
|
||||
}
|
||||
|
||||
+ (NSInteger)integerValue:(id)object
|
||||
{
|
||||
if ([object isKindOfClass:[NSNumber class]]) {
|
||||
return ((NSNumber *)object).integerValue;
|
||||
} else if ([object isKindOfClass:[NSString class]]) {
|
||||
return ((NSString *)object).integerValue;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)stringValueOrNil:(id)object
|
||||
{
|
||||
return [self _objectValue:object ofClass:NSString.class];
|
||||
}
|
||||
|
||||
+ (id)objectValue:(id)object
|
||||
{
|
||||
return ([object isKindOfClass:[NSNull class]] ? nil : object);
|
||||
}
|
||||
|
||||
+ (NSString *)coercedToStringValue:(id)object
|
||||
{
|
||||
if ([object isKindOfClass:[NSString class]]) {
|
||||
return (NSString *)object;
|
||||
} else if ([object isKindOfClass:[NSNumber class]]) {
|
||||
return ((NSNumber *)object).stringValue;
|
||||
} else if ([object isKindOfClass:[NSURL class]]) {
|
||||
return ((NSURL *)object).absoluteString;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSTimeInterval)timeIntervalValue:(id)object
|
||||
{
|
||||
if ([object isKindOfClass:[NSNumber class]]) {
|
||||
return ((NSNumber *)object).doubleValue;
|
||||
} else if ([object isKindOfClass:[NSString class]]) {
|
||||
return ((NSString *)object).doubleValue;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSUInteger)unsignedIntegerValue:(id)object
|
||||
{
|
||||
if ([object isKindOfClass:[NSNumber class]]) {
|
||||
return ((NSNumber *)object).unsignedIntegerValue;
|
||||
} else {
|
||||
// there is no direct support for strings containing unsigned values > NSIntegerMax - not worth writing ourselves
|
||||
// right now, so just cap unsigned values at NSIntegerMax until we have a need for larger
|
||||
NSInteger integerValue = [self integerValue:object];
|
||||
if (integerValue < 0) {
|
||||
integerValue = 0;
|
||||
}
|
||||
return (NSUInteger)integerValue;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSURL *)URLValue:(id)object
|
||||
{
|
||||
if ([object isKindOfClass:[NSURL class]]) {
|
||||
return (NSURL *)object;
|
||||
} else if ([object isKindOfClass:[NSString class]]) {
|
||||
return [NSURL URLWithString:(NSString *)object];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+ (BOOL)isValidJSONObject:(id)obj
|
||||
{
|
||||
return [NSJSONSerialization isValidJSONObject:obj];
|
||||
}
|
||||
|
||||
+ (NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError *__autoreleasing _Nullable *)error
|
||||
{
|
||||
NSData *data;
|
||||
|
||||
@try {
|
||||
data = [NSJSONSerialization dataWithJSONObject:obj options:opt error:error];
|
||||
} @catch (NSException *exception) {
|
||||
NSLog(@"FBSDKJSONSerialization - dataWithJSONObject:options:error failed: %@", exception.reason);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError *__autoreleasing _Nullable *)error
|
||||
{
|
||||
if (![data isKindOfClass:NSData.class]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
id object;
|
||||
@try {
|
||||
object = [NSJSONSerialization JSONObjectWithData:data options:opt error:error];
|
||||
} @catch (NSException *exception) {
|
||||
NSLog(@"FBSDKJSONSerialization - JSONObjectWithData:options:error failed: %@", exception.reason);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
+ (id)_objectValue:(id)object ofClass:(Class)expectedClass
|
||||
{
|
||||
return ([object isKindOfClass:expectedClass] ? object : nil);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,78 @@
|
||||
// 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 "FBSDKURLSession.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FBSDKBasicUtility.h"
|
||||
#import "FBSDKURLSessionTask.h"
|
||||
|
||||
// At some point this default conformance declaration needs to be moved out of
|
||||
// this class and treated like the dependency it is.
|
||||
@interface NSURLSession (SessionProviding) <FBSDKSessionProviding>
|
||||
@end
|
||||
|
||||
@implementation FBSDKURLSession
|
||||
|
||||
- (instancetype)initWithDelegate:(id<NSURLSessionDataDelegate>)delegate
|
||||
delegateQueue:(NSOperationQueue *)queue
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.delegate = delegate;
|
||||
self.delegateQueue = queue;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)executeURLRequest:(NSURLRequest *)request
|
||||
completionHandler:(FBSDKURLSessionTaskBlock)handler
|
||||
{
|
||||
if (!self.valid) {
|
||||
[self updateSessionWithBlock:^{
|
||||
FBSDKURLSessionTask *task = [[FBSDKURLSessionTask alloc] initWithRequest:request fromSession:self.session completionHandler:handler];
|
||||
[task start];
|
||||
}];
|
||||
} else {
|
||||
FBSDKURLSessionTask *task = [[FBSDKURLSessionTask alloc] initWithRequest:request fromSession:self.session completionHandler:handler];
|
||||
[task start];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateSessionWithBlock:(dispatch_block_t)block
|
||||
{
|
||||
if (!self.valid) {
|
||||
self.session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
|
||||
delegate:_delegate
|
||||
delegateQueue:_delegateQueue];
|
||||
}
|
||||
block();
|
||||
}
|
||||
|
||||
- (void)invalidateAndCancel
|
||||
{
|
||||
[self.session invalidateAndCancel];
|
||||
self.session = nil;
|
||||
}
|
||||
|
||||
- (BOOL)valid
|
||||
{
|
||||
return self.session != nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -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 "FBSDKURLSessionTask.h"
|
||||
|
||||
#import "FBSDKSessionProviding.h"
|
||||
|
||||
@implementation FBSDKURLSessionTask
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_requestStartDate = [NSDate date];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithRequest:(NSURLRequest *)request
|
||||
fromSession:(id<FBSDKSessionProviding>)session
|
||||
completionHandler:(FBSDKURLSessionTaskBlock)handler
|
||||
{
|
||||
if ((self = [self init])) {
|
||||
self.requestStartTime = (uint64_t)([self.requestStartDate timeIntervalSince1970] * 1000);
|
||||
self.task = [session dataTaskWithRequest:request completionHandler:handler];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSURLSessionTaskState)state
|
||||
{
|
||||
return self.task.state;
|
||||
}
|
||||
|
||||
#pragma mark - Task State
|
||||
|
||||
- (void)start
|
||||
{
|
||||
[self.task resume];
|
||||
}
|
||||
|
||||
- (void)cancel
|
||||
{
|
||||
[self.task cancel];
|
||||
self.handler = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,281 @@
|
||||
// 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 "FBSDKBasicUtility.h"
|
||||
#import "FBSDKTypeUtility.h"
|
||||
|
||||
static NSString *const FBSDKUserDataKey = @"com.facebook.appevents.UserDataStore.userData";
|
||||
static NSString *const FBSDKInternalUserDataKey = @"com.facebook.appevents.UserDataStore.internalUserData";
|
||||
|
||||
static NSMutableDictionary<NSString *, NSString *> *hashedUserData;
|
||||
static NSMutableDictionary<NSString *, NSString *> *internalHashedUserData;
|
||||
static NSMutableSet<NSString *> *enabledRules;
|
||||
|
||||
static dispatch_queue_t serialQueue;
|
||||
|
||||
//
|
||||
// Public event user data types
|
||||
//
|
||||
|
||||
FBSDKAppEventUserDataType FBSDKAppEventEmail = @"em";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventFirstName = @"fn";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventLastName = @"ln";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventPhone = @"ph";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventDateOfBirth = @"dob";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventGender = @"ge";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventCity = @"ct";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventState = @"st";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventZip = @"zp";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventCountry = @"country";
|
||||
FBSDKAppEventUserDataType FBSDKAppEventExternalId = @"external_id";
|
||||
|
||||
@implementation FBSDKUserDataStore
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
serialQueue = dispatch_queue_create("com.facebook.appevents.UserDataStore", DISPATCH_QUEUE_SERIAL);
|
||||
hashedUserData = [FBSDKUserDataStore initializeUserData:FBSDKUserDataKey];
|
||||
internalHashedUserData = [FBSDKUserDataStore initializeUserData:FBSDKInternalUserDataKey];
|
||||
enabledRules = [NSMutableSet new];
|
||||
}
|
||||
|
||||
+ (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
|
||||
externalId:(nullable NSString *)externalId
|
||||
{
|
||||
NSMutableDictionary *ud = [NSMutableDictionary new];
|
||||
if (email) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:email type:FBSDKAppEventEmail] forKey:FBSDKAppEventEmail];
|
||||
}
|
||||
if (firstName) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:firstName type:FBSDKAppEventFirstName] forKey:FBSDKAppEventFirstName];
|
||||
}
|
||||
if (lastName) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:lastName type:FBSDKAppEventLastName] forKey:FBSDKAppEventLastName];
|
||||
}
|
||||
if (phone) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:phone type:FBSDKAppEventPhone] forKey:FBSDKAppEventPhone];
|
||||
}
|
||||
if (dateOfBirth) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:dateOfBirth type:FBSDKAppEventDateOfBirth] forKey:FBSDKAppEventDateOfBirth];
|
||||
}
|
||||
if (gender) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:gender type:FBSDKAppEventGender] forKey:FBSDKAppEventGender];
|
||||
}
|
||||
if (city) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:city type:FBSDKAppEventCity] forKey:FBSDKAppEventCity];
|
||||
}
|
||||
if (state) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:state type:FBSDKAppEventState] forKey:FBSDKAppEventState];
|
||||
}
|
||||
if (zip) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:zip type:FBSDKAppEventZip] forKey:FBSDKAppEventZip];
|
||||
}
|
||||
if (country) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:country type:FBSDKAppEventCountry] forKey:FBSDKAppEventCountry];
|
||||
}
|
||||
if (externalId) {
|
||||
[FBSDKTypeUtility dictionary:ud setObject:[FBSDKUserDataStore encryptData:externalId type:FBSDKAppEventExternalId] forKey:FBSDKAppEventExternalId];
|
||||
}
|
||||
|
||||
dispatch_async(serialQueue, ^{
|
||||
hashedUserData = [ud mutableCopy];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[FBSDKUserDataStore stringByHashedData:hashedUserData]
|
||||
forKey:FBSDKUserDataKey];
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)setUserData:(nullable NSString *)data
|
||||
forType:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
[FBSDKUserDataStore setHashData:[FBSDKUserDataStore encryptData:data type:type]
|
||||
forType:type];
|
||||
}
|
||||
|
||||
+ (void)setHashData:(nullable NSString *)hashData
|
||||
forType:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
dispatch_async(serialQueue, ^{
|
||||
if (!hashData) {
|
||||
[hashedUserData removeObjectForKey:type];
|
||||
} else {
|
||||
[FBSDKTypeUtility dictionary:hashedUserData setObject:hashData forKey:type];
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[FBSDKUserDataStore stringByHashedData:hashedUserData]
|
||||
forKey:FBSDKUserDataKey];
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)setInternalHashData:(nullable NSString *)hashData
|
||||
forType:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
dispatch_async(serialQueue, ^{
|
||||
if (!hashData) {
|
||||
[internalHashedUserData removeObjectForKey:type];
|
||||
} else {
|
||||
internalHashedUserData[type] = hashData;
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[FBSDKUserDataStore stringByHashedData:internalHashedUserData]
|
||||
forKey:FBSDKInternalUserDataKey];
|
||||
});
|
||||
}
|
||||
|
||||
+ (void)setEnabledRules:(NSArray<NSString *> *)rules
|
||||
{
|
||||
if (rules.count > 0) {
|
||||
[enabledRules addObjectsFromArray:rules];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)clearUserDataForType:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
[FBSDKUserDataStore setUserData:nil forType:type];
|
||||
}
|
||||
|
||||
+ (NSString *)getUserData
|
||||
{
|
||||
return [FBSDKUserDataStore getHashedData];
|
||||
}
|
||||
|
||||
+ (NSString *)getHashedData
|
||||
{
|
||||
__block NSString *hashedUserDataString;
|
||||
dispatch_sync(serialQueue, ^{
|
||||
NSMutableDictionary<NSString *, NSString *> *hashedUD = [NSMutableDictionary new];
|
||||
[hashedUD addEntriesFromDictionary:hashedUserData];
|
||||
for (NSString *key in enabledRules) {
|
||||
if (internalHashedUserData[key]) {
|
||||
hashedUD[key] = internalHashedUserData[key];
|
||||
}
|
||||
}
|
||||
hashedUserDataString = [FBSDKUserDataStore stringByHashedData:hashedUD];
|
||||
});
|
||||
return hashedUserDataString;
|
||||
}
|
||||
|
||||
+ (void)clearUserData
|
||||
{
|
||||
[FBSDKUserDataStore setUserEmail:nil
|
||||
firstName:nil
|
||||
lastName:nil
|
||||
phone:nil
|
||||
dateOfBirth:nil
|
||||
gender:nil
|
||||
city:nil
|
||||
state:nil
|
||||
zip:nil
|
||||
country:nil
|
||||
externalId:nil];
|
||||
}
|
||||
|
||||
+ (NSString *)getInternalHashedDataForType:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
__block NSString *hashedData;
|
||||
dispatch_sync(serialQueue, ^{
|
||||
hashedData = [FBSDKTypeUtility dictionary:internalHashedUserData objectForKey:type ofType:NSObject.class];
|
||||
});
|
||||
return hashedData;
|
||||
}
|
||||
|
||||
#pragma mark - Helper Methods
|
||||
|
||||
+ (NSMutableDictionary<NSString *, NSString *> *)initializeUserData:(NSString *)userDataKey
|
||||
{
|
||||
NSString *userData = [[NSUserDefaults standardUserDefaults] stringForKey:userDataKey];
|
||||
NSMutableDictionary<NSString *, NSString *> *hashedUD = nil;
|
||||
if (userData) {
|
||||
hashedUD = (NSMutableDictionary<NSString *, NSString *> *)[FBSDKTypeUtility JSONObjectWithData:[userData dataUsingEncoding:NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: nil];
|
||||
}
|
||||
if (!hashedUD) {
|
||||
hashedUD = [NSMutableDictionary new];
|
||||
}
|
||||
return hashedUD;
|
||||
}
|
||||
|
||||
+ (NSString *)stringByHashedData:(id)hashedData
|
||||
{
|
||||
NSError *error;
|
||||
NSData *jsonData = [FBSDKTypeUtility dataWithJSONObject:hashedData
|
||||
options:0
|
||||
error:&error];
|
||||
if (jsonData) {
|
||||
return [[NSString alloc] initWithData:jsonData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
} else {
|
||||
return @"";
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *)encryptData:(NSString *)data
|
||||
type:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
if (data.length == 0 || [FBSDKUserDataStore maybeSHA256Hashed:data]) {
|
||||
return data;
|
||||
}
|
||||
return [FBSDKBasicUtility SHA256Hash:[FBSDKUserDataStore normalizeData:data type:type]];
|
||||
}
|
||||
|
||||
+ (NSString *)normalizeData:(NSString *)data
|
||||
type:(FBSDKAppEventUserDataType)type
|
||||
{
|
||||
NSString *normalizedData = @"";
|
||||
NSSet<FBSDKAppEventUserDataType> *set = [NSSet setWithArray:
|
||||
@[FBSDKAppEventEmail, FBSDKAppEventFirstName, FBSDKAppEventLastName, FBSDKAppEventCity, FBSDKAppEventState, FBSDKAppEventCountry]];
|
||||
if ([set containsObject:type]) {
|
||||
normalizedData = [data stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
normalizedData = normalizedData.lowercaseString;
|
||||
} else if ([type isEqualToString:FBSDKAppEventPhone]) {
|
||||
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:FBSDKAppEventGender]) {
|
||||
NSString *temp = [data stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
temp = temp.lowercaseString;
|
||||
normalizedData = temp.length > 0 ? [temp substringToIndex:1] : @"";
|
||||
} else if ([type isEqualToString:FBSDKAppEventExternalId]) {
|
||||
normalizedData = data;
|
||||
}
|
||||
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
|
||||
@@ -0,0 +1,59 @@
|
||||
// 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_SWIFT_NAME(Base64)
|
||||
@interface FBSDKBase64 : NSObject
|
||||
|
||||
/**
|
||||
Decodes a base-64 encoded string.
|
||||
@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.
|
||||
@param string The base-64 encoded string.
|
||||
@return NSString with the decoded UTF-8 value.
|
||||
*/
|
||||
+ (NSString *)decodeAsString:(NSString *)string;
|
||||
|
||||
/**
|
||||
Encodes data into a 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.
|
||||
@param string The string to be encoded.
|
||||
@return The base-64 encoded string.
|
||||
*/
|
||||
+ (NSString *)encodeString:(NSString *)string;
|
||||
|
||||
/**
|
||||
Encodes URL string into a base-64 representation.
|
||||
@param base64Url The URL string to be encoded.
|
||||
@return The base-64 encoded string.
|
||||
*/
|
||||
+ (NSString *)base64FromBase64Url:(NSString *)base64Url;
|
||||
|
||||
@end
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
// 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
|
||||
|
||||
/**
|
||||
Dispatches the specified block on the main thread.
|
||||
@param block the block to dispatch
|
||||
*/
|
||||
extern void fb_dispatch_on_main_thread(dispatch_block_t block);
|
||||
|
||||
/**
|
||||
Dispatches the specified block on the default thread.
|
||||
@param block the block to dispatch
|
||||
*/
|
||||
extern void fb_dispatch_on_default_thread(dispatch_block_t block);
|
||||
|
||||
/**
|
||||
Describes the callback for appLinkFromURLInBackground.
|
||||
@param object the FBSDKAppLink representing the deferred App Link
|
||||
@param stop the error during the request, if any
|
||||
|
||||
*/
|
||||
typedef id _Nullable (^FBSDKInvalidObjectHandler)(id object, BOOL *stop)
|
||||
NS_SWIFT_NAME(InvalidObjectHandler);
|
||||
|
||||
NS_SWIFT_NAME(BasicUtility)
|
||||
@interface FBSDKBasicUtility : NSObject
|
||||
|
||||
/**
|
||||
Converts an object into a JSON string.
|
||||
@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.
|
||||
*/
|
||||
+ (nullable NSString *)JSONStringForObject:(id)object
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
invalidObjectHandler:(nullable FBSDKInvalidObjectHandler)invalidObjectHandler;
|
||||
|
||||
/**
|
||||
Sets an object for a key in a dictionary if it is not nil.
|
||||
@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<id, id> *)dictionary
|
||||
setJSONStringForObject:(id)object
|
||||
forKey:(id<NSCopying>)key
|
||||
error:(NSError *__autoreleasing *)errorRef;
|
||||
|
||||
/**
|
||||
Converts a JSON string into an object
|
||||
@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.
|
||||
*/
|
||||
+ (nullable id)objectForJSONString:(NSString *)string error:(NSError *__autoreleasing *)errorRef;
|
||||
|
||||
/**
|
||||
Constructs a query string from a dictionary.
|
||||
@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.
|
||||
*/
|
||||
+ (nullable NSString *)queryStringWithDictionary:(NSDictionary<NSString *, id> *)dictionary
|
||||
error:(NSError *__autoreleasing *)errorRef
|
||||
invalidObjectHandler:(nullable FBSDKInvalidObjectHandler)invalidObjectHandler;
|
||||
|
||||
/**
|
||||
Converts simple value types to the string equivalent for serializing to a request query or body.
|
||||
@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;
|
||||
|
||||
/**
|
||||
Encodes a value for an URL.
|
||||
@param value The value to encode.
|
||||
@return The encoded value.
|
||||
*/
|
||||
+ (NSString *)URLEncode:(NSString *)value;
|
||||
|
||||
/**
|
||||
Parses a query string into a dictionary.
|
||||
@param queryString The query string value.
|
||||
@return A dictionary with the key/value pairs.
|
||||
*/
|
||||
+ (NSDictionary<NSString *, NSString *> *)dictionaryWithQueryString:(NSString *)queryString;
|
||||
|
||||
/**
|
||||
Decodes a value from an URL.
|
||||
@param value The value to decode.
|
||||
@return The decoded value.
|
||||
*/
|
||||
+ (NSString *)URLDecode:(NSString *)value;
|
||||
|
||||
/**
|
||||
Gzip data with default compression level if possible.
|
||||
@param data The raw data.
|
||||
@return nil if unable to gzip the data, otherwise gzipped data.
|
||||
*/
|
||||
+ (nullable NSData *)gzip:(NSData *)data;
|
||||
|
||||
+ (NSString *)anonymousID;
|
||||
+ (NSString *)persistenceFilePath:(NSString *)filename;
|
||||
+ (nullable NSString *)SHA256Hash:(nullable NSObject *)input;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// 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 "FBSDKBase64.h"
|
||||
#import "FBSDKBasicUtility.h"
|
||||
#import "FBSDKCrashHandler.h"
|
||||
#import "FBSDKCrashHandler+CrashHandlerProtocol.h"
|
||||
#import "FBSDKCrashHandlerProtocol.h"
|
||||
#import "FBSDKCrashObserving.h"
|
||||
#import "FBSDKFileDataExtracting.h"
|
||||
#import "FBSDKFileManaging.h"
|
||||
#import "FBSDKInfoDictionaryProviding.h"
|
||||
#import "FBSDKJSONValue.h"
|
||||
#import "FBSDKLibAnalyzer.h"
|
||||
#import "FBSDKSafeCast.h"
|
||||
#import "FBSDKSessionProviding.h"
|
||||
#import "FBSDKTypeUtility.h"
|
||||
#import "FBSDKURLSession.h"
|
||||
#import "FBSDKURLSessionTask.h"
|
||||
#import "FBSDKUserDataStore.h"
|
||||
#import "NSBundle+InfoDictionaryProviding.h"
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// 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 "FBSDKCrashHandlerProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Default conformance to the FBSDKCrashHandler protocol
|
||||
@interface FBSDKCrashHandler (CrashHandlerProtocol) <FBSDKCrashHandler>
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// 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 "FBSDKCrashObserving.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NS_SWIFT_NAME(CrashHandler)
|
||||
@interface FBSDKCrashHandler : NSObject
|
||||
|
||||
@property (class, nonatomic, readonly) FBSDKCrashHandler *shared;
|
||||
|
||||
- (void)disable;
|
||||
+ (void)disable;
|
||||
+ (void)addObserver:(id<FBSDKCrashObserving>)observer;
|
||||
+ (void)removeObserver:(id<FBSDKCrashObserving>)observer;
|
||||
+ (void)clearCrashReportFiles;
|
||||
+ (NSString *)getFBSDKVersion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+26
@@ -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.
|
||||
|
||||
@protocol FBSDKCrashObserving;
|
||||
|
||||
NS_SWIFT_NAME(CrashHandlerProtocol)
|
||||
@protocol FBSDKCrashHandler
|
||||
|
||||
- (void)addObserver:(id<FBSDKCrashObserving>)observer;
|
||||
|
||||
@end
|
||||
+33
@@ -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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NS_SWIFT_NAME(CrashObserving)
|
||||
@protocol FBSDKCrashObserving
|
||||
|
||||
@property (nonatomic, copy) NSArray<NSString *> *prefixes;
|
||||
@property (nullable, nonatomic, copy) NSArray<NSString *> *frameworks;
|
||||
|
||||
- (void)didReceiveCrashLogs:(NSArray<NSDictionary<NSString *, id> *> *)crashLogs;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// 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
|
||||
|
||||
/// An internal protocol used to describe a type that can extract data from a file
|
||||
NS_SWIFT_NAME(FileDataExtracting)
|
||||
@protocol FBSDKFileDataExtracting
|
||||
|
||||
+ (nullable NSData *)dataWithContentsOfFile:(NSString *)path
|
||||
options:(NSDataReadingOptions)readOptionsMask
|
||||
error:(NSError * _Nullable *)errorPtr;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSData (FileDataExtracting) <FBSDKFileDataExtracting>
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// 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
|
||||
|
||||
/// An internal protocol used to describe a file manager
|
||||
NS_SWIFT_NAME(FileManaging)
|
||||
@protocol FBSDKFileManaging
|
||||
|
||||
- (nullable NSURL *)URLForDirectory:(NSSearchPathDirectory)directory
|
||||
inDomain:(NSSearchPathDomainMask)domain
|
||||
appropriateForURL:(NSURL *)url
|
||||
create:(BOOL)shouldCreate
|
||||
error:(NSError * _Nullable *)error;
|
||||
|
||||
- (BOOL)createDirectoryAtPath:(NSString *)path
|
||||
withIntermediateDirectories:(BOOL)createIntermediates
|
||||
attributes:(NSDictionary<NSFileAttributeKey, id> * _Nullable)attributes
|
||||
error:(NSError * _Nullable *)error;
|
||||
|
||||
- (BOOL)fileExistsAtPath:(NSString *)path;
|
||||
|
||||
- (BOOL)removeItemAtPath:(NSString *)path
|
||||
error:(NSError * _Nullable *)error;
|
||||
|
||||
- (NSArray<NSString *> *)contentsOfDirectoryAtPath:(NSString *)path
|
||||
error:(NSError * _Nullable *)error;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSFileManager (FBSDKFileManaging) <FBSDKFileManaging>
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+32
@@ -0,0 +1,32 @@
|
||||
// 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
|
||||
|
||||
NS_SWIFT_NAME(InfoDictionaryProviding)
|
||||
@protocol FBSDKInfoDictionaryProviding
|
||||
|
||||
@property(nullable, readonly, copy) NSDictionary<NSString *,id> *infoDictionary;
|
||||
|
||||
- (nullable id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
// 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 purpose of this class is to serve as thin, type-safe wrapper
|
||||
around FBSDKTypeUtility
|
||||
*/
|
||||
@interface FBSDKJSONField : NSObject
|
||||
|
||||
/**
|
||||
This can only be created by FBSDKJSONValue.
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
A safe method to unpack the values in the top-level JSON object.
|
||||
https://developer.apple.com/documentation/foundation/nsjsonserialization
|
||||
*/
|
||||
- (void)matchArray:(void (^_Nullable)(NSArray<FBSDKJSONField *> *_Nonnull))arrayMatcher
|
||||
dictionary:(void (^_Nullable)(NSDictionary<NSString *, FBSDKJSONField *> *_Nonnull))dictionaryMatcher
|
||||
string:(void (^_Nullable)(NSString *_Nonnull))stringMatcher
|
||||
number:(void (^_Nullable)(NSNumber *_Nonnull))numberMatcher
|
||||
null:(void (^_Nullable)(void))nullMatcher;
|
||||
|
||||
/**
|
||||
The underlying JSON object. The only guarantee we provide with this
|
||||
is that it passes [FBSDKTypeUtility isValidJSONObject:]
|
||||
*/
|
||||
@property (nonnull, nonatomic, readonly, strong) id rawObject;
|
||||
|
||||
- (NSArray<FBSDKJSONField *> *_Nullable)arrayOrNil;
|
||||
- (NSDictionary<NSString *, FBSDKJSONField *> *_Nullable)dictionaryOrNil;
|
||||
- (NSString *_Nullable)stringOrNil;
|
||||
- (NSNumber *_Nullable)numberOrNil;
|
||||
- (NSNull *_Nullable)nullOrNil;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Represents Top-level JSON objects.
|
||||
*/
|
||||
@interface FBSDKJSONValue : NSObject
|
||||
|
||||
/**
|
||||
If the object does not pass [FBSDKTypeUtility isValidJSONObject:]
|
||||
this will return nil.
|
||||
*/
|
||||
- (_Nullable instancetype)initWithPotentialJSONObject:(id)obj;
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
The underlying JSON object. The only guarantee we provide with this
|
||||
is that it passes [FBSDKTypeUtility isValidJSONObject:]
|
||||
*/
|
||||
@property (nonatomic, readonly, strong) id rawObject;
|
||||
|
||||
/**
|
||||
A safe method to unpack the values in the top-level JSON object.
|
||||
|
||||
The specs are per Apple's documentation: https://developer.apple.com/documentation/foundation/nsjsonserialization
|
||||
*/
|
||||
- (void)matchArray:(void (^_Nullable)(NSArray<FBSDKJSONField *> *))arrayMatcher
|
||||
dictionary:(void (^_Nullable)(NSDictionary<NSString *, FBSDKJSONField *> *))dictMatcher;
|
||||
|
||||
/**
|
||||
Returns the dictionary if that's truly what it is, otherwise, nil.
|
||||
*/
|
||||
- (NSDictionary<NSString *, FBSDKJSONField *> *_Nullable)matchDictionaryOrNil;
|
||||
|
||||
/**
|
||||
The unsafe variant which drops all the type-safety for this class.
|
||||
If this object is nonnull, you at least have guarantees from Apple that this is NSNull, NSString, NSNumber, NSArray, or NSDictionary.
|
||||
*/
|
||||
- (NSDictionary<NSString *, id> *_Nullable)unsafe_matchDictionaryOrNil;
|
||||
|
||||
- (NSArray<FBSDKJSONField *> *_Nullable)matchArrayOrNil;
|
||||
- (NSArray *_Nullable)unsafe_matchArrayOrNil;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
FBSDKTypeUtility returns id, which is problematic in our codebase.
|
||||
|
||||
You can wrap resulting objects in this to force users of your JSON to use
|
||||
type-safe bindings.
|
||||
|
||||
If this is not a valid JSON object...this will return nil.
|
||||
*/
|
||||
FBSDKJSONValue *_Nullable FBSDKCreateJSONFromString(NSString *_Nullable string, NSError *__autoreleasing *errorRef);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+33
@@ -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>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NS_SWIFT_NAME(LibAnalyzer)
|
||||
@interface FBSDKLibAnalyzer : NSObject
|
||||
|
||||
+ (NSDictionary<NSString *, NSString *> *)getMethodsTable:(NSArray<NSString *> *)prefixes
|
||||
frameworks:(NSArray<NSString *> *_Nullable)frameworks;
|
||||
+ (nullable NSArray<NSString *> *)symbolicateCallstack:(NSArray<NSString *> *)callstack
|
||||
methodMapping:(NSDictionary<NSString *, id> *)methodMapping;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// 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>
|
||||
|
||||
#ifndef FBSDK_CAST_TO_CLASS_OR_NIL_FUNC
|
||||
#define FBSDK_CAST_TO_CLASS_OR_NIL_FUNC
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/** Use the type-safe FBSDK_CAST_TO_CLASS_OR_NIL instead. */
|
||||
id _FBSDKCastToClassOrNilUnsafeInternal(id object, Class klass);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FBSDK_CAST_TO_CLASS_OR_NIL
|
||||
#define FBSDK_CAST_TO_CLASS_OR_NIL(obj_, class_) ((class_ *)_FBSDKCastToClassOrNilUnsafeInternal(obj_, [class_ class]))
|
||||
#endif
|
||||
|
||||
#ifndef FBSDK_CAST_TO_PROTOCOL_OR_NIL_FUNC
|
||||
#define FBSDK_CAST_TO_PROTOCOL_OR_NIL_FUNC
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/** Use the type-safe FBSDK_CAST_TO_PROTOCOL_OR_NIL instead. */
|
||||
id _FBSDKCastToProtocolOrNilUnsafeInternal(id object, Protocol *protocol);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FBSDK_CAST_TO_PROTOCOL_OR_NIL
|
||||
#define FBSDK_CAST_TO_PROTOCOL_OR_NIL(obj_, protocol_) ((id<protocol_>)_FBSDKCastToProtocolOrNilUnsafeInternal(obj_, @protocol(protocol_)))
|
||||
#endif
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// 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
|
||||
|
||||
/// An internal protocol used to describe a session data task
|
||||
NS_SWIFT_NAME(SessionDataTask)
|
||||
@protocol FBSDKSessionDataTask <NSObject>
|
||||
|
||||
@property(readonly) NSURLSessionTaskState state;
|
||||
|
||||
- (void)resume;
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
|
||||
/// An internal protocol used to describe a url session
|
||||
NS_SWIFT_NAME(SessionProviding)
|
||||
@protocol FBSDKSessionProviding <NSObject>
|
||||
|
||||
- (id<FBSDKSessionDataTask>)dataTaskWithRequest:(NSURLRequest *)request
|
||||
completionHandler:(void (^)(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error))completionHandler;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
// 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
|
||||
|
||||
NS_SWIFT_NAME(TypeUtility)
|
||||
@interface FBSDKTypeUtility : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
/// Returns an NSArray if the provided object is an NSArray, otherwise returns nil.
|
||||
+ (nullable NSArray *)arrayValue:(id)object;
|
||||
|
||||
/**
|
||||
Return an object at a given index if the index is valid, otherwise return nil
|
||||
@param array The array to retrieve the object from.
|
||||
@param index The index to retrieve the object from.
|
||||
*/
|
||||
+ (nullable id)array:(NSArray *)array objectAtIndex:(NSUInteger)index;
|
||||
|
||||
/**
|
||||
Adds an object to an array if it is not nil.
|
||||
@param array The array to add the object to.
|
||||
@param object The object to add to the array.
|
||||
*/
|
||||
+ (void)array:(NSMutableArray *)array addObject:(nullable id)object;
|
||||
|
||||
/**
|
||||
Adds an object to an array at a given index if the object is not nil and the index is available.
|
||||
Will override objects if they exist.
|
||||
@param array The array to add the object to.
|
||||
@param object The object to add to the array.
|
||||
@param index The index to try and insert the object into
|
||||
*/
|
||||
+ (void)array:(NSMutableArray *)array addObject:(nullable id)object atIndex:(NSUInteger)index;
|
||||
|
||||
/// Returns a BOOL if the provided object is a BOOL, otherwise returns nil.
|
||||
+ (BOOL)boolValue:(id)object;
|
||||
|
||||
/// Returns an NSDictionary if the provided object is an NSDictionary, otherwise returns nil.
|
||||
+ (nullable NSDictionary *)dictionaryValue:(id)object;
|
||||
|
||||
/// Returns an object for a given key in the provided dictionary if it matches the stated type
|
||||
+ (nullable id)dictionary:(NSDictionary *)dictionary objectForKey:(NSString *)key ofType:(Class)type;
|
||||
|
||||
/**
|
||||
Sets an object for a key in a dictionary if it is not nil.
|
||||
@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:(nullable id)object
|
||||
forKey:(nullable id<NSCopying>)key;
|
||||
|
||||
/// Checks if an object is a valid dictionary type before enumerating its keys and objects
|
||||
+ (void)dictionary:(NSDictionary *)dictionary enumerateKeysAndObjectsUsingBlock:(void (NS_NOESCAPE ^)(id key, id obj, BOOL *stop))block;
|
||||
|
||||
/// Returns an NSInteger if the provided object is an NSInteger, otherwise returns nil.
|
||||
+ (NSInteger)integerValue:(id)object;
|
||||
|
||||
/// Returns an NSNumber if the provided object is an NSNumber, otherwise returns nil.
|
||||
+ (NSNumber *)numberValue:(id)object;
|
||||
|
||||
/// Returns an NSString if the provided object is an NSString, otherwise returns nil.
|
||||
+ (NSString *)stringValueOrNil:(id)object;
|
||||
|
||||
/// Returns the provided object if it is non-null
|
||||
+ (nullable id)objectValue:(id)object;
|
||||
|
||||
/// Returns an NSString if the provided object can be coered to an NSString, otherwise returns nil.
|
||||
+ (nullable NSString *)coercedToStringValue:(id)object;
|
||||
|
||||
/// Returns an NSTimeInterval if the provided object is an NSTimeInterval, otherwise returns nil.
|
||||
+ (NSTimeInterval)timeIntervalValue:(id)object;
|
||||
|
||||
/// Returns an NSUInteger if the provided object is an NSUInteger, otherwise returns nil.
|
||||
+ (NSUInteger)unsignedIntegerValue:(id)object;
|
||||
|
||||
/// Returns an NSURL if the provided object is an NSURL, otherwise returns nil.
|
||||
+ (nullable NSURL *)URLValue:(id)object;
|
||||
|
||||
/*
|
||||
Lightweight wrapper around Foundation's isValidJSONObject:
|
||||
|
||||
Returns YES if the given object can be converted to JSON data, NO otherwise.
|
||||
Calling this method or attempting a conversion are the definitive ways to tell if a given object can be converted to JSON data.
|
||||
*/
|
||||
+ (BOOL)isValidJSONObject:(id)obj;
|
||||
|
||||
/*
|
||||
Lightweight safety wrapper around Foundation's NSJSONSerialization:dataWithJSONObject:options:error:
|
||||
|
||||
Generate JSON data from a Foundation object.
|
||||
If the object will not produce valid JSON then null is returned.
|
||||
Setting the NSJSONWritingPrettyPrinted option will generate JSON with whitespace designed to make the output more readable.
|
||||
If that option is not set, the most compact possible JSON will be generated.
|
||||
If an error occurs, the error parameter will be set and the return value will be nil.
|
||||
The resulting data is a encoded in UTF-8.
|
||||
*/
|
||||
+ (nullable NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error;
|
||||
|
||||
/*
|
||||
Lightweight safety wrapper around Foundation's NSJSONSerialization:JSONObjectWithData:options:error:
|
||||
|
||||
Create a Foundation object from JSON data.
|
||||
Set the NSJSONReadingAllowFragments option if the parser should allow top-level objects that are not an NSArray or NSDictionary.
|
||||
Setting the NSJSONReadingMutableContainers option will make the parser generate mutable NSArrays and NSDictionaries.
|
||||
Setting the NSJSONReadingMutableLeaves option will make the parser generate mutable NSString objects.
|
||||
If an error occurs during the parse, then the error parameter will be set and the result will be nil.
|
||||
The data must be in one of the 5 supported encodings listed in the JSON specification: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE.
|
||||
The data may or may not have a BOM.
|
||||
The most efficient encoding to use for parsing is UTF-8, so if you have a choice in encoding the data passed to this method, use UTF-8.
|
||||
*/
|
||||
+ (nullable id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+45
@@ -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>
|
||||
|
||||
#import "FBSDKURLSessionTask.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBSDKURLSession : NSObject
|
||||
|
||||
@property (nullable, atomic, strong) NSURLSession *session;
|
||||
@property (nullable, nonatomic, weak) id<NSURLSessionDataDelegate> delegate;
|
||||
@property (nullable, nonatomic, retain) NSOperationQueue *delegateQueue;
|
||||
|
||||
- (instancetype)initWithDelegate:(id<NSURLSessionDataDelegate>)delegate
|
||||
delegateQueue:(NSOperationQueue *)delegateQueue;
|
||||
|
||||
- (void)executeURLRequest:(NSURLRequest *)request
|
||||
completionHandler:(FBSDKURLSessionTaskBlock)handler;
|
||||
|
||||
- (void)updateSessionWithBlock:(dispatch_block_t)block;
|
||||
|
||||
- (void)invalidateAndCancel;
|
||||
|
||||
- (BOOL)valid;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// 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 "FBSDKSessionProviding.h"
|
||||
|
||||
typedef void (^FBSDKURLSessionTaskBlock)(NSData *responseData,
|
||||
NSURLResponse *response,
|
||||
NSError *error)
|
||||
NS_SWIFT_NAME(UrlSessionTaskBlock);
|
||||
|
||||
NS_SWIFT_NAME(UrlSessionTask)
|
||||
@interface FBSDKURLSessionTask : NSObject
|
||||
|
||||
@property (nonatomic, strong) id<FBSDKSessionDataTask> task;
|
||||
@property (atomic, readonly) NSURLSessionTaskState state;
|
||||
@property (nonatomic, strong, readonly) NSDate *requestStartDate;
|
||||
@property (nonatomic, copy) FBSDKURLSessionTaskBlock handler;
|
||||
@property (nonatomic, assign) uint64_t requestStartTime;
|
||||
@property (nonatomic, assign) NSUInteger loggerSerialNumber;
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype)initWithRequest:(NSURLRequest *)request
|
||||
fromSession:(id<FBSDKSessionProviding>)session
|
||||
completionHandler:(FBSDKURLSessionTaskBlock)handler;
|
||||
|
||||
- (void)start;
|
||||
- (void)cancel;
|
||||
|
||||
@end
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
// 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
|
||||
|
||||
/// typedef for FBSDKAppEventUserDataType
|
||||
typedef NSString *const FBSDKAppEventUserDataType NS_TYPED_EXTENSIBLE_ENUM; // NS_SWIFT_NAME(AppEvents.UserDataType);
|
||||
|
||||
/** Parameter key used to specify user's email. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventEmail;
|
||||
|
||||
/** Parameter key used to specify user's first name. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventFirstName;
|
||||
|
||||
/** Parameter key used to specify user's last name. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventLastName;
|
||||
|
||||
/** Parameter key used to specify user's phone. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventPhone;
|
||||
|
||||
/** Parameter key used to specify user's date of birth. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventDateOfBirth;
|
||||
|
||||
/** Parameter key used to specify user's gender. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventGender;
|
||||
|
||||
/** Parameter key used to specify user's city. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventCity;
|
||||
|
||||
/** Parameter key used to specify user's state. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventState;
|
||||
|
||||
/** Parameter key used to specify user's zip. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventZip;
|
||||
|
||||
/** Parameter key used to specify user's country. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventCountry;
|
||||
|
||||
/** Parameter key used to specify user's external id. */
|
||||
FOUNDATION_EXPORT FBSDKAppEventUserDataType FBSDKAppEventExternalId;
|
||||
|
||||
NS_SWIFT_NAME(UserDataStore)
|
||||
@interface FBSDKUserDataStore : NSObject
|
||||
|
||||
/*
|
||||
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
|
||||
@param externalId user's external id
|
||||
*/
|
||||
+ (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
|
||||
externalId:(nullable NSString *)externalId
|
||||
NS_SWIFT_NAME(setUser(email:firstName:lastName:phone:dateOfBirth:gender:city:state:zip:country:externalId:));
|
||||
|
||||
/*
|
||||
Returns the set user data else nil
|
||||
*/
|
||||
+ (nullable NSString *)getUserData;
|
||||
|
||||
/*
|
||||
Clears the current user data
|
||||
*/
|
||||
+ (void)clearUserData;
|
||||
|
||||
/*
|
||||
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 data data
|
||||
@param type data type, e.g. FBSDKAppEventEmail, FBSDKAppEventPhone
|
||||
*/
|
||||
+ (void)setUserData:(nullable NSString *)data
|
||||
forType:(FBSDKAppEventUserDataType)type;
|
||||
|
||||
/*
|
||||
Clears the current user data of certain type
|
||||
*/
|
||||
+ (void)clearUserDataForType:(FBSDKAppEventUserDataType)type;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Generated
+29
@@ -0,0 +1,29 @@
|
||||
// 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 "FBSDKInfoDictionaryProviding.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Default conformance to the info dictionary providing protocol
|
||||
@interface NSBundle (InfoDictionaryProviding) <FBSDKInfoDictionaryProviding>
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user