ios-branch-deep-linking-attribution: Callback on the initSession() function doesn't get called when app already installed
When I launch the app from a universal link on a device where the app is already installed, the callback on the initSession() function doesn’t get called. This is my AppDelegate code:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
func showHomeViewController() {
//TODO: Remove for launch
Branch.useTestBranchKey()
Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in
guard error == nil, let parameters = params as? [String: AnyObject], let encodedReferralEvent = parameters[Branch.BranchKey.referralEvent.rawValue] as? NSString else {
DispatchQueue.main.async {
self.setRootViewController(viewController: self.produceRootViewController(referralEvent: nil))
}
return
}
DispatchQueue.main.async {
let referralEvent = API.Users.Get.MyDecodedInvitationObject(base64EncodedString: encodedReferralEvent as String)
self.setRootViewController(viewController: self.produceRootViewController(referralEvent: referralEvent))
}
}
}
#if DEBUG
if EnvironmentPickerViewController.shouldShowEnvironmentPicker() {
let envPicker = EnvironmentPickerViewController.newInstance()
envPicker.completion = showHomeViewController
window?.rootViewController = envPicker
window?.makeKeyAndVisible()
} else {
showHomeViewController()
}
#else
showHomeViewController()
#endif
return true
}
func setRootViewController(viewController: UIViewController) {
window?.rootViewController = viewController
window?.makeKeyAndVisible()
}
func produceRootViewController(referralEvent: ReferralEvent?) -> RootViewController {
let vc = ControllerFactory.newController(instantiator: .storyboard, configurator: RootConfigurator())
var destinationDS = vc.router?.dataStore
destinationDS?.referralEvent = referralEvent
return vc
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
Branch.getInstance().application(app, open: url, options: options)
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
// handler for Universal Links
Branch.getInstance().continue(userActivity)
return true
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// handler for Push Notifications
Branch.getInstance().handlePushNotification(userInfo)
}
When I launch the app after installing it from the App Store, the callback is called. Any ideas why there is this difference in behaviour?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 28 (13 by maintainers)
@javidsheikh The fix is on the staging branch, QA is testing it. I’m hoping to have a new release by mid next week.
0.30.0 is released and includes general init threading improvements.
Hi @echo-branch, Is there any update from this issue? We are waiting a new version to remove UIWebView without this issue.
This is a pretty serious issue. We updated from
0.25.3to0.29.0and started experiencing this change in behavior, which in our case led to the app failing to load as we were optimistically relying on that callback always running.@doanduchieu Not yet. Still researching.