Can we test iOS Universal Links / Deep Links without apple-app-site-association (AASA)?

Bharat Dodeja picture Bharat Dodeja · Nov 9, 2017 · Viewed 7.1k times · Source

I have implemented universal links into my app but for reason, AASA file is not going to be uploaded on server for now.

Answer

Noam picture Noam · Jan 24, 2018

Yes you actually can!

You can test you app's response to a deep link without actually implementing the remote side by calling this function from terminal:

$ xcrun simctl openurl booted 'YOUR_LINK_HERE'

This will trigger the following callback in your app's appDelegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool

...which is exactly the behavior you should expect from a deep link.

just don't forget to actually have the simulator up ;-)

As for universal links - the appDelegate callback is slightly different, but its a very small mental leap:

func application(_ app: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
        if let url = userActivity.webpageURL {
            // parse the url and decide how to handle the universal link

        }
    }
    return true
}