Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Application.OpenURL causing application on WP8 phone to stop

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

  1. Memosis


    Jul 23, 2013
    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


    Jun 12, 2013
    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.

  3. DanielSan


    Nov 20, 2012
    Create a static class in Unity with a static event...

    Code (csharp):
    2. public static class WP8Statics
    3. {
    4.      public static event EventHandler OpenUrlHandle;   
    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):
    2. // Constructor
    3. public MainPage()
    4. {
    5.      ...
    6.      WP8Statics.OpenUrlHandle += WP8Statics_OpenUrlHandle;
    7. }
    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.