Skip to content

Commit 2009c84

Browse files
committed
Allow init calls to come in late.
1 parent b30349c commit 2009c84

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Sources/BranchSDK/Branch.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -625,27 +625,20 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options
625625
[self.class addBranchSDKVersionToCrashlyticsReport];
626626
self.shouldAutomaticallyDeepLink = automaticallyDisplayController;
627627

628-
// If the SDK is already initialized, this means that initSession was called after other lifecycle calls.
629-
if (self.initializationStatus == BNCInitStatusInitialized) {
630-
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil];
631-
return;
632-
}
633-
634-
// Save data from push notification on app launch
628+
// Check for Branch link in a push payload
629+
NSString *pushURL = nil;
635630
#if !TARGET_OS_TV
636631
if ([options objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
637632
id branchUrlFromPush = [options objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey][BRANCH_PUSH_NOTIFICATION_PAYLOAD_KEY];
638633
if ([branchUrlFromPush isKindOfClass:[NSString class]]) {
639634
self.preferenceHelper.universalLinkUrl = branchUrlFromPush;
640635
self.preferenceHelper.referringURL = branchUrlFromPush;
636+
pushURL = (NSString *)branchUrlFromPush;
641637
}
642638
}
643639
#endif
644640

645-
// Handle case where there's no URI scheme or Universal Link.
646-
if (![options.allKeys containsObject:UIApplicationLaunchOptionsURLKey] && ![options.allKeys containsObject:UIApplicationLaunchOptionsUserActivityDictionaryKey]) {
647-
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil];
648-
}
641+
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL];
649642
}
650643

651644
- (void)setDeepLinkDebugMode:(NSDictionary *)debugParams {

0 commit comments

Comments
 (0)