Skip to content

Commit 37d0fb8

Browse files
committed
Release 3.8.0
1 parent 67b02bf commit 37d0fb8

File tree

13 files changed

+82
-27
lines changed

13 files changed

+82
-27
lines changed

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,23 @@ - (BOOL)application:(UIApplication *)application
4141
// test pre init support
4242
//[self testDispatchToIsolationQueue:branch]
4343

44-
45-
[Branch enableLoggingAtLevel:BranchLogLevelVerbose withCallback:^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error) {
44+
[Branch enableLoggingAtLevel:BranchLogLevelVerbose withAdvancedCallback:^(NSString * _Nonnull message, BranchLogLevel logLevel, NSError * _Nullable error, NSMutableURLRequest * _Nullable request, BNCServerResponse * _Nullable response) {
4645
// Handle the log message and error here. For example, printing to the console:
4746
if (error) {
4847
NSLog(@"[BranchLog] Level: %lu, Message: %@, Error: %@", (unsigned long)logLevel, message, error.localizedDescription);
4948
} else {
5049
NSLog(@"[BranchLog] Level: %lu, Message: %@", (unsigned long)logLevel, message);
5150
}
5251

52+
if (request) {
53+
NSString *jsonString = [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding];
54+
NSLog(@"[BranchLog] Got %@ Request: %@", request.URL , jsonString);
55+
}
56+
57+
if (response) {
58+
NSLog(@"[BranchLog] Got Response for request (%@): %@", response.requestId, response.data);
59+
}
60+
5361
NSString *logEntry = error ? [NSString stringWithFormat:@"Level: %lu, Message: %@, Error: %@", (unsigned long)logLevel, message, error.localizedDescription]
5462
: [NSString stringWithFormat:@"Level: %lu, Message: %@", (unsigned long)logLevel, message];
5563
APPLogHookFunction([NSDate date], logLevel, logEntry);

BranchSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "BranchSDK"
3-
s.version = "3.7.0"
3+
s.version = "3.8.0"
44
s.summary = "Create an HTTP URL for any piece of content in your app"
55
s.description = <<-DESC
66
- Want the highest possible conversions on your sharing feature?

BranchSDK.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@
19741974
"@executable_path/Frameworks",
19751975
"@loader_path/Frameworks",
19761976
);
1977-
MARKETING_VERSION = 3.7.0;
1977+
MARKETING_VERSION = 3.8.0;
19781978
OTHER_LDFLAGS = (
19791979
"-weak_framework",
19801980
LinkPresentation,
@@ -2009,7 +2009,7 @@
20092009
"@executable_path/Frameworks",
20102010
"@loader_path/Frameworks",
20112011
);
2012-
MARKETING_VERSION = 3.7.0;
2012+
MARKETING_VERSION = 3.8.0;
20132013
OTHER_LDFLAGS = (
20142014
"-weak_framework",
20152015
LinkPresentation,
@@ -2215,7 +2215,7 @@
22152215
"@loader_path/Frameworks",
22162216
);
22172217
MACH_O_TYPE = staticlib;
2218-
MARKETING_VERSION = 3.7.0;
2218+
MARKETING_VERSION = 3.8.0;
22192219
OTHER_LDFLAGS = (
22202220
"-weak_framework",
22212221
LinkPresentation,
@@ -2254,7 +2254,7 @@
22542254
"@loader_path/Frameworks",
22552255
);
22562256
MACH_O_TYPE = staticlib;
2257-
MARKETING_VERSION = 3.7.0;
2257+
MARKETING_VERSION = 3.8.0;
22582258
OTHER_LDFLAGS = (
22592259
"-weak_framework",
22602260
LinkPresentation,
@@ -2291,7 +2291,7 @@
22912291
"@executable_path/Frameworks",
22922292
"@loader_path/Frameworks",
22932293
);
2294-
MARKETING_VERSION = 3.7.0;
2294+
MARKETING_VERSION = 3.8.0;
22952295
OTHER_LDFLAGS = (
22962296
"-weak_framework",
22972297
LinkPresentation,
@@ -2326,7 +2326,7 @@
23262326
"@executable_path/Frameworks",
23272327
"@loader_path/Frameworks",
23282328
);
2329-
MARKETING_VERSION = 3.7.0;
2329+
MARKETING_VERSION = 3.8.0;
23302330
OTHER_LDFLAGS = (
23312331
"-weak_framework",
23322332
LinkPresentation,

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Branch iOS SDK Change Log
22

3+
v.3.8.0
4+
- Added new `BranchAdvancedLogCallback` which contains request and response data for Branch network requests
5+
- Added ability to set Consumer Protection Attribution Level through the `branch.json` file
6+
37
v.3.7.0
48
- Added `setConsumerProtectionAttributionLevel` for controlling attribution data collection
59
- Deprecated `setTrackingDisabled` in favor of `setConsumerProtectionAttributionLevel(NONE)`

Sources/BranchSDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include "BNCConfig.h"
1010

11-
NSString * const BNC_SDK_VERSION = @"3.7.0";
11+
NSString * const BNC_SDK_VERSION = @"3.8.0";
1212
NSString * const BNC_LINK_URL = @"https://bnc.lt";
1313
NSString * const BNC_CDN_URL = @"https://cdn.branch.io";
1414

Sources/BranchSDK/BNCServerInterface.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ - (NSURLRequest *)preparePostRequest:(NSDictionary *)params url:(NSString *)url
289289
[request setHTTPBody:postData];
290290

291291
if ([[BranchLogger shared] shouldLog:BranchLogLevelDebug]) {
292-
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"%@\nHeaders %@\nBody %@", request, [request allHTTPHeaderFields], [BNCEncodingUtils prettyPrintJSON:updatedParams]] error:nil];
292+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"%@\nHeaders %@\nBody %@", request, [request allHTTPHeaderFields], [BNCEncodingUtils prettyPrintJSON:updatedParams]] error:nil request:request response:nil];
293293
}
294294

295295
return request;
@@ -310,7 +310,7 @@ - (BNCServerResponse *)processServerResponse:(NSURLResponse *)response data:(NSD
310310
serverResponse.requestId = requestId;
311311

312312
if ([[BranchLogger shared] shouldLog:BranchLogLevelDebug]) {
313-
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"%@\nBody %@", response, [BNCEncodingUtils prettyPrintJSON:serverResponse.data]] error:nil];
313+
[[BranchLogger shared] logDebug:[NSString stringWithFormat:@"%@\nBody %@", response, [BNCEncodingUtils prettyPrintJSON:serverResponse.data]] error:nil request:nil response:serverResponse];
314314
}
315315

316316
} else {

Sources/BranchSDK/Branch.m

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,20 @@ - (id)initWithInterface:(BNCServerInterface *)interface
256256
if (config.checkPasteboardOnInstall) {
257257
[self checkPasteboardOnInstall];
258258
}
259+
260+
if (config.cppLevel) {
261+
if ([config.cppLevel caseInsensitiveCompare:@"FULL"] == NSOrderedSame) {
262+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelFull];
263+
} else if ([config.cppLevel caseInsensitiveCompare:@"REDUCED"] == NSOrderedSame) {
264+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelReduced];
265+
} else if ([config.cppLevel caseInsensitiveCompare:@"MINIMAL"] == NSOrderedSame) {
266+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelMinimal];
267+
} else if ([config.cppLevel caseInsensitiveCompare:@"NONE"] == NSOrderedSame) {
268+
[[Branch getInstance] setConsumerProtectionAttributionLevel:BranchAttributionLevelNone];
269+
} else {
270+
NSLog(@"Invalid CPP Level set in branch.json: %@", config.cppLevel);
271+
}
272+
}
259273

260274
return self;
261275
}
@@ -455,6 +469,15 @@ + (void)enableLoggingAtLevel:(BranchLogLevel)logLevel withCallback:(nullable Bra
455469
}
456470
}
457471

472+
+ (void)enableLoggingAtLevel:(BranchLogLevel)logLevel withAdvancedCallback:(nullable BranchAdvancedLogCallback)callback {
473+
BranchLogger *logger = [BranchLogger shared];
474+
logger.loggingEnabled = YES;
475+
logger.logLevelThreshold = logLevel;
476+
if (callback) {
477+
logger.advancedLogCallback = callback;
478+
}
479+
}
480+
458481
- (void)useEUEndpoints {
459482
[BNCServerAPI sharedInstance].useEUServers = YES;
460483
}
@@ -632,7 +655,7 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options automaticallyDispla
632655

633656
#pragma mark - Actual Init Session
634657

635-
- (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandlerUsingBranchUniversalObject:(callbackWithBranchUniversalObject)callback {
658+
- (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandlerUsingBranchUniversalObject:(callbackWithBranchUniversalObject)callback {
636659
[self initSceneSessionWithLaunchOptions:options isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController
637660
registerDeepLinkHandler:^(BNCInitSessionResponse * _Nullable initResponse, NSError * _Nullable error) {
638661
if (callback) {
@@ -1107,8 +1130,8 @@ - (NSDictionary *)getFirstReferringParams {
11071130

11081131
if (self.deepLinkDebugParams) {
11091132
NSMutableDictionary* debugInstallParams =
1110-
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
1111-
mutableCopy];
1133+
[[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams]
1134+
mutableCopy];
11121135
[debugInstallParams addEntriesFromDictionary:self.deepLinkDebugParams];
11131136
return debugInstallParams;
11141137
}
@@ -2051,7 +2074,7 @@ - (void)initUserSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSStr
20512074
// only called from initUserSessionAndCallCallback!
20522075
- (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier urlString:(NSString *)urlString {
20532076

2054-
// BranchDelegate willStartSessionWithURL notification
2077+
// BranchDelegate willStartSessionWithURL notification
20552078
NSURL *URL = (self.preferenceHelper.referringURL.length) ? [NSURL URLWithString:self.preferenceHelper.referringURL] : nil;
20562079
if ([self.delegate respondsToSelector:@selector(branch:willStartSessionWithURL:)]) {
20572080
[self.delegate branch:self willStartSessionWithURL:URL];
@@ -2116,7 +2139,7 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS
21162139

21172140
[self processNextQueueItem];
21182141
});
2119-
}
2142+
}
21202143
}
21212144

21222145

Sources/BranchSDK/BranchJsonConfig.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
NSString * _Nonnull const BranchJsonConfigEnableLogging = @"enableLogging";
1919
NSString * _Nonnull const BranchJsonConfigCheckPasteboardOnInstall = @"checkPasteboardOnInstall";
2020
NSString * _Nonnull const BranchJsonConfigAPIUrl = @"apiUrl";
21-
21+
NSString * _Nonnull const BranchJsonConfigCPPLevel = @"consumerProtectionAttributionLevel";
2222

2323
@interface BranchJsonConfig()
2424
@property (nonatomic, strong) NSDictionary *configuration;
@@ -163,6 +163,11 @@ - (NSString *)apiUrl
163163
return self[BranchJsonConfigAPIUrl];
164164
}
165165

166+
- (NSString *)cppLevel
167+
{
168+
return self[BranchJsonConfigCPPLevel];
169+
}
170+
166171
- (id)objectForKey:(NSString *)key
167172
{
168173
return self.configuration[key];

Sources/BranchSDK/BranchLogger.m

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,29 @@ - (void)disableCallerDetails {
5353
}
5454

5555
- (void)logError:(NSString *)message error:(NSError *_Nullable)error {
56-
[self logMessage:message withLevel:BranchLogLevelError error:error];
56+
[self logMessage:message withLevel:BranchLogLevelError error:error request:nil response:nil];
5757
}
5858

5959
- (void)logWarning:(NSString *)message error:(NSError *_Nullable)error {
60-
[self logMessage:message withLevel:BranchLogLevelWarning error:error];
60+
[self logMessage:message withLevel:BranchLogLevelWarning error:error request:nil response:nil];
6161
}
6262

63-
- (void)logDebug:(NSString *)message error:(NSError *_Nullable)error {
64-
[self logMessage:message withLevel:BranchLogLevelDebug error:error];
63+
- (void)logDebug:(NSString * _Nonnull)message error:(NSError * _Nullable)error {
64+
[self logDebug:message error:error request:nil response:nil];
65+
}
66+
67+
- (void)logDebug:(NSString * _Nonnull)message
68+
error:(NSError * _Nullable)error
69+
request:(NSMutableURLRequest * _Nullable)request
70+
response:(BNCServerResponse * _Nullable)response {
71+
[self logMessage:message withLevel:BranchLogLevelDebug error:error request:request response:response];
6572
}
6673

6774
- (void)logVerbose:(NSString *)message error:(NSError *_Nullable)error {
68-
[self logMessage:message withLevel:BranchLogLevelVerbose error:error];
75+
[self logMessage:message withLevel:BranchLogLevelVerbose error:error request:nil response:nil];
6976
}
7077

71-
- (void)logMessage:(NSString *)message withLevel:(BranchLogLevel)level error:(NSError *_Nullable)error {
78+
- (void)logMessage:(NSString *)message withLevel:(BranchLogLevel)level error:(NSError *_Nullable)error request:(NSMutableURLRequest * _Nullable)request response:(BNCServerResponse * _Nullable)response {
7279
if (!self.loggingEnabled || level < self.logLevelThreshold || message.length == 0) {
7380
return;
7481
}
@@ -77,8 +84,10 @@ - (void)logMessage:(NSString *)message withLevel:(BranchLogLevel)level error:(NS
7784
if (self.includeCallerDetails) {
7885
formattedMessage = [NSString stringWithFormat:@"%@ %@", [self callingClass], message];
7986
}
80-
81-
if (self.logCallback) {
87+
88+
if (self.advancedLogCallback) {
89+
self.advancedLogCallback(formattedMessage, level, error, request, response);
90+
} else if (self.logCallback) {
8291
self.logCallback(formattedMessage, level, error);
8392
}
8493
}

Sources/BranchSDK/Private/BranchJsonConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern NSString * _Nonnull const BranchJsonConfigAPIUrl;
3131
@property (nonatomic, readonly, assign) BOOL enableLogging;
3232
@property (nonatomic, readonly, assign) BOOL checkPasteboardOnInstall;
3333
@property (nonatomic, readonly, nullable, copy) NSString *apiUrl;
34+
@property (nonatomic, readonly, nullable, copy) NSString *cppLevel;
3435

3536
- (nullable id)objectForKey:(NSString * _Nonnull)key;
3637
- (nullable id)objectForKeyedSubscript:(NSString * _Nonnull)key;

0 commit comments

Comments
 (0)