From 800ea811513621c6f5078adf963ad17d59bbb429 Mon Sep 17 00:00:00 2001 From: ndixit-branch <93544270+NidhiDixit09@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:52:14 -0700 Subject: [PATCH] INTENG-21106 Fix for double opens (#1425) * INTENG-21106 Fix for double opens initSceneSessionWithLaunchOptions will call initUserSessionAndCallCallback method only is there is a push URL or BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY is true. In rest of the use cases initUserSessionAndCallCallback will be called by function - handleDeepLink(universal links or custom URIs ) or appDidBecomeActive (organic Opens) * Updated fix for deffered init. * Updated Version and ChangeLog for Release 3.6.2 --- BranchSDK.podspec | 2 +- BranchSDK.xcodeproj/project.pbxproj | 12 ++++++------ ChangeLog.md | 4 ++++ Sources/BranchSDK/BNCConfig.m | 2 +- Sources/BranchSDK/Branch.m | 13 +++++++++++-- scripts/version.sh | 2 +- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/BranchSDK.podspec b/BranchSDK.podspec index 2945cc13f..51834cb76 100644 --- a/BranchSDK.podspec +++ b/BranchSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "BranchSDK" - s.version = "3.6.1" + s.version = "3.6.2" 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 a325e67a5..4cc3e30c3 100644 --- a/BranchSDK.xcodeproj/project.pbxproj +++ b/BranchSDK.xcodeproj/project.pbxproj @@ -1974,7 +1974,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2009,7 +2009,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2215,7 +2215,7 @@ "@loader_path/Frameworks", ); MACH_O_TYPE = staticlib; - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2254,7 +2254,7 @@ "@loader_path/Frameworks", ); MACH_O_TYPE = staticlib; - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2291,7 +2291,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, @@ -2326,7 +2326,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 3.6.1; + MARKETING_VERSION = 3.6.2; OTHER_LDFLAGS = ( "-weak_framework", LinkPresentation, diff --git a/ChangeLog.md b/ChangeLog.md index b81675e83..d082a2f74 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ Branch iOS SDK Change Log +v.3.6.2 +- Fix for issue which was sending an extra open request on cold app launch. +- Updated fix for cold link launch when using deferred initialization and an AppDelegate only app. + v.3.6.1 - Fixed issues where external_intent_uri was incorrectly set in certain cases diff --git a/Sources/BranchSDK/BNCConfig.m b/Sources/BranchSDK/BNCConfig.m index 53443cbda..cbba9b378 100644 --- a/Sources/BranchSDK/BNCConfig.m +++ b/Sources/BranchSDK/BNCConfig.m @@ -8,7 +8,7 @@ #include "BNCConfig.h" -NSString * const BNC_SDK_VERSION = @"3.6.1"; +NSString * const BNC_SDK_VERSION = @"3.6.2"; NSString * const BNC_LINK_URL = @"https://bnc.lt"; NSString * const BNC_CDN_URL = @"https://cdn.branch.io"; diff --git a/Sources/BranchSDK/Branch.m b/Sources/BranchSDK/Branch.m index 69aac1ee2..9b4d4f87e 100644 --- a/Sources/BranchSDK/Branch.m +++ b/Sources/BranchSDK/Branch.m @@ -70,6 +70,7 @@ NSString * const BRANCH_INIT_KEY_IS_FIRST_SESSION = @"+is_first_session"; NSString * const BRANCH_INIT_KEY_CLICKED_BRANCH_LINK = @"+clicked_branch_link"; static NSString * const BRANCH_PUSH_NOTIFICATION_PAYLOAD_KEY = @"branch"; +static NSString * const BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY = @"deferInitForPluginRuntime"; NSString * const BNCCanonicalIdList = @"$canonical_identifier_list"; NSString * const BNCPurchaseAmount = @"$amount"; @@ -615,9 +616,15 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL) - (void)initSceneSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)isReferrable explicitlyRequestedReferrable:(BOOL)explicitlyRequestedReferrable automaticallyDisplayController:(BOOL)automaticallyDisplayController registerDeepLinkHandler:(void (^)(BNCInitSessionResponse * _Nullable initResponse, NSError * _Nullable error))callback { + NSMutableDictionary * optionsWithDeferredInit = [[NSMutableDictionary alloc ] initWithDictionary:options]; + if (self.deferInitForPluginRuntime) { + [optionsWithDeferredInit setObject:@1 forKey:@"BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY"]; + } else { + [optionsWithDeferredInit setObject:@0 forKey:@"BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY"]; + } [self deferInitBlock:^{ self.sceneSessionInitWithCallback = callback; - [self initSessionWithLaunchOptions:options isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController]; + [self initSessionWithLaunchOptions:(NSDictionary *)optionsWithDeferredInit isReferrable:isReferrable explicitlyRequestedReferrable:explicitlyRequestedReferrable automaticallyDisplayController:automaticallyDisplayController]; }]; } @@ -642,7 +649,9 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options } #endif - [self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL reset:NO]; + if(pushURL || [[options objectForKey:@"BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY"] isEqualToNumber:@1] || (![options.allKeys containsObject:UIApplicationLaunchOptionsURLKey] && ![options.allKeys containsObject:UIApplicationLaunchOptionsUserActivityDictionaryKey]) ) { + [self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL reset:NO]; + } } - (void)setDeepLinkDebugMode:(NSDictionary *)debugParams { diff --git a/scripts/version.sh b/scripts/version.sh index d6953fded..952184f43 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -30,7 +30,7 @@ Options: USAGE } -version=3.6.1 +version=3.6.2 prev_version="$version" if (( $# == 0 )); then