Error during trying opening file in predefined app

94 Views Asked by At

I'm trying to open a file directly in the predefined app. I have this code running but I keep getting an error...

func pushFile(_ destination: URL) {
    let appURL = destination
    DispatchQueue.main.async {
        if UIApplication.shared.canOpenURL(appURL) {
            if #available(iOS 10.0, *) {
                UIApplication.shared.open(appURL, options: [:], completionHandler: nil)
            }
            else {
                UIApplication.shared.openURL(appURL)
            }
        } else {
            print("ERROR")
        }
    }
}

In info.plist I also added:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>file</string>
</array>

When I run the app from my iPhone (not inside the simulator), I get this error:

SuperApp[24883:7866592] -canOpenURL: failed for URL: "file:///private/var/mobile/Containers/Data/Application/7F14B348-8BE5-4A26-94DA-D9163634D8BA/tmp/port.lrtemplate" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

The needed app is installed on the device.

1

There are 1 best solutions below

0
On

You are trying to make an app open a file by throwing a file URL at the system. You can’t do that.