0

I'm trying to use universal links to be detected in a callback in an app developed in SwiftUI. I think all the settings are ok, including the AASA file, capability in the app with applinks: join-domain.com. When I tap in the link https://join-domain.com/something in the notes app it will open my app so I assume is detecting the domain but it never enters in any callback of the appDelegate.

Inside the app I have the following:

import SwiftUI

@main
struct XApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

and in AppDelegate:

class AppDelegate: UIResponder, UIApplicationDelegate, ObservableObject {
    
    func application(_ application: UIApplication,
                         continue userActivity: NSUserActivity,
                         restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
       print("did it entered here?")
    }
}

I run through stackoverflow, nothing worked. In this one thread it mentions the 'Application Scene Manifest' and configurationForConnectingSceneSession. I have nothing of that.

Any ideas?

lopes710
  • 315
  • 1
  • 3
  • 19
  • Try to use onOpenURL – Asperi Aug 11 '22 at 10:30
  • I tried "func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool" right now. Nothing. Do you think I should add a SceneDelegate and configuration in info.plist? – lopes710 Aug 11 '22 at 10:35
  • 1
    I meant view modifier. Like in https://stackoverflow.com/a/72359011/12299030. – Asperi Aug 11 '22 at 10:38
  • You saved my ass with that answer. It's working, I'm going to give accepted answer. Thank you very much @Asperi! – lopes710 Aug 11 '22 at 10:48
  • Well it seems I can't accepted an answer as a comment. Upvoted it though. Btw, why is not working on restorationHandler callback? – lopes710 Aug 11 '22 at 11:03
  • I also found Asperi's answer to be the only working one of many. The docs specifically say this modifier handles Universal Links. It doesn't say what *else* might come in. – Andrew Duncan Aug 09 '23 at 05:06

0 Answers0