Question: Implemented every kind of step exactly as described. App open successfully but, no URL data fetched.

Implemented every kind of step exactly as described. Send links from gmail and the links open the app so yes, it works. 
BUT here is 2 problems

1- How on earth can I debug and print the app since you have to close the app and break the connection between the app and Xcode debugger to reopen the app from a universal link !!. It's frustrating, If I keep the app running in the background for the debugger, the universal link simply re- activates the app state to the foreground but then the function 
func application(\_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: .... 

is not invoked

2- I always get "userActivity?.activityType" = nil no matter what.

```
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 if userActivity?.activityType == NSUserActivityTypeBrowsingWeb {
            let univrsalLinkURL = userActivity?.webpageURL!.absoluteString
//            remoteParmNumTxt = univrsalLinkURL!
            print(univrsalLinkURL!)
        }
return true
}

```

Should be able to capture url and url data
iOS 12.4
Xcode 10.3

Answer: 
So after many trials trying to get the app run and fetch url data
It seems like something has changed in iOS where "userActivity" will always be nil unless you get it from an overload from "application" function

so @Simon McLoughlin solution did solve half of the problem by suggesting to use this function

```
func application(_ application: UIApplication,
             continue userActivity: NSUserActivity,
             restorationHandler: @escaping ([Any]?) -> Void) -> Bool

```

But this overload gets triggered "Only" when the app is already running in the background.

Well, the only solution worked for me to get the app to fetch url data if the app is opened by a universal link while its not running is the following

```
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

    let activityDictionary = launchOptions?[UIApplication.LaunchOptionsKey.userActivityDictionary] as? [AnyHashable: Any] ?? [AnyHashable: Any]()
    let activity = activityDictionary ["UIApplicationLaunchOptionsUserActivityKey"] as? NSUserActivity ?? nil

    if let finalString = activity?.webpageURL?.absoluteString {
        remoteParmNumTxt = finalString
    }

    print("dic",activity?.webpageURL)
    print("yesssss loaded from url")

    return true
}

```

If you try to use the "userActivity" directly it would give you nil value no matter what

So, apple documentation sucks
IOS version > 13.0

only running app (from universal link)

SceneDelegate.swift

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

    if let activity: NSUserActivity = connectionOptions.userActivities.first,
       let url: URL = activity.webpageURL {
          print(url.absoluteString)
    }

    ...
}

```