Skip to content

Commit 18d848f

Browse files
committed
change errors to warnings in BNCApplication. Remove telephony from testbed
1 parent b8d27fc commit 18d848f

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
5F3D671B233062FD00454FF1 /* BNCJsonLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F3D671A233062FD00454FF1 /* BNCJsonLoader.m */; };
5151
5F3D671C233062FD00454FF1 /* BNCJsonLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F3D671A233062FD00454FF1 /* BNCJsonLoader.m */; };
5252
5F42763325DB3694005B9BBC /* AdServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F42763225DB3694005B9BBC /* AdServices.framework */; };
53-
5F437E38237DE1320052064B /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F437E37237DE1320052064B /* CoreTelephony.framework */; settings = {ATTRIBUTES = (Required, ); }; };
5453
5F437E40237E1A560052064B /* BNCDeviceSystemTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F437E3F237E1A560052064B /* BNCDeviceSystemTests.m */; };
5554
5F5FDA102B7DE20800F14A43 /* BranchLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F5FDA0F2B7DE20800F14A43 /* BranchLogger.m */; };
5655
5F5FDA122B7DE22A00F14A43 /* BranchLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F5FDA112B7DE22A00F14A43 /* BranchLogger.h */; };
@@ -569,7 +568,6 @@
569568
buildActionMask = 2147483647;
570569
files = (
571570
5F92B2362383644C00CA909B /* SystemConfiguration.framework in Frameworks */,
572-
5F437E38237DE1320052064B /* CoreTelephony.framework in Frameworks */,
573571
5F205D05231864E800C776D1 /* WebKit.framework in Frameworks */,
574572
5FF7D2862A9549B40049158D /* AdServices.framework in Frameworks */,
575573
466B584F1B17775900A69EDE /* AdSupport.framework in Frameworks */,

Sources/BranchSDK/BNCApplication.m

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,64 +69,66 @@ + (BNCApplication*) createCurrentApplication {
6969
return application;
7070
}
7171

72-
+ (NSDate*) currentBuildDate {
72+
+ (NSDate *)currentBuildDate {
7373
NSURL *appURL = nil;
7474
NSURL *bundleURL = [NSBundle mainBundle].bundleURL;
7575
NSDictionary *info = [NSBundle mainBundle].infoDictionary;
76-
NSString *appName = info[(__bridge NSString*)kCFBundleExecutableKey];
76+
NSString *appName = info[(__bridge NSString *)kCFBundleExecutableKey];
7777
if (appName.length > 0 && bundleURL) {
7878
appURL = [bundleURL URLByAppendingPathComponent:appName];
7979
} else {
8080
NSString *path = [[NSProcessInfo processInfo].arguments firstObject];
81-
if (path) appURL = [NSURL fileURLWithPath:path];
81+
if (path) {
82+
appURL = [NSURL fileURLWithPath:path];
83+
}
8284
}
83-
if (appURL == nil)
85+
if (appURL == nil) {
86+
[[BranchLogger shared] logWarning:@"Failed to get build date, app path is nil" error:nil];
8487
return nil;
88+
}
8589

8690
NSError *error = nil;
8791
NSFileManager *fileManager = [NSFileManager defaultManager];
8892
NSDictionary *attributes = [fileManager attributesOfItemAtPath:appURL.path error:&error];
8993
if (error) {
90-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Can't get build date: %@.", error] error:error];
94+
[[BranchLogger shared] logWarning:@"Failed to get build date" error:error];
9195
return nil;
9296
}
93-
NSDate * buildDate = [attributes fileCreationDate];
97+
NSDate *buildDate = [attributes fileCreationDate];
9498
if (buildDate == nil || [buildDate timeIntervalSince1970] <= 0.0) {
95-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Invalid build date: %@.", buildDate] error:nil];
99+
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Invalid build date: %@", buildDate] error:nil];
96100
}
97101
return buildDate;
98102
}
99103

100-
+ (NSDate*) firstInstallBuildDate {
104+
+ (NSDate *)firstInstallBuildDate {
101105
NSError *error = nil;
102-
NSDate *firstBuildDate =
103-
[BNCKeyChain retrieveDateForService:kBranchKeychainService
104-
key:kBranchKeychainFirstBuildKey
105-
error:&error];
106-
if (firstBuildDate)
106+
NSDate *firstBuildDate = [BNCKeyChain retrieveDateForService:kBranchKeychainService key:kBranchKeychainFirstBuildKey error:&error];
107+
if (firstBuildDate) {
107108
return firstBuildDate;
108-
109+
}
110+
109111
firstBuildDate = [self currentBuildDate];
110-
error = [BNCKeyChain storeDate:firstBuildDate
111-
forService:kBranchKeychainService
112-
key:kBranchKeychainFirstBuildKey
113-
cloudAccessGroup:nil];
114-
if (error) [[BranchLogger shared] logError:[NSString stringWithFormat:@"Keychain store: %@.", error] error:error];
115-
112+
error = [BNCKeyChain storeDate:firstBuildDate forService:kBranchKeychainService key:kBranchKeychainFirstBuildKey cloudAccessGroup:nil];
113+
if (error) {
114+
[[BranchLogger shared] logWarning:@"Error while saving build date" error:error];
115+
}
116116
return firstBuildDate;
117117
}
118118

119-
+ (NSDate *) currentInstallDate {
119+
+ (NSDate *)currentInstallDate {
120120
NSDate *installDate = [NSDate date];
121121

122122
#if !TARGET_OS_TV
123123
// tvOS always returns a creation date of Unix epoch 0 on device
124124
installDate = [self creationDateForLibraryDirectory];
125-
#endif
126-
127125
if (installDate == nil || [installDate timeIntervalSince1970] <= 0.0) {
128-
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Invalid install date, using [NSDate date]."] error:nil];
126+
[[BranchLogger shared] logWarning:@"Invalid install date, using [NSDate date]" error:nil];
129127
}
128+
#else
129+
[[BranchLogger shared] logWarning:@"File system creation date not supported on tvOS, using [NSDate date]" error:nil];
130+
#endif
131+
130132
return installDate;
131133
}
132134

@@ -136,13 +138,13 @@ + (NSDate *)creationDateForLibraryDirectory {
136138
NSURL *directoryURL = [[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] firstObject];
137139
NSDictionary *attributes = [fileManager attributesOfItemAtPath:directoryURL.path error:&error];
138140
if (error) {
139-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Can't get creation date for Library directory: %@", error] error:error];
140-
return nil;
141+
[[BranchLogger shared] logWarning:@"Failed to get creation date for Library directory" error:error];
142+
return nil;
141143
}
142144
return [attributes fileCreationDate];
143145
}
144146

145-
+ (NSDate*) firstInstallDate {
147+
+ (NSDate *)firstInstallDate {
146148
// check keychain for stored install date, on iOS this is lost on app deletion.
147149
NSError *error = nil;
148150
NSDate* firstInstallDate = [BNCKeyChain retrieveDateForService:kBranchKeychainService key:kBranchKeychainFirstInstalldKey error:&error];
@@ -156,7 +158,7 @@ + (NSDate*) firstInstallDate {
156158
// save filesystem time to keychain
157159
error = [BNCKeyChain storeDate:firstInstallDate forService:kBranchKeychainService key:kBranchKeychainFirstInstalldKey cloudAccessGroup:nil];
158160
if (error) {
159-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Keychain store: %@.", error] error:error];
161+
[[BranchLogger shared] logWarning:@"Error while saving install date" error:error];
160162
}
161163
return firstInstallDate;
162164
}

Sources/BranchSDK/BranchQRCode.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,14 @@ - (void)callQRCodeAPI:(nullable NSDictionary *)params
143143
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
144144

145145
if (error) {
146-
[[BranchLogger shared] logError:[NSString stringWithFormat:@"QR Code Post Request Error: %@", [error localizedDescription]] error:error];
146+
[[BranchLogger shared] logError:@"QR Code request failed" error:error];
147147
completion(nil, error);
148148
return;
149149
}
150150

151151
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
152152

153153
if (httpResponse.statusCode == 200) {
154-
155154
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"Network finish operation %@ %1.3fs. Status %ld.",
156155
request.URL.absoluteString,
157156
[[NSDate date] timeIntervalSinceDate:startDate],

0 commit comments

Comments
 (0)