Has anyone else run into an error where a custom URI such as "myapp://test" will open the app with a urlscheme "myapp" but won't pick up the "test" portion of the URI? The code I am using below is in the AppDelegate.swift file:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
@Binding var _: String = url.absoluteString
print(url.absoluteString)
Controller.message = url.absoluteString
return true
}
The Controller is a struct with a static var "message" that I am using in a View. Nothing is printed out when I pass "myapp://test", but the app opens even if it is close.
This does work, however, if I place this code in the SceneDelegate:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let url = URLContexts.first?.url{
@Binding var _: String = url.absoluteString
print(url.absoluteString)
Controller.message = url.absoluteString
print(Controller.message)
}
}
This will print the correct URI, but if I try to use this URI when the app is closed out it will open, but no information will be passed.
Is this a Swift 5.1 problem? Every tutorial/video I have found online uses the first code snippet in the AppDelegate file and I have triple checked to make sure it is the same. Everything is the same from the tutorials, but I'm still not getting any results.
Thanks.
Matt