Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

After using Application.OpenURL(), is it impossible to get back to the Unity app?

Discussion in 'iOS and tvOS' started by diegoleao, Jul 20, 2011.

  1. diegoleao

    diegoleao

    Joined:
    Oct 27, 2006
    Posts:
    23
    Hi! I'm creating an iPad app that uses Application.OpenURL to open a dynamic webpage that shows a list of PDF files. The problem is that after using Application.OpenURL, a Safari window replaces my Unity app, and there is no button to go back or close the window.

    Is it impossible to get back to the Unity app after using this method? If so, is there another way to show an html page without closing my app?

    OBS: note that it doesn't help to just "fetch" the contents of the page, because the pdf files are opened in new Safari windows anyway.

    Some context (for the curious only): I'm creating a medical software here in Brazil and I'm using Unity to show a list of drugs (legal ones!). Each of those drugs has one or more "drug description leaflets" that can only be obtained from "Anvisa" website, a regulatory agency. I query the website with the drug's name and get an html with a list of pdfs.
     
    Last edited: Jul 20, 2011
  2. diegoleao

    diegoleao

    Joined:
    Oct 27, 2006
    Posts:
    23
    Anyone?
     
  3. nocanwin

    nocanwin

    Joined:
    May 7, 2009
    Posts:
    176
  4. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I would like to know this as well.
     
  5. diegoleao

    diegoleao

    Joined:
    Oct 27, 2006
    Posts:
    23
    Thanks @nocanwin! I'll look into this plugin. Anyone has any other way to show a browser inside Unity iOS?
     
  6. BoredKoi

    BoredKoi

    Joined:
    Jun 18, 2009
    Posts:
    162
    Hi DeigoLeao -- take a look at this thread...I would imagine (?) a UIWebView would play nice with either approach, however I haven't tested it.
     
  7. squidbot

    squidbot

    Joined:
    Jan 4, 2011
    Posts:
    128
    You'll need to use a custom URL scheme. This will involve patching the application delegate and making some additions to the apps plist. This can all be done via script in Unit's post process build step if you don't want to do it by hand every time you build the Xcode project. You'd probably need to have your own web code with the site you were looking at in an iframe so you could have your own button to redirect to your URL scheme.

    See here for info on custom URL schemes: http://developer.apple.com/library/...uide/StandardBehaviors/StandardBehaviors.html

    All that said, Prime31 offers the Etcetera plugin which implements a WebView that is part of your application rather than opening a separate browser and then needing URL schemes to open your app back up. This might be an easier choice. You could code this up yourself, but I'm guessing his price is cheaper than your time.
     
    levlaj likes this.
  8. TheCircadian

    TheCircadian

    Joined:
    Jul 30, 2016
    Posts:
    15
    Is there any standard approach that doesn't only work for Apple? I'm looking to do this on the Quest. Thanks