Vlad
Vlad

Reputation: 1919

iOS 12.1.2 branch.io Universal Links open app, but no data is present

I am trying to implement deep-links via branch.io for an iOS app (Swift 4.2). I have integrated the iOS SDK exactly as outlined in the branch docs. To test the integration, I ran the branch.io universal link validation script and it passed successfully.

What's not working for Universal Links: Clicking on a deeplink from 'Notes' or 'Messages' does open the app, but no data is passed. Branch reports a completely blank url (example.app.link?%24identity_id=611647344982868361) instead of (example.app.link/hj86HlvvMk2?%24identity_id=611647344982868361), when looking at the debug logs. This is the same as just opening the app manually without a deeplink. No data is available via the deferred deeplink functionality either.

Using URI schemes instead of Universal Links: If I turn Universal Links OFF via the branch.io link settings dashboard, then all urls open in the browser, without any prompt to open the app. However, when I open the app manually, the deeplink data is available on start (via the deferred link functionality).

Other attempts: Adding $uri_redirect_mode: 2 to the link data to force the app open didn't really change anything. The only thing different is that for URI schemes, it displays an error in Safari before redirecting to the $fallback_url. I also tried re-installing the app fresh, clearing Safari cache and cookies, with no success.

I'll also mention that there should be nothing wrong with the deeplinks themselves. On Android, the same deeplinks work perfectly.

Neither method is able to open the app with the deeplink data immediately available. Are there any other options to make this work?

UPDATE: The URI and universal links were separate issues. We got URI to work by double checking our URI scheme (it was incorrect). For universal links, there might be a slight error in Branch's documentation for Swift 4.2. See my answer for a solution.

UPDATE 2019-02-05: Branch documentation has been updated for Swift 4.2. Everything is working nicely.

Upvotes: 2

Views: 4053

Answers (2)

Vlad
Vlad

Reputation: 1919

UPDATE 2019-02-05: Branch documentation is now up-to-date for Swift 4.2.


ORIGINAL ANSWER:

Ok so we found a solution to the universal links not working. I believe the Branch documentation is not up to date for Swift 4.2. When handling universal links, the func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) protocol should use [UIUserActivityRestoring] instead of [Any] for the restorationHandler param. See below:

Current Branch documentation (not working):

func application(_ application: UIApplication,
                 continue userActivity: NSUserActivity, 
                 restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
  // handler for Universal Links
  Branch.getInstance().continue(userActivity)
  return true
}

The above function also causes a warning in XCode. Auto-fixing it won't work, it will just convert it to a private function and not to the correct protocol.

Correction (working):

func application(_ application: UIApplication, 
                 continue userActivity: NSUserActivity, 
                 restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
  // handler for Universal Links
  Branch.getInstance().continue(userActivity)
  return true
}

Upvotes: 10

Jackie Choi
Jackie Choi

Reputation: 432

Jackie from Branch here.

Can you make sure to go through the below checkpoints?

If you continue to see link data not passing, can you please email your Branch app ID, link(s) you’re using to [email protected] so that our team can do a deep-dive?

Upvotes: 1

Related Questions