BranchIO Universal Link iOS data only works when long pressing and selecting open with

Viewed 238

I have implemented BranchI to handle universal links, I have been through the documentation and as far as I can everything should work.

The behaviour I get is that when I long press and select open with 'myApp' from the menu all is fine and works as expected.

However if I simply click the link, the app will open as expected but the Branch Universal object does not have the data that the the link should be passing through. I have emailed Branch support but they have not replied for days.

Would appreciate help from anyone who has also experienced this issue.

I am running an app deployed to iOS14 using SwiftUI , but I do have an appdelegate, where I am calling the Branch Universal object in UIApplicationDidFinishWithOptions.

Many thanks

2 Answers

In your app under Signing & Capabilities you have to add the domain you want to open in your app as Associated Domain. So you add the Associated Domain capability and add your domain as applinks (eg "applinks:casperzandbergen.nl").

This lets iOS know your app wants to handle those links. But iOS also asks the server if an app is allowed to handle that domain so no one else could make an app to hijack traffic to my domain.

To let iOS know an app is allowed to open urls from your domain you have to host an entitlements file on your server with details of what apps can open exactly which paths.

Specifically you host your entitlement json at https://<the domain in your capabilities>/.well-known/apple-app-site-association

For example I have this hosted:

{
  "applinks":{
    "apps":[],
    "details":[
      {
        "appID":"<app id including team id>",
        "paths":["/*"]
      }
    ]
  }
}

And this works but the new syntax described by apple is different:

https://developer.apple.com/documentation/xcode/supporting-associated-domains

Please make sure that you added Associated Domain capability In your app under Signing & Capabilities you have to add the domain you want to open in your app as Associated Domain.

For Example

applinks:www.amazon.com

This is enough from client side app. But some apps will try to steal traffic of may websites by this dynamic links, so apple required to add apple-app-site-association to verify the server.

Associated domains establish a secure association between domains and your app so you can share credentials or provide features in your app from your website.

Host your apple domain entitlement json at https://yourdomine.com/apple-app-site-association

The following JSON code represents the contents of a simple association file.

{
"applinks": {
    "details": [{
        "appIDs": ["ABCDE12345.com.example.app", "ABCDE12345.com.example.app2"],
        "components": [{
                "/": "/buy/*",
                "comment": "Matches any URL whose path starts with /buy/"
            }
        ]
    }]
},
"webcredentials": {
    "apps": ["ABCDE12345.com.example.app"]
},

"appclips": {
    "apps": ["ABCED12345.com.example.MyApp.Clip"]
}
}

You can see apple-app-site-association in Netflix and Youtube Here.

Apple documentation for associated domains Click Here

You will get a call in func scene(_ scene: UIScene, continue userActivity: NSUserActivity){} in or in AppDelegate corresponding method once you successfully integrated it.

Related