Quantcast
Viewing latest article 18
Browse Latest Browse All 86

Answer by Vandarthul

Hey @Giusort , I can offer you a way to do it in Android but you will still need to find a way to do it in iOS. You can wrap it up in [Platform Dependent Compilation][1] like #if UNITY_ANDROID and use that way. Try this: public void LaunchApp(string package, string storeLink = null) { bool fail = false; string bundleId = package; // your target bundle id AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic("currentActivity"); AndroidJavaObject packageManager = ca.Call("getPackageManager"); AndroidJavaObject launchIntent = null; try { launchIntent = packageManager.Call("getLaunchIntentForPackage", bundleId); } catch (System.Exception e) { fail = true; } if (fail && storeLink != null) { //open app in store Application.OpenURL(storeLink); } else //open the app ca.Call("startActivity", launchIntent); up.Dispose(); ca.Dispose(); packageManager.Dispose(); launchIntent.Dispose(); } package is bundleIdentifier of app, such as "com.facebook.katana" and optional parameter is the store link of the app in case the app is not found in device, you can leave it as null and it will only try to open the app if it exists. [1]: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html

Viewing latest article 18
Browse Latest Browse All 86

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>