Reputation: 111
I'm currently testing universal link on my app. I have uploaded apple-app-site-association, edit my app's entitlements file. The app can be opened when I click the link(say: domain.com/test/id12345) from the Note.
However, it only opens the app, but from the app itself. the delegate method to capture the info is not be called.
the project is a SwiftUI project with iOS 13, with life cycle of UIKit App Delegate.
Under AppDelegate.swift:
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
print("Test: this is never called:\(userActivity)")
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
return false
}
return false
}
Is anybody know how to detect the universal link clicked? How should I debug it, the link does open the app but I can't handle the rest.
Upvotes: 3
Views: 1449
Reputation: 21
If your application supports multiwindows or you didn't destroy SceneDelegate you need to implement this method in SceneDelegate
// SceneDelegate.swift
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
_ = LoginManager.shared.application(.shared, open: URLContexts.first?.url)
}
Upvotes: 2