Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

open local file on IOS with Application.OpenURL

Discussion in 'iOS and tvOS' started by pragmascript, Jan 25, 2018.

  1. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    107
    Hey I am trying to open an .ics file on IOS but it doesn't seem to do anything.
    It works fine on android but on IOS I am out of luck.

    My code looks like this:

    Code (CSharp):
    1.  
    2.         var path = Application.temporaryCachePath;
    3.         var filename = System.IO.Path.Combine(path, "termin.ics");
    4.         System.IO.File.WriteAllText(filename, sb.ToString());
    5. #if UNITY_ANDROID
    6.         Application.OpenURL(filename);
    7. #endif
    8. #if UNITY_IOS
    9.         Application.OpenURL("file://" + filename);
    10. #endif
    11.  
    Maybe someone has an idea what could be wrong. (I also tried `www.EscapeURL()` but this didn't help either)
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    www.EscapeURL() isn't right way to escape URI. Try:
    new System.Uri(filename).AbsoluteUri
     
  3. pragmascript

    pragmascript

    Joined:
    Dec 31, 2010
    Posts:
    107
    Thanks for the answer. Unfortunately OpenURL still does nothing on IOS. It works fine on the Desktop (Windows / MacOS) and Android though.