Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

214
Views
Universal Links from Closed App not working

I have my app set-up to handle Universal links. We handle the retrieval of the URL, and the navigation given the URL inside of this function:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        guard NSUserActivityTypeBrowsingWeb == userActivity.activityType, let url = userActivity.webpageURL else {
            return false
        }
        // Do navigation to correct page based on URL
        return true
    }

This works perfectly for us when our app was previous running in the background, and a universal link is tapped.

However, when I kill the app completely and click on a universal link, this function doesn't appear to be running and so it doesn't handle the universal link at all, it just brings the user to the home tab.

I've tried grabbing the URL in application(didFinishLaunchingWithOptions:) and application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) but neither of those seem to get called as well.

Does anyone have any ideas on this?

Thank you!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Swift 5 IOS 14 When app is terminated use

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Get URL components from the incoming user activity.
        guard let userActivity = connectionOptions.userActivities.first,
              userActivity.activityType == NSUserActivityTypeBrowsingWeb,
              let incomingURL = userActivity.webpageURL
        else { return }
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            LinkHandler.sharedInstance.handleLink(url: incomingURL)
        }
        guard let _ = (scene as? UIWindowScene) else { return }
    }
over 4 years ago · Santiago Trujillo Report

0

You can check in

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

You can get the URL by checking connectionOptions.userActivities (it's a Set<NSUserActivity>).

Get the URL from webpageURL Here's the example:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    for userActivity in connectionOptions.userActivities where userActivity.webpageURL != nil {
        // call your universal link handler here
    }
}

I hope it can help you fix your problem.

over 4 years ago · Santiago Trujillo Report

0

On application(didFinishLaunchingWithOptions:) url is inside an options. Please test it again.

Apple docs: launchOptions A dictionary indicating the reason the app was launched (if any). The contents of this dictionary may be empty in situations where the user launched the app directly. For information about the possible keys in this dictionary and how to handle them, see Launch Options Keys.

https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622921-application

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!