-1

I have an app which picks document using UIDocumentPickerController.

After the document is selected by user I want to pass the URL to that document to as deep link to other app(I know the URL schemes for this app).

I have been able to access the document using UIDocumentPickerController and the 2nd app launches(of which I know the url schemes)

I am passing the url to the file as

let urlfin = URL(string: "appscheme://open?url=\(documenturl.absoluteString)")
self.openUrlinotherapp(urlfin!)

**but I have no idea how to get back the documenturl in scenedelegate of other app that is launched using first app ** I am following a guide and according to that I should be able to access the urlfin in scenedelegate as

extension SceneDelegate {
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        guard let firstUrl = URLContexts.first?.url else {
            return
        }

        print(firstUrl.absoluteString)
    }
}

mimi
  • 1

1 Answers1

0

See if this helps. Based on your question you are probably missed one more scene delegate method, which is

Apple developer documentation for custom url schemes here states the following:

If your app has opted into Scenes, and your app isn’t running, the system delivers the URL to the scene(:willConnectTo:options:) delegate method after launch, and to scene(:openURLContexts:) when your app opens a URL while running or suspended in memory.

You have mentioned that you have implemented one of the above methods which is scene(_:openURLContexts:). This would be called when the app is running or was suspended by the system.

If the app was not running (maybe because the user had killed it using the app-switcher), the method scene(_:willConnectTo:options:), and you should be able to get the deeplink URL in it.

If this helps you please consider marking this as the answer. If this doesn’t help, please post a comment and we can look into it further.