Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
AlanYeats's avatar
AlanYeats
Honored Guest
2 years ago

Open Store Page from Unity app

I've trying to add a deep link to the store page to another app (from a demo version of the game to the main version store page). I have something working but it seems to only work every second time and I'm totally lost to why. 


This is the code I'm using to trigger the opening of store 

        AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
        AndroidJavaObject packageManager = currentActivity.Call<AndroidJavaObject>("getPackageManager");
        AndroidJavaObject i = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", "com.oculus.vrshell");
        i.Call<AndroidJavaObject>("setClassName", "com.oculus.vrshell", "com.oculus.vrshell.MainActivity");
        i.Call<AndroidJavaObject>("setAction", "android.intent.action.VIEW");
        i.Call<AndroidJavaObject>("putExtra", "uri", "/item/" + APP_ID);
        i.Call<AndroidJavaObject>("putExtra", "intent_data", "systemux://store");
        currentActivity.Call("startActivity", i); 

 
Comparing logs between when it does work and when it doesn I really can't see anything either.


Has anyone got any thoughts on this or another way around this?