Search code examples
ioshttp-redirectios9deep-linkingios-universal-links

iOS 9 - Redirect to Universal Link not working


Let's assume I have two domains - example.com and ex.co

On example.com I've configured Universal Links for iOS 9 and my apple-app-site-association file is unsigned and looks like this:

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "JUSTEXAMPLE.com.example.app",
        "paths": [
          "link/example*"
        ]
      }
    ]
  }
}

My application also has com.apple.developer.associated-domains entry - applinks:example.com

Everything works fine if you click example.com/link/example?param=value (app opens)


But I want to do next thing:

  1. User taps ex.co/abc
  2. User gets 301 header (permanent redirect) with example.com/link/example?param=value as location
  3. App opens and everyone is happy

First and second execute fine, but at third one I only get blank page with little banner at the top that says something like 'Would you like to open this page in app?' and big 'OPEN' button

PS: both websites are using valid HTTPS

PPS: I can't make apple-app-site-association for ex.co, cause it's going to have many short links, that will redirect to different pages on example.com for different apps


Solution

  • Safari on iOS (9...who knows what will happen next week!) only responds to Universal Links when the user actually takes a specific action to open the URL. That's a slight generalization, but basically a good guideline. A 301 redirect doesn't qualify, so that's why your app isn't opening up.

    A workaround you could use (which we employ at Branch.io) is to use a unique path segment for each app on the ex.co domain (instead of ex.co/abc, you'd have ex.co/uniqueappid/abc). Then you can trigger Universal Links based on uniqueappid for each app separately.