Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda