Skip to content

Commit 696a513

Browse files
committed
Updated callback
1 parent e5aa03e commit 696a513

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

Branch-TestBed/Branch-SDK-Tests/BranchLoggerTests.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ - (void)testLogLevelThresholdBlocksLowerLevels {
3030
logger.logCallback = ^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {
3131
if ([message isEqualToString:@"[BranchSDK][Debug][BranchLoggerTests testLogLevelThresholdBlocksLowerLevels] This message should trigger the log callback."] && logLevel >= BranchLogLevelDebug) {
3232
[expectation fulfill];
33+
} else if (logLevel == BranchLogLevelVerbose) {
34+
XCTFail();
3335
}
3436
};
3537

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ - (BOOL)application:(UIApplication *)application
3535
// test pre init support
3636
//[self testDispatchToIsolationQueue:branch]
3737

38-
[branch enableLoggingAtLevel:BranchLogLevelVerbose];
39-
// [BranchLogger shared].logCallback = ^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {
40-
// // Handle the log message and error here. For example, printing to the console:
41-
// if (error) {
42-
// NSLog(@"[BranchLog] Level: %lu, Message: %@, Error: %@", (unsigned long)logLevel, message, error.localizedDescription);
43-
// } else {
44-
// NSLog(@"[BranchLog] Level: %lu, Message: %@", (unsigned long)logLevel, message);
45-
// }
46-
// };
38+
[branch enableLoggingAtLevel:BranchLogLevelVerbose withCallback:^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {
39+
// Handle the log message and error here. For example, printing to the console:
40+
if (error) {
41+
NSLog(@"[BranchLog] Level: %lu, Message: %@, Error: %@", (unsigned long)logLevel, message, error.localizedDescription);
42+
} else {
43+
NSLog(@"[BranchLog] Level: %lu, Message: %@", (unsigned long)logLevel, message);
44+
}
45+
}];
4746

4847
// Comment out in production. Un-comment to test your Branch SDK Integration:
4948
//[branch validateSDKIntegration];

BranchSDK/Branch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ extern NSString * __nonnull const BNCSpotlightFeature;
568568
*/
569569
- (void)enableLogging;
570570
- (void)enableLoggingAtLevel:(BranchLogLevel)logLevel;
571+
- (void)enableLoggingAtLevel:(BranchLogLevel)logLevel withCallback:(nullable BranchLogCallback)callback;
571572

572573
/**
573574
Send requests to EU endpoints.

BranchSDK/Branch.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,13 @@ - (void)enableLoggingAtLevel:(BranchLogLevel)logLevel {
427427
logger.logLevelThreshold = logLevel;
428428
}
429429

430+
- (void)enableLoggingAtLevel:(BranchLogLevel)logLevel withCallback:(nullable BranchLogCallback)callback {
431+
BranchLogger *logger = [BranchLogger shared];
432+
logger.loggingEnabled = YES;
433+
logger.logLevelThreshold = logLevel;
434+
logger.logCallback = callback;
435+
}
436+
430437
- (void)useEUEndpoints {
431438
[BNCServerAPI sharedInstance].useEUServers = YES;
432439
}

0 commit comments

Comments
 (0)