2

I have a pages document in my iOS applications bundle. I'd like to open this document directly with Apple's Pages iOS app. I know I have to add schemes in info.plist under LSApplicationQueriesSchemes. But i'm really just guessing what I should add. I have tried "pages"//" and "com.apple.pages://" and neither of these work.

If I try MS Word, it works!

UIApplication.shared.open(URL.init(string: "word://hello.doc")!, options: [: ]) { (result) in
    print(result)
}

When I try:

UIApplication.shared.canOpenURL(URL.init(string: "pages://hello.pages")!)

I get the following error:

canOpenURL: failed for URL: "pages://hello.pages" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

When i google this error code, I find it means kLSApplicationNotFoundErr. Is it possible to open a .pages document this way? Or do u have to use UIDocumentInteractionController?

Stickley
  • 4,561
  • 3
  • 30
  • 29
NSCaleb
  • 135
  • 4
  • Perhaps this: https://stackoverflow.com/questions/7156932/open-file-in-another-app – Phillip Mills Jan 28 '20 at 19:42
  • Thank you, i got working using UIDocumentInteractionController. but i was hoping to avoid the steps where user has to save to files and select open with pages. I want the pages document to just launch in pages – NSCaleb Jan 28 '20 at 19:46
  • @NSCaleb I can do the same. But it doesn't work for Word since it's not shown in UIDocumentInteractionController – Bagusflyer May 04 '23 at 08:12

1 Answers1

0

The code to get a button to link to a URL is...

@IBAction func linkTapped(_ sender: UIButton) {
    if let url = NSURL(string: 
"https://www.radiusapp.co/blog/end-user-license- 
agreement"){
        UIApplication.shared.open(url as URL)
    }
}

Since you're technically linking to URL, I believe that this should work. If not, would linking to a Google doc be an option?? I hope this helps!

Kasey
  • 374
  • 2
  • 12
  • ah thanks for your help, but what i really need is the scheme to open pages ie something along the lines of ://myDoc.pages – NSCaleb Jan 30 '20 at 22:10