Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

iOS > SPIKE > App Link Implementation #169

Open
corblng opened this issue Jul 12, 2023 · 0 comments
Open

iOS > SPIKE > App Link Implementation #169

corblng opened this issue Jul 12, 2023 · 0 comments
Assignees
Labels

Comments

@corblng
Copy link
Collaborator

corblng commented Jul 12, 2023

Universal Links in iOS

Steps

  1. Enable Associated Domains on our App Identifier

  2. Enable Associated Domains in Xcode in Signing and Capabilities tab, add domains there. Add the domain and subdomain. Prefix these with applinks:. This will tell the app that we should
    download the JSON called "aasa"

  3. Write AASA JSON file according to Apple's requirements.

  4. Backend team adds this page at the desired url.

  5. Test Connection. Make sure app is opening when defined url is hit. Test without app installed for a fallback

  6. iOS link handling implementation. Within the App Delegate OR the Scene Delegate, we need to add code to handle the incoming links. We get back an NSUserActivity.
    Within the object lies the incoming URL. This is the specific delegate method with example implementation:

func application(_ application: NSApplication,
                     continue userActivity: NSUserActivity,
                     restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool
{
    // Get URL components from the incoming user activity.
    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
        let incomingURL = userActivity.webpageURL,
        let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
        return false
    }

    // Check for specific URL components that you need.
    guard let path = components.path,
    let params = components.queryItems else {
        return false
    }    
    print("path = \(path)")
}

The scene delegate's version is:

func scene(_ scene: UIScene, willConnectTo
           session: UISceneSession,
           options connectionOptions: UIScene.ConnectionOptions) {}

Requirements

  • AASA (Apple App Site Association) - It is the way in which we deeplink the user into the App using urls. It's a JSON which looks something like this:
"applinks": {
    "apps": [], 
    "details": {
        "com.dsnpwallet.wallet" : {
            "paths": [
                "/meWeLogin", 
                "/settings"
            ]
        }
    }
}

Validator located here: https://branch.io/resources/aasa-validator/

  • URL Requirements

The AASA file should be hosted at the root of the url.

Example:

https://www.amplica.io/apple-app-site-association`
  • hosted over HTTPS
  • No suffix
  • mime type will be application/json

Once users install the app, the AASA file is downloaded and cached.

Sources:
https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app
https://developer.apple.com/documentation/xcode/supporting-associated-domains
https://www.youtube.com/watch?v=oJaxHabyp-4
https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html

@corblng corblng self-assigned this Jul 12, 2023
@corblng corblng added the spike label Jul 12, 2023
@BenJamminnn BenJamminnn self-assigned this Jul 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants