BranchMetrics/ios-branch-deep-linking-attribution

Branch.initSession(launchOptions:andRegisterDeepLinkHandler:) never calls handler

kagan-livefront opened this issue · 6 comments

Describe the bug

When launching our app by following a universal link unrelated to Branch, the deep link handler is never called. The deep link handler is called correctly when launching the app normally, or when launching the app via a Branch link.

Steps to reproduce

This is a stripped down version of our didFinishLaunchingWithOptions method. Everything works correctly when launching the app normally, or when following a branch link. However, when launching the app by following a universal link unrelated to Branch, the deep link handler is never called.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        let branch = Branch.getInstance("our-configuration-key")
        branch.initSession(launchOptions: launchOptions) { params, error in
            // deep link handler is never called
        }

        return true
    }

Note: If I pass in nil instead of launchOptions everything works. So I assume the initSession(launchOptions:) method is erroring on the launchOptions that are being passed in. In that case, I would still expect the deep link handler to be called, with an error included.

Expected behavior

The deep link handler would be called upon initialization, and also whenever the app is foregrounded. If there was an error in initialization, I would expect an error to be returned in the completion handler.

SDK Version

2.2.0 and 2.1.1

XCode Version

14.3

Device

iPhone 14 Pro Simulator

OS

16.4

Additional Information/Context

No response

I'd like to know more about the non-branch link that's causing this. Is it the sort of thing you could share or repro generically?

Thanks for responding so quickly!

I'd like to know more about the non-branch link that's causing this. Is it the sort of thing you could share or repro generically?

Unfortunately for client confidentiality reasons I can't share the actual link. But here's a generic version of the link's format with a random UUID representing a unique ID. https://some.host.com/somepath/5678685e-fb7c-4a84-934d-7446349df5d0

If it's important to have the actual link to diagnose this issue we could work on building an example app and example website that handled the universal linking.

Hi @kagan-livefront, you can certainly create a support ticket through https://help.branch.io/using-branch/page/submit-a-ticket and our support team can ask for more confidential integration information.

But, this sounds like it could be possible that the non-branch link isn't being passed to us properly via continueUserActivity

But, this sounds like it could be possible that the non-branch link isn't being passed to us properly via continueUserActivity

@jf-branch Brilliant! This was 100% it. We had been checking Branch.isBranchLink(_:) to determine if we should call Branch.continue(_:) or process the link manually. Instead, it sounds like we need to always call Branch.continue(_:).

Tangentially, should we skip the isBranchLink(_:) check and use the result of continue(_:) as a defecto check of whether it's a Branch link? According to the docs it seems like the .isBranchLink(_:) check was possibly redundant.

@kagan-livefront Happy to hear!

so I think it depends actually.

If you have routing logic based on non-Branch Links, than it depends where you want to handle that routing logic.

But since Branch relays all non-Branch links through our initSession callback for the key +non_branch_link, than my recommendation would be that you can consolidate all your routing logics within the Branch initSession callback and then always return true for continue(_:).

Thanks @jf-branch 🙌. I'll go ahead and close this out then.