QLPreviewController not opening links embedded in PDF

Hi,


we are using a QLPreviewController in our App to preview PDF documents.

For some reason the Links embedded in the PDF document are not opened in safari, even though the AlertView "Leave APPNAME and open this link?" is shown and confirmed.


In our logs I see the following

+[LSApplicationProxy applicationProxyFor*] is not a supported method for getting the LSApplicationProxy for the current process, use +[LSBundleProxy bundleProxyForCurrentProcess] instead.


I also added the QLPreviewControllerDelegate to handle the callback shouldOpenUrl - however this callback is never fired

func previewController(_ controller: QLPreviewController, shouldOpen url: URL, for item: QLPreviewItem) -> Bool {
     return true;
}

Replies

Do you display the pdf in a WKWebView ?

I have a similar issue and the PDF is not displaying in WKWebview (only with a PDF title and size on a gray background), but it works in UIWebview.


Do you have any insights to this?


Thanks

We have the very same setup. When I implement QLPreviewControllerDelegate shouldOpen

    func previewController(_ controller: QLPreviewController, shouldOpen url: URL, for item: QLPreviewItem) -> Bool 
        debugPrint("The user clicked on link \(url.absoluteString) in opened document")
        DispatchQueue.main.async {
            UIApplication.shared.open(url, options: [:])
        }
        return true
    }

then I can open the link by explicitly opening the link with UIApplication.

But that's not the way we want it to, because the AlertView is still open and awaits my reaction (-> YES).


But at least it shows, that the delegate works and gets the correct url.


Documentation tells us:
If you return

true
, the Quick Look preview controller invokes the
openURL(_:)
method on the
UIApplication
object, sending it the value of the
url
parameter. If you return
false
, the
openURL:
method isn’t invoked.



That means, we have a problem invoking implicitly openURL(_:) on the UIApplication object. Maybe because of some missing rights....