0

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.

Cristian
  • 57
  • 1
  • 8

1 Answers1

0

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

matt
  • 515,959
  • 87
  • 875
  • 1,141