From ffa4337da202af70fcff5719ebfce1211a9f2d3f Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Tue, 23 Jul 2024 17:50:00 -0700 Subject: [PATCH] Release 3.5.0 --- BranchSDK.podspec | 2 +- BranchSDK.xcodeproj/project.pbxproj | 12 +++--- ChangeLog.md | 4 ++ Sources/BranchSDK/BNCConfig.m | 2 +- Sources/BranchSDK/BNCPreferenceHelper.m | 3 ++ Sources/BranchSDK/BNCReferringURLUtility.m | 2 + Sources/BranchSDK/BNCServerInterface.m | 11 +++++- Sources/BranchSDK/BNCURLFilter.m | 2 + Sources/BranchSDK/Branch.m | 29 +++++++++++++- Sources/BranchSDK/BranchQRCode.m | 2 + Sources/BranchSDK/NSError+Branch.m | 46 ++++++++++++++++++++++ Sources/BranchSDK/Private/NSError+Branch.h | 3 ++ Sources/BranchSDK/Public/Branch.h | 4 +- scripts/version.sh | 2 +- 14 files changed, 111 insertions(+), 13 deletions(-) diff --git a/BranchSDK.podspec b/BranchSDK.podspec index 9802021..aa82bcf 100644 --- a/BranchSDK.podspec +++ b/BranchSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "BranchSDK" - s.version = "3.4.4" + s.version = "3.5.0" s.summary = "Create an HTTP URL for any piece of content in your app" s.description = <<-DESC - Want the highest possible conversions on your sharing feature? diff --git a/BranchSDK.xcodeproj/project.pbxproj b/BranchSDK.xcodeproj/project.pbxproj index 2bcc3a7..b68b64b 100644 --- a/BranchSDK.xcodeproj/project.pbxproj +++ b/BranchSDK.xcodeproj/project.pbxproj @@ -1974,7 +1974,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.4.4; + MARKETING_VERSION = 3.5.0; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2009,7 +2009,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.4.4; + MARKETING_VERSION = 3.5.0; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2215,7 +2215,7 @@ "@loader_path/Frameworks", ); MACH_O_TYPE = staticlib; - MARKETING_VERSION = 3.4.4; + MARKETING_VERSION = 3.5.0; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2254,7 +2254,7 @@ "@loader_path/Frameworks", ); MACH_O_TYPE = staticlib; - MARKETING_VERSION = 3.4.4; + MARKETING_VERSION = 3.5.0; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2291,7 +2291,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.4.4; + MARKETING_VERSION = 3.5.0; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2326,7 +2326,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.4.4; + MARKETING_VERSION = 3.5.0; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, diff --git a/ChangeLog.md b/ChangeLog.md index bf6ae71..df75a18 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ Branch iOS SDK Change Log +v.3.5.0 +- Add additional logging +- Update setRequestMetadata signature to use NSString + v.3.4.4 - Fix for rare case where Branch events were duplicated - Fixed script in "Run Script" phase of static framework targets diff --git a/Sources/BranchSDK/BNCConfig.m b/Sources/BranchSDK/BNCConfig.m index 385949a..3224fdd 100644 --- a/Sources/BranchSDK/BNCConfig.m +++ b/Sources/BranchSDK/BNCConfig.m @@ -8,7 +8,7 @@ #include "BNCConfig.h" -NSString * const BNC_SDK_VERSION = @"3.4.4"; +NSString * const BNC_SDK_VERSION = @"3.5.0"; NSString * const BNC_LINK_URL = @"https://bnc.lt"; NSString * const BNC_CDN_URL = @"https://cdn.branch.io"; diff --git a/Sources/BranchSDK/BNCPreferenceHelper.m b/Sources/BranchSDK/BNCPreferenceHelper.m index ff4eaca..66b9464 100644 --- a/Sources/BranchSDK/BNCPreferenceHelper.m +++ b/Sources/BranchSDK/BNCPreferenceHelper.m @@ -388,9 +388,11 @@ - (NSString *)sessionParams { - (void)setSessionParams:(NSString *)sessionParams { @synchronized (self) { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Setting session params %@", sessionParams] error:nil]; if (sessionParams == nil || ![_sessionParams isEqualToString:sessionParams]) { _sessionParams = sessionParams; [self writeObjectToDefaults:BRANCH_PREFS_KEY_SESSION_PARAMS value:sessionParams]; + [[BranchLogger shared] logVerbose:@"Params set" error:nil]; } } } @@ -845,6 +847,7 @@ - (void) clearTrackingInformation { self.userIdentity = nil; self.referringURLQueryParameters = nil; self.anonID = nil; + [[BranchLogger shared] logVerbose:@"Tracking information cleared" error:nil]; } } diff --git a/Sources/BranchSDK/BNCReferringURLUtility.m b/Sources/BranchSDK/BNCReferringURLUtility.m index 3d7b63a..79ce1cd 100644 --- a/Sources/BranchSDK/BNCReferringURLUtility.m +++ b/Sources/BranchSDK/BNCReferringURLUtility.m @@ -46,6 +46,8 @@ - (void)dealloc { - (void)parseReferringURL:(NSURL *)url { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Parsing URL %@", url] error:nil]; + NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; for (NSURLQueryItem *item in components.queryItems) { if ([self isSupportedQueryParameter:item.name]) { diff --git a/Sources/BranchSDK/BNCServerInterface.m b/Sources/BranchSDK/BNCServerInterface.m index 63559c3..818eba4 100644 --- a/Sources/BranchSDK/BNCServerInterface.m +++ b/Sources/BranchSDK/BNCServerInterface.m @@ -61,6 +61,8 @@ - (void)postRequest:(NSDictionary *)post url:(NSString *)url key:(NSString *)key - (void)postRequest:(NSDictionary *)post url:(NSString *)url retryNumber:(NSInteger)retryNumber key:(NSString *)key callback:(BNCServerCallback)callback { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"retryNumber %ld", retryNumber] error:nil]; + // TODO: confirm it's ok to send full URL instead of with the domain trimmed off self.requestEndpoint = url; NSURLRequest *request = [self preparePostRequest:post url:url key:key retryNumber:retryNumber]; @@ -124,6 +126,8 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN if (status != 200) { if ([NSError branchDNSBlockingError:underlyingError]) { [[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Possible DNS Ad Blocker. Giving up on request with HTTP status code %ld", (long)status] error:underlyingError]; + } else if ([NSError branchVPNBlockingError:underlyingError]) { + [[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Possible VPN Ad Blocker. Giving up on request with HTTP status code %ld", (long)status] error:underlyingError]; } else { [[BranchLogger shared] logWarning: [NSString stringWithFormat:@"Giving up on request with HTTP status code %ld", (long)status] error:underlyingError]; } @@ -139,7 +143,8 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN // Drops non-linking requests when tracking is disabled if (Branch.trackingDisabled) { NSString *endpoint = request.URL.absoluteString; - + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Tracking is disabled, checking if %@ is linking request.", endpoint] error:nil]; + if (![self isLinkingRelatedRequest:endpoint]) { [[BNCPreferenceHelper sharedInstance] clearTrackingInformation]; NSError *error = [NSError branchErrorWithCode:BNCTrackingDisabledError]; @@ -290,6 +295,10 @@ - (BNCServerResponse *)processServerResponse:(NSURLResponse *)response data:(NSD NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; NSString *requestId = httpResponse.allHeaderFields[@"X-Branch-Request-Id"]; + if ([[BranchLogger shared] shouldLog:BranchLogLevelVerbose]) { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Processing response %@", requestId] error:nil]; + } + if (!error) { serverResponse.statusCode = @([httpResponse statusCode]); serverResponse.data = [BNCEncodingUtils decodeJsonDataToDictionary:data]; diff --git a/Sources/BranchSDK/BNCURLFilter.m b/Sources/BranchSDK/BNCURLFilter.m index 65cf25f..d60ff38 100644 --- a/Sources/BranchSDK/BNCURLFilter.m +++ b/Sources/BranchSDK/BNCURLFilter.m @@ -133,6 +133,8 @@ - (BOOL)foundUpdatedURLList:(id)operation { } else if (statusCode != 200 || error != nil || jsonString == nil) { if ([NSError branchDNSBlockingError:error]) { [[BranchLogger shared] logWarning:@"Possible DNS Ad Blocker" error:error]; + } else if ([NSError branchVPNBlockingError:error]) { + [[BranchLogger shared] logWarning:@"Possible VPN Ad Blocker" error:error]; } else { [[BranchLogger shared] logWarning:@"Failed to update URL ignore list" error:operation.error]; } diff --git a/Sources/BranchSDK/Branch.m b/Sources/BranchSDK/Branch.m index 97a7383..194e03f 100644 --- a/Sources/BranchSDK/Branch.m +++ b/Sources/BranchSDK/Branch.m @@ -491,7 +491,7 @@ - (void)setRetryInterval:(NSTimeInterval)retryInterval { } -- (void)setRequestMetadataKey:(NSString *)key value:(NSObject *)value { +- (void)setRequestMetadataKey:(NSString *)key value:(NSString *)value { [self.preferenceHelper setRequestMetadataKey:key value:value]; } @@ -504,6 +504,8 @@ + (BOOL)trackingDisabled { + (void)setTrackingDisabled:(BOOL)disabled { @synchronized(self) { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"setTrackingDisabled to %d", disabled] error:nil]; + BOOL currentSetting = self.trackingDisabled; if (!!currentSetting == !!disabled) return; @@ -515,6 +517,8 @@ + (void)setTrackingDisabled:(BOOL)disabled { Branch *branch = Branch.getInstance; [branch clearNetworkQueue]; branch.initializationStatus = BNCInitStatusUninitialized; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"initializationStatus %ld", branch.initializationStatus] error:nil]; + [branch.linkCache clear]; // Release the lock in case it's locked: [BranchOpenRequest releaseOpenResponseLock]; @@ -668,10 +672,12 @@ - (BOOL)handleDeepLink:(NSURL *)url { } - (BOOL)handleDeepLink:(NSURL *)url sceneIdentifier:(NSString *)sceneIdentifier { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Handle deep link %@", url] error:nil]; // we've been resetting the session on all deeplinks for quite some time // this allows foreground links to callback self.initializationStatus = BNCInitStatusUninitialized; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"initializationStatus %ld", self.initializationStatus] error:nil]; //Check the referring url/uri for query parameters and save them BNCReferringURLUtility *utility = [BNCReferringURLUtility new]; @@ -702,6 +708,8 @@ - (BOOL)handleDeepLink:(NSURL *)url sceneIdentifier:(NSString *)sceneIdentifier - (BOOL)handleSchemeDeepLink_private:(NSURL*)url sceneIdentifier:(NSString *)sceneIdentifier { BOOL handled = NO; self.preferenceHelper.referringURL = nil; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Set referringURL to %@", self.preferenceHelper.referringURL] error:nil]; + if (url && ![url isEqual:[NSNull null]]) { NSString *urlScheme = [url scheme]; @@ -712,12 +720,14 @@ - (BOOL)handleSchemeDeepLink_private:(NSURL*)url sceneIdentifier:(NSString *)sce if (urlScheme && [scheme isEqualToString:urlScheme]) { self.preferenceHelper.externalIntentURI = [url absoluteString]; self.preferenceHelper.referringURL = [url absoluteString]; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Allowed scheme list, set externalIntentURI and referringURL to %@", [url absoluteString]] error:nil]; break; } } } else { self.preferenceHelper.externalIntentURI = [url absoluteString]; self.preferenceHelper.referringURL = [url absoluteString]; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Set externalIntentURI and referringURL to %@", [url absoluteString]] error:nil]; } NSString *query = [url fragment]; @@ -762,6 +772,7 @@ - (BOOL)handleUniversalDeepLink_private:(NSString*)urlString sceneIdentifier:(NS if (urlString.length) { self.preferenceHelper.universalLinkUrl = urlString; self.preferenceHelper.referringURL = urlString; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Set universalLinkUrl and referringURL to %@", urlString] error:nil]; } [self initUserSessionAndCallCallback:YES sceneIdentifier:sceneIdentifier urlString:urlString]; @@ -1699,16 +1710,25 @@ - (void)applicationDidBecomeActive { dispatch_async(self.isolationQueue, ^(){ // if necessary, creates a new organic open BOOL installOrOpenInQueue = [self.requestQueue containsInstallOrOpen]; + + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationDidBecomeActive installOrOpenInQueue %d", installOrOpenInQueue] error:nil]; + if (!Branch.trackingDisabled && self.initializationStatus != BNCInitStatusInitialized && !installOrOpenInQueue) { + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationDidBecomeActive trackingDisabled %d initializationStatus %d installOrOpenInQueue %d", Branch.trackingDisabled, self.initializationStatus, installOrOpenInQueue] error:nil]; + [self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil]; } }); } - (void)applicationWillResignActive { + [[BranchLogger shared] logVerbose:@"applicationWillResignActive" error:nil]; + dispatch_async(self.isolationQueue, ^(){ if (!Branch.trackingDisabled) { self.initializationStatus = BNCInitStatusUninitialized; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"applicationWillResignActive initializationStatus %ld", self.initializationStatus] error:nil]; + [self.requestQueue persistImmediately]; [BranchOpenRequest setWaitNeededForOpenResponseLock]; } @@ -1842,6 +1862,8 @@ - (void)processNextQueueItem { self.networkCount = 1; dispatch_semaphore_signal(self.processing_sema); BNCServerRequest *req = [self.requestQueue peek]; + + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"Processing %@", req]error:nil]; if (req) { @@ -2035,6 +2057,8 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS } self.initializationStatus = BNCInitStatusInitializing; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"initializationStatus %ld", self.initializationStatus] error:nil]; + [self processNextQueueItem]; }); } @@ -2044,6 +2068,8 @@ - (void)initializeSessionAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSS - (void)handleInitSuccessAndCallCallback:(BOOL)callCallback sceneIdentifier:(NSString *)sceneIdentifier { self.initializationStatus = BNCInitStatusInitialized; + [[BranchLogger shared] logVerbose:[NSString stringWithFormat:@"initializationStatus %ld", self.initializationStatus] error:nil]; + NSDictionary *latestReferringParams = [self getLatestReferringParams]; if ([latestReferringParams[@"_branch_validate"] isEqualToString:@"060514"]) { @@ -2260,6 +2286,7 @@ - (void)presentSharingViewController:(UIViewController