Vitaliy Krayovyy
Vitaliy Krayovyy

Reputation: 1

Issues passing data from subdomain to app with Branch.io

We have an iOS app and use Branch SDK to implement invites. All required data we transfer as parameters inside a universal link. Our problem is that it works perfectly fine when a user taps a link when the app is already installed on the device, but it fails to pass data in random cases when a user has to install the app from Testflight or AppStore in between. It sometimes works, and sometimes just doesn't. The one same link may work now, but fail in few minutes. Under "fail" I mean that parameters are not passed to the app.

Here's our configuration:

We set up Info.plist files for our staging and production environment as it is described in the documentation:

All these fields are present in .plist files for both environments.

Also, we set up .entitlements file where we placed associated domains. It contains 6 values:

and this file is added to both staging and production targets.

In my AppDelegate I set up branch like this:

    Branch.setUseTestBranchKey(Configuration.branchTestKeyEnabled)
    let branch: Branch = Branch.getInstance()

    branch.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: {params, error in
        if error == nil {
            print("params: %@", params as? [String: AnyObject] ?? {})
        } else {
            print(error)
        }
    })

Where

Configuration.branchTestKeyEnabled 

is true for staging and false for production.

Later after launch, I try to get referring parameters like this:

 let branch = Branch.getInstance()
 let params = branch?.getLatestReferringParamsSynchronous() as? [String : Any]
 // Do something with parameters

Here is a report from a validation script: Report

I assume that there might be something wrong with my configuration, but I don't understand why it behaves so inconsistently.

Upvotes: 0

Views: 588

Answers (1)

Brian Chang
Brian Chang

Reputation: 169

Brian from Branch here.

Because you are receiving the data inconsistently, there may be a race condition. We recommend that you read the deep link parameters from the listener method here:

branch.initSession(launchOptions: launchOptions, andRegisterDeepLinkHandler: {params, error in
    if error == nil {
        print("params: %@", params as? [String: AnyObject] ?? {})
    } else {
        print(error)
    }
})

If this is not possible, we also recommend calling getLatestReferringParams(), rather than getLatestReferringParamsSynchronous().

For more information, please visit: https://docs.branch.io/pages/apps/ios/#read-deep-link

Upvotes: 0

Related Questions