Skip to content

Commit abe0662

Browse files
authored
Merge pull request #253 from BranchMetrics/fix_update_ios_sdk
fix: updated iOS sdk to 0.12.19
2 parents 95defff + 52aeda6 commit abe0662

File tree

8 files changed

+68
-31
lines changed

8 files changed

+68
-31
lines changed

src/ios/dependencies/Branch-SDK/BNCConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef Branch_SDK_Config_h
1010
#define Branch_SDK_Config_h
1111

12-
#define SDK_VERSION @"0.12.16"
12+
#define SDK_VERSION @"0.12.19"
1313

1414
#define BNC_PROD_ENV
1515
//#define BNC_STAGE_ENV

src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,11 @@ - (void)persistPrefsToDisk {
633633
@synchronized (self) {
634634
NSDictionary *persistenceDict = [self.persistenceDict copy];
635635
NSBlockOperation *newPersistOp = [NSBlockOperation blockOperationWithBlock:^ {
636-
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:persistenceDict];
636+
NSData *data = nil;
637+
@try {
638+
data = [NSKeyedArchiver archivedDataWithRootObject:persistenceDict];
639+
} @catch (id n) {
640+
}
637641
if (!data) {
638642
[self logWarning:@"Can't create preferences archive."];
639643
return;
@@ -659,7 +663,7 @@ - (NSMutableDictionary *)persistenceDict {
659663
@try {
660664
NSError *error = nil;
661665
NSData *data = [NSData dataWithContentsOfURL:self.class.URLForPrefsFile
662-
options:0 error:&error];
666+
options:0 error:&error];
663667
if (!error && data)
664668
persistenceDict = [NSKeyedUnarchiver unarchiveObjectWithData:data];
665669
}
@@ -713,35 +717,64 @@ + (NSString *)prefsFile_deprecated {
713717
return path;
714718
}
715719

716-
+ (NSURL*) URLForBranchDirectory {
720+
+ (NSURL* _Nonnull) URLForBranchDirectory {
721+
NSSearchPathDirectory kSearchDirectories[] = {
722+
NSApplicationSupportDirectory,
723+
NSCachesDirectory,
724+
NSDocumentDirectory,
725+
};
726+
727+
#define _countof(array) (sizeof(array)/sizeof(array[0]))
728+
729+
for (NSSearchPathDirectory directory = 0; directory < _countof(kSearchDirectories); directory++) {
730+
NSURL *URL = [self createDirectoryForBranchURLWithPath:kSearchDirectories[directory]];
731+
if (URL) return URL;
732+
}
733+
734+
#undef _countof
735+
736+
// Worst case backup plan:
737+
NSString *path = [@"~/Library/io.branch" stringByExpandingTildeInPath];
738+
NSURL *branchURL = [NSURL fileURLWithPath:path isDirectory:YES];
739+
NSFileManager *fileManager = [NSFileManager defaultManager];
717740
NSError *error = nil;
718-
NSURL *URL =
719-
[[NSFileManager defaultManager]
720-
URLForDirectory:NSApplicationSupportDirectory
721-
inDomain:NSUserDomainMask
722-
appropriateForURL:nil
723-
create:YES
741+
BOOL success =
742+
[fileManager
743+
createDirectoryAtURL:branchURL
744+
withIntermediateDirectories:YES
745+
attributes:nil
724746
error:&error];
725-
if (error) {
726-
NSLog(@"Error creating URLForPrefsDirectory: %@.", error);
727-
return nil;
747+
if (!success) {
748+
NSLog(@"Worst case CreateBranchURL error: %@ URL: %@.", error, branchURL);
728749
}
729-
URL = [URL URLByAppendingPathComponent:@"io.branch"];
730-
[[NSFileManager defaultManager]
731-
createDirectoryAtURL:URL
732-
withIntermediateDirectories:YES
733-
attributes:nil
734-
error:&error];
735-
if (error) {
736-
NSLog(@"Error creating URLForPrefsDirectory: %@.", error);
737-
return nil;
750+
return branchURL;
751+
}
752+
753+
+ (NSURL* _Null_unspecified) createDirectoryForBranchURLWithPath:(NSSearchPathDirectory)directory {
754+
NSFileManager *fileManager = [NSFileManager defaultManager];
755+
NSArray *URLs = [fileManager URLsForDirectory:directory inDomains:NSUserDomainMask | NSLocalDomainMask];
756+
757+
for (NSURL *URL in URLs) {
758+
NSError *error = nil;
759+
NSURL *branchURL = [URL URLByAppendingPathComponent:@"io.branch" isDirectory:YES];
760+
BOOL success =
761+
[fileManager
762+
createDirectoryAtURL:branchURL
763+
withIntermediateDirectories:YES
764+
attributes:nil
765+
error:&error];
766+
if (success) {
767+
return branchURL;
768+
} else {
769+
NSLog(@"CreateBranchURL error: %@ URL: %@.", error, branchURL);
770+
}
738771
}
739-
return URL;
772+
return nil;
740773
}
741774

742-
+ (NSURL*) URLForPrefsFile {
775+
+ (NSURL* _Nonnull) URLForPrefsFile {
743776
NSURL *URL = [self URLForBranchDirectory];
744-
URL = [URL URLByAppendingPathComponent:BRANCH_PREFS_FILE];
777+
URL = [URL URLByAppendingPathComponent:BRANCH_PREFS_FILE isDirectory:NO];
745778
return URL;
746779
}
747780

src/ios/dependencies/Branch-SDK/BNCServerRequestQueue.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ + (NSString *)queueFile_deprecated {
291291
return path;
292292
}
293293

294-
+ (NSURL*) URLForQueueFile {
294+
+ (NSURL* _Nonnull) URLForQueueFile {
295295
NSURL *URL = [BNCPreferenceHelper URLForBranchDirectory];
296-
URL = [URL URLByAppendingPathComponent:BRANCH_QUEUE_FILE];
296+
URL = [URL URLByAppendingPathComponent:BRANCH_QUEUE_FILE isDirectory:NO];
297297
return URL;
298298
}
299299

src/ios/dependencies/Branch-SDK/Branch.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ + (NSString *)bundleIdentifier {
14331433
}
14341434

14351435
+ (NSString *)kitDisplayVersion {
1436-
return @"0.12.16";
1436+
return @"0.12.19";
14371437
}
14381438

14391439
@end

src/ios/dependencies/Branch-SDK/BranchActivityItemProvider.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ + (NSString *)humanReadableChannelWithActivityType:(NSString *)activityString {
9393
@"WhatsApp", @"net.whatsapp.WhatsApp.ShareExtension",
9494
@"WeChat", @"com.tencent.xin.sharetimeline",
9595
@"LINE", @"jp.naver.line.Share",
96+
@"Pinterest", @"pinterest.ShareExtension",
9697
nil
9798
];
9899
// Set to a more human readible sting if we can identify it

src/ios/dependencies/Branch-SDK/BranchContentDiscoverer.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,17 @@ - (UIViewController *)getActiveViewController:(UIViewController *)rootViewContro
240240
return activeController;
241241
}
242242

243-
- (void)addFormattedContentData:(NSMutableArray *)contentDataArray withText:(NSString *)contentData clearText:(BOOL)isClearText {
243+
- (void)addFormattedContentData:(NSMutableArray *)contentDataArray
244+
withText:(NSString *)contentData
245+
clearText:(BOOL)isClearText {
244246
if (contentData && contentData.length > _cdManifest.maxTextLen) {
245247
contentData = [contentData substringToIndex:_cdManifest.maxTextLen];
246248
}
247249
if (!isClearText) {
248250
contentData = [BNCEncodingUtils md5Encode:contentData];
249251
}
250-
[contentDataArray addObject:contentData];
252+
if (contentData)
253+
[contentDataArray addObject:contentData];
251254
}
252255

253256
- (NSString *)getContentText:(UIView *)view {
Binary file not shown.

src/ios/dependencies/Branch.framework/Versions/A/Headers/BNCConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef Branch_SDK_Config_h
1010
#define Branch_SDK_Config_h
1111

12-
#define SDK_VERSION @"0.12.16"
12+
#define SDK_VERSION @"0.12.19"
1313

1414
#define BNC_PROD_ENV
1515
//#define BNC_STAGE_ENV

0 commit comments

Comments
 (0)