Post

Replies

Boosts

Views

Activity

Custom URL opening app, but not passing information
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
2
2
4.9k
Oct ’19
Display Binding<String> inside of SwiftUI Text element
I'm trying to display the value of a Binding&lt;String&gt; inside of a Text() element in SwiftUI.A brief example would be:struct ContentView: View { @State var textValue: String = Controller.message var body: some View { Text($textValue) } }The error I am running into is:Initializer 'init(_:)' requires that 'Binding&lt;String&gt;' conform to 'StringProtocol'This seems like a very obvious problem that I just don't understand. Any help would be appreciated.Thanks.Matt
5
2
16k
Oct ’19