2

Hello I World like to open PDFs directly in iBooks instead of get them Opened in Safari.

So for example this would be my website: http://www.ti.com/lit/ds/symlink/sn74ls00.pdf

When I Access this link it will Open in my browser. But i Want it to Open automatically in iBooks. Is that possible with some deeplink of something like that?

Salexes
  • 53
  • 1
  • 7

1 Answers1

0

If you want to open a document with iBooks you could do it like this:

let docController: UIDocumentInteractionController =  UIDocumentInteractionController(url: localURL)
if UIApplication.shared.canOpenURL(URL(string: "itms-books:")!) {
        docController.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
}

but UIDocumentInteractionController only supports local files, so you would have to download the PDF file to users device and then you could open it in iBooks. This is really bad approach in opening PDF files because you are saving each file to the device. You should use WebView and open PDF in it. And it's really simple:

let request = URLRequest(url: URL(string: "http://www.ti.com/lit/ds/symlink/sn74ls00.pdf")!)
self.webView.loadRequest(request)
Tuc3k
  • 1,032
  • 9
  • 12