Skip to content

Commit

Permalink
Merge pull request #253 from BranchMetrics/fix_update_ios_sdk
Browse files Browse the repository at this point in the history
fix: updated iOS sdk to 0.12.19
  • Loading branch information
ethanneff authored Dec 8, 2016
2 parents 95defff + 52aeda6 commit abe0662
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef Branch_SDK_Config_h
#define Branch_SDK_Config_h

#define SDK_VERSION @"0.12.16"
#define SDK_VERSION @"0.12.19"

#define BNC_PROD_ENV
//#define BNC_STAGE_ENV
Expand Down
81 changes: 57 additions & 24 deletions src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,11 @@ - (void)persistPrefsToDisk {
@synchronized (self) {
NSDictionary *persistenceDict = [self.persistenceDict copy];
NSBlockOperation *newPersistOp = [NSBlockOperation blockOperationWithBlock:^ {
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:persistenceDict];
NSData *data = nil;
@try {
data = [NSKeyedArchiver archivedDataWithRootObject:persistenceDict];
} @catch (id n) {
}
if (!data) {
[self logWarning:@"Can't create preferences archive."];
return;
Expand All @@ -659,7 +663,7 @@ - (NSMutableDictionary *)persistenceDict {
@try {
NSError *error = nil;
NSData *data = [NSData dataWithContentsOfURL:self.class.URLForPrefsFile
options:0 error:&error];
options:0 error:&error];
if (!error && data)
persistenceDict = [NSKeyedUnarchiver unarchiveObjectWithData:data];
}
Expand Down Expand Up @@ -713,35 +717,64 @@ + (NSString *)prefsFile_deprecated {
return path;
}

+ (NSURL*) URLForBranchDirectory {
+ (NSURL* _Nonnull) URLForBranchDirectory {
NSSearchPathDirectory kSearchDirectories[] = {
NSApplicationSupportDirectory,
NSCachesDirectory,
NSDocumentDirectory,
};

#define _countof(array) (sizeof(array)/sizeof(array[0]))

for (NSSearchPathDirectory directory = 0; directory < _countof(kSearchDirectories); directory++) {
NSURL *URL = [self createDirectoryForBranchURLWithPath:kSearchDirectories[directory]];
if (URL) return URL;
}

#undef _countof

// Worst case backup plan:
NSString *path = [@"~/Library/io.branch" stringByExpandingTildeInPath];
NSURL *branchURL = [NSURL fileURLWithPath:path isDirectory:YES];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSURL *URL =
[[NSFileManager defaultManager]
URLForDirectory:NSApplicationSupportDirectory
inDomain:NSUserDomainMask
appropriateForURL:nil
create:YES
BOOL success =
[fileManager
createDirectoryAtURL:branchURL
withIntermediateDirectories:YES
attributes:nil
error:&error];
if (error) {
NSLog(@"Error creating URLForPrefsDirectory: %@.", error);
return nil;
if (!success) {
NSLog(@"Worst case CreateBranchURL error: %@ URL: %@.", error, branchURL);
}
URL = [URL URLByAppendingPathComponent:@"io.branch"];
[[NSFileManager defaultManager]
createDirectoryAtURL:URL
withIntermediateDirectories:YES
attributes:nil
error:&error];
if (error) {
NSLog(@"Error creating URLForPrefsDirectory: %@.", error);
return nil;
return branchURL;
}

+ (NSURL* _Null_unspecified) createDirectoryForBranchURLWithPath:(NSSearchPathDirectory)directory {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *URLs = [fileManager URLsForDirectory:directory inDomains:NSUserDomainMask | NSLocalDomainMask];

for (NSURL *URL in URLs) {
NSError *error = nil;
NSURL *branchURL = [URL URLByAppendingPathComponent:@"io.branch" isDirectory:YES];
BOOL success =
[fileManager
createDirectoryAtURL:branchURL
withIntermediateDirectories:YES
attributes:nil
error:&error];
if (success) {
return branchURL;
} else {
NSLog(@"CreateBranchURL error: %@ URL: %@.", error, branchURL);
}
}
return URL;
return nil;
}

+ (NSURL*) URLForPrefsFile {
+ (NSURL* _Nonnull) URLForPrefsFile {
NSURL *URL = [self URLForBranchDirectory];
URL = [URL URLByAppendingPathComponent:BRANCH_PREFS_FILE];
URL = [URL URLByAppendingPathComponent:BRANCH_PREFS_FILE isDirectory:NO];
return URL;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ios/dependencies/Branch-SDK/BNCServerRequestQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ + (NSString *)queueFile_deprecated {
return path;
}

+ (NSURL*) URLForQueueFile {
+ (NSURL* _Nonnull) URLForQueueFile {
NSURL *URL = [BNCPreferenceHelper URLForBranchDirectory];
URL = [URL URLByAppendingPathComponent:BRANCH_QUEUE_FILE];
URL = [URL URLByAppendingPathComponent:BRANCH_QUEUE_FILE isDirectory:NO];
return URL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ + (NSString *)bundleIdentifier {
}

+ (NSString *)kitDisplayVersion {
return @"0.12.16";
return @"0.12.19";
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ + (NSString *)humanReadableChannelWithActivityType:(NSString *)activityString {
@"WhatsApp", @"net.whatsapp.WhatsApp.ShareExtension",
@"WeChat", @"com.tencent.xin.sharetimeline",
@"LINE", @"jp.naver.line.Share",
@"Pinterest", @"pinterest.ShareExtension",
nil
];
// Set to a more human readible sting if we can identify it
Expand Down
7 changes: 5 additions & 2 deletions src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,17 @@ - (UIViewController *)getActiveViewController:(UIViewController *)rootViewContro
return activeController;
}

- (void)addFormattedContentData:(NSMutableArray *)contentDataArray withText:(NSString *)contentData clearText:(BOOL)isClearText {
- (void)addFormattedContentData:(NSMutableArray *)contentDataArray
withText:(NSString *)contentData
clearText:(BOOL)isClearText {
if (contentData && contentData.length > _cdManifest.maxTextLen) {
contentData = [contentData substringToIndex:_cdManifest.maxTextLen];
}
if (!isClearText) {
contentData = [BNCEncodingUtils md5Encode:contentData];
}
[contentDataArray addObject:contentData];
if (contentData)
[contentDataArray addObject:contentData];
}

- (NSString *)getContentText:(UIView *)view {
Expand Down
Binary file modified src/ios/dependencies/Branch.framework/Versions/A/Branch
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef Branch_SDK_Config_h
#define Branch_SDK_Config_h

#define SDK_VERSION @"0.12.16"
#define SDK_VERSION @"0.12.19"

#define BNC_PROD_ENV
//#define BNC_STAGE_ENV
Expand Down

0 comments on commit abe0662

Please sign in to comment.