- Home /
iOS can't open local file with Application.OpenURL()
Hello,
I'm trying to open a PDF file downloaded to Application.persistentDataPath but the file wont open. I know the file is there, but Application.OpenURL() just does nothing. I have tried with:
Application.OpenURL(Application.persistentDataPath + "downloadedFile.pdf");
Application.OpenURL("file://" + Application.persistentDataPath + "downloadedFile.pdf");
Application.OpenURL("file:///" + Application.persistentDataPath + "downloadedFile.pdf");
From the Editor I have no problems at all, it is just when I build to iOS. I'm also having problems with Android builds, but I need to solve it first for iOS.
What is the correct way to open a local file? Am I missing anything?
Hello there,
I don't know much about iOS unfortunately, however I'd recommend building your paths differently. Either using System.IO.Path.Combine(Application.persistentDataPath, "downloadedFile.pdf")
or Application.persistentDataPath + "/downloadedFile.pdf"
($$anonymous$$d the slash).
I hope that helps!
~Cheers, LegendBacon
Yes, I wrote some sample code for fast understanding, but the way I'm building the path is with Path.Combine: string filePath = Path.Combine(Application.persistentDataPath, fileName); Thank you anyway.
Answer by blocovin · Jul 06, 2021 at 12:28 PM
I know this is an old topic but you can find explication in the documentation: https://docs.unity3d.com/ScriptReference/Application.OpenURL.html
iOS: Application.OpenURL cannot be used for opening local files.
Your answer
Follow this Question
Related Questions
Open a PDF on Android and iOS 2 Answers
Opening PDF on Mobile (iOS/Android) 1 Answer
PDF Generation in Unity for Android and iOS 0 Answers
how many computers does the android basic license cover 2 Answers
Embedded app in unity 0 Answers