Question by
umerPC · Apr 10, 2018 at 08:41 AM ·
androidiospdffilesystemrestrictions
open pdf on IOS
Hi,
I am currently struggling to find a way to open Pdfs on IOS.
any suggestions?
I am currently using this code for android:
public void OpenPDFAndroid(string filename) // works for android { using (AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent")) using (AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent")) { //storage/emulated/0/Android/data/com.app.umer/files/Documents/pdf string finalPath = "file://" + Application.persistentDataPath + Path.DirectorySeparatorChar + "Documents" + Path.DirectorySeparatorChar + "pdf"+ Path.DirectorySeparatorChar + filename;
try
{
using (intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_VIEW")))
using (intentObject.Call<AndroidJavaObject>("setType", "application/pdf"))
using (AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"))
using (AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", finalPath))
using (intentObject.Call<AndroidJavaObject>("setData", uriObject))
// finally start application
using (AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"))
{
AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Open In");
currentActivity.Call("startActivity", jChooser);
}
}
catch (Exception e)
{
Debug.LogError(e);
debug.text = e.ToString();
}
}
}
Comment