Skip to content

Instantly share code, notes, and snippets.

@MattyAyOh
Last active December 26, 2020 05:53
Show Gist options
  • Save MattyAyOh/3d68286766f4f24398e7968695efc5ce to your computer and use it in GitHub Desktop.
Save MattyAyOh/3d68286766f4f24398e7968695efc5ce to your computer and use it in GitHub Desktop.
Deep Linking

Deep Linking Documentation:

Deep Linking:

Deep linking is using a URL to get to a specific piece of content A deep link is a URL that can be parsed by an application, for specific data & app navigation

In iOS there are 2 ways to Deep Link, Custom URL Scheme (deprecated, not advised anymore), and Universal Links

Custom URL Scheme:

Custom URL Scheme is the URL protocol. Default for iOS is to use the Bundle ID

default.bundle.identifier://deeplink.com/navigateHere?data="helloworld"

  • When an app is installed it can register a Custom URL Scheme, iOS will know to open your app when it sees this Scheme
  • Schemes open an attack vector, other apps can use your protocol and send data to your app.
  • Don't allow deleting content or accessing sensitive information
  • Also note that a desktop would not be able to understand what to do with this link.

Universal Link:

A Universal Link uses the HTTP or HTTPS Scheme

https://www.myapp.com/navigateHere?data="helloworld"

  • If a Universal link URL is opened on desktop, it will open a web browser and go to the URL
  • If a Universal link is opened on a phone, it will check associated domains to open an App.
    • If there is no associated domain found, it will open in web browser.
  • Universal Links also use the URL query string to pass pieces of data.
  • A Universal Link will always be able to present data to the user, because it can be opened in a web browser.

Associated Domain:

Connects App<->Website, for interchangable native app & browser experience Current Use Case:

  • Universal Links
  • Shared web credentials
  • Handoff

iOS Apps declare Associated Domains in Entitlements. When the app is installed, iOS will register the associated domains to the App

When a URL is hit on iOS, if a JSON file "apple-app-site-association" exists, iOS will then look at the JSON file for the applinks key/value, to associate your Bundle ID.

Example JSON:
{"applinks":{"apps":[],"details":[{"appID":"XFPHP5CWRG.io.bettylabs.Disco.dev","paths":["NOT /_/*","/*"]}]}}

If declaring an Associated Domain for a Universal Link, you use the applinks domain in your entitlements (www matters):

applinks:<YOUR_URL_WITH_ASSOCIATION_FILE>.

If an association has been made, then when the client opens a link with that domain, it will know there is an association and open your app instead.

Dynamic Link:

Built by Firebase, a Dynamic Link (FDL) is basically a middle-man who can do some fancy things before serving up a Deep Link (Universal Link if Dynamic link is produced through web, Custom URL Scheme if produced programmatically)

  • Links can be shortened for easier readability, and to disguise data being passed from a regular deep link

    • When creating an FDL through the web dashboard, you are creating the short link
    • When creating an FDL programmatically, a short link is randomly generated by a web request
  • Long Links contain the data Firebase uses for the FDL features.

    • When creating an FDL through the web dashboard, the long link is generated from the values you input into the wizard
    • When creating an FDL programmatically, the long link is generated by the values you pass into the DynamicLinkComponents
  • Dynamic Links made more sense when Universal Links didn't exist. FDL long link could contain information for what to do on what platform. Custom URL Scheme if on mobile, and HTTP URL if on desktop.

  • With Universal Links this matters less, however FDL shortening is still very nice

  • Social Media previews can be added to a Dynamic link, so users will see a preview title/image if sent over iMessage or posted on social media

    • Social Media information is stored in the long link itself, meaning you can retroactively change the title/image, and short links will map accordingly
  • FDL also has matchType, which let's your client know how confident it should be that the link is unique for user data update purposes

  • FDL puts the a custom scheme long url into pasteboard, so if the app isn't installed, and when app is installed, the custom scheme handler fires

  • Because a FDL is not actually hosting your web content, the FDL query string contains a link value, which is the Deep Link, and will redirect to that page on desktop.

    • On mobile, because you should have the FDL as a registered associated domain (myapp.page.link), it will open your app and handleUniversalLink will parse the link value so you can handle it like you would if the Deep Link itself was tapped

Short FDL: https://discodev.page.link/XxJbkSBUmxXztoN59

Long FDL Universal Link:https://discodev.page.link/?link=https://discodev.page.link?roomId=00bc98bd-0165-44d6-8fbe-1baed7845bdb&isi=1512014346&ibi=io.bettylabs.Disco.dev

Long FDL Custom URL Scheme: io.bettylabs.disco.dev://google/link/?deep_link_id=https%3A%2F%2Fwww%2Ediscodev%2Epage%2Elink%3FroomId%3D693029f8%2Dc11b%2D44ba%2D9d7f%2Dc6e39d9c8343&match_type=unique

Branch Usage:

  • Sharing Universal Links to app in general

  • Sharing Universal Links that contains Deep Links to rooms in app

  • User Invitee Attribution for installs from an Universal Link

  • Ad Campaign Attribution for installs from an Universal Link

  • Deep Link inside of Push Notification (Follow notif, OrbitInvite notif)

  • Proper social preview render (Title, subtitle, image)

  • Twitter OAuth Callback URL

Desktop Fallback:

  • Fallback to joinlockerroom.com
  • Room Universal Links fallback to joinlockeroom.com/room/{roomId}

iOS Fallback:

  • Universal Link tapped without app installed takes to App Store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment