Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Application.OpenURL causing application on WP8 phone to stop

Discussion in 'Windows' started by Memosis278978978, Jul 23, 2013.

  1. Memosis278978978

    Memosis278978978

    Joined:
    Jul 23, 2013
    Posts:
    12
    We call Application.OpenURL when user clicks banner in our game or when we want to display ratings in store. It works on all platforms we used so far (Win x86, Mac, Android, iOS). On WP8 phone the game simply stops. We will appreciate your experience and tips on debugging these kinds of problems.
     
  2. BFS-Kyle

    BFS-Kyle

    Joined:
    Jun 12, 2013
    Posts:
    838
    I believe Application.OpenURL is not yet implemented in WP8, so you can't use it (seems to quit the game when it gets called). You will have to handle this yourself after exporting the build into Visual Studio and then edit the project. There is an example of how to do this in the Windows Phone 8 Beta group if you have access.

    The other alternative is to grab one of the Windows Phone 8 plugins - currently there are two that I know of, one is my own called BFS WP8 Goodies which has functionality to open URL's among other things, and the other is called RobotoWP plugin for Windows Phone which from the looks of it (I haven't purchased this plugin) can also handle opening URL's.

    -Kyle
     
  3. DanielSan

    DanielSan

    Joined:
    Nov 20, 2012
    Posts:
    5
    Create a static class in Unity with a static event...

    Code (csharp):
    1.  
    2. public static class WP8Statics
    3. {
    4.      public static event EventHandler OpenUrlHandle;   
    5.    
    6.      public static void FireOpenUrl(string url)
    7.      {
    8.           if (OpenUrlHandle != null)
    9.           {
    10.                OpenUrlHandle(url, null);           
    11.           }
    12.      }
    13. }
    Build in Unity to create a VS solution. Open the solution and then attach the native browser functionality to the method you created in MainPage.xaml.cs...

    Code (csharp):
    1.  
    2. // Constructor
    3. public MainPage()
    4. {
    5.      ...
    6.      WP8Statics.OpenUrlHandle += WP8Statics_OpenUrlHandle;
    7. }
    8.  
    9. void WP8Statics_OpenUrlHandle(object sender, EventArgs e)
    10. {
    11.        Microsoft.Phone.Tasks.WebBrowserTask wbt = new Microsoft.Phone.Tasks.WebBrowserTask();
    12.        wbt.Uri = new Uri((string)sender);
    13.        wbt.Show();
    14. }
     
    Last edited: Aug 5, 2013
    jdrostov likes this.