HomeiOS Developmentios - Associating a Scene with an exterior occasion

ios – Associating a Scene with an exterior occasion


I am engaged on an iPadOS SwiftUI app supporting a number of scenes, every Scene responds to a selected method during which the app was launched. If app was launched by tapping an related file or a deep hyperlink (customized URL), then, the URLHandlerScene is invoked. If app was launched by QuickAction (lengthy faucet on the app icon), then one other Scene is invoked and many others. Every Scene has a function and responds to a selected launch.
However after defining handlesExternlEvents(matching:) scene modifier, the URLHandlerScene is launched when consumer faucets the related file or the app’s Deeplinks was invoked.

@major
struct IOSSwiftUIScenesApp: App {
    
    var physique: some Scene {
        DefaultScene()
        
        URLHandlerScene()
            .handlesExternalEvents(matching: ["file://"]) // Launched by an related file
            .handlesExternalEvents(matching: ["Companion://"]) // Launched by Deeplink.
        
        // Different scenes
    }
}
 
struct URLHandlerScene: Scene {
 
    @State personal var inputURL: URL // Retailer the incoming URL
    
    init() {
        self.inputURL = URL(string: "Temp://")!
    }
    
    var physique: some Scene {
        WindowGroup {
            URLhandlerView(inputURL: $inputURL)
                .onOpenURL(carry out:  Thread.present = %@", String(describing: Thread.present)))
                    log("fileURL = " + String(describing: fileURL))
                    
                    inputURL = fileURL
                )
        }
    }
}

As proven above, I’ve connected handlesExternalEvents(matching:) modifier with “file://” for the affiliate file launch and “Companion” is my customized URL scheme. As per the scene matching guidelines documented right here, URLHandlerScene ought to get launched, however each time I launch the app utilizing related file or ‘open’ a Deeplink, the DefaultScene is all the time launched.

What’s lacking right here?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments