How to open Appstore in Unity for iOS and Android? And how to not leave app when doing it?
You can just download my NativeAppstore.unitypackage, and import it into your project. (I haven’t wrote about the nitty gritty of creating Unity plugins yet, so this post will not go into the iOS or Android codes)
You can take a look at AppstoreTestScene.cs:
using UnityEngine;
using System.Collections;
public class AppstoreTestScene : MonoBehaviour
{
public string m_appID_IOS = “840066184“;
public string m_appID_Android = “com.orangenose.noone“;
public void OnButtonClick(string buttonName)
{
if(buttonName == “ViewApp“)
{
if(!Application.isEditor)
{
#if UNITY_IPHONE
AppstoreHandler.Instance.openAppInStore(m_appID_IOS);
#endif
#if UNITY_ANDROID
AppstoreHandler.Instance.openAppInStore(m_appID_Android);
#endif
} else
{ Debug.Log(“AppstoreTestScene:: Cannot view app in Editor.“);
}
}
}
}
Pass your iOS and Android ID to AppstoreHandler (which is a Singleton), and it will be in charge of opening your Appstore for you.
For iOS, I use SKStoreProductViewController when its available, and if it’s not it defaults back to OpenURL (that unfortunately will pop you out of your app).
For Android, I use Uri Intent.
They are modal views, which means that it will not pop you out of your app. For iOS, just click Cancel, while for Android, just click Back Button to go back to your Unity scene.
When can you use this? For example, you want your players to rate your app, or you want to cross sell another of your apps.
All the codes are available on Github: https://github.com/purplelilgirl/Unity-NativeAppstore
By the way, the Apps shown in the tutorial is Toughest Game Ever 2, which is available for iOS and Android, and I’m part of the team that made the game. So please check it out, download, show us some love?
Good job, please keep going!
thank you 🙂 any post suggestions? or questions?
Hi, package is good, But its crashing on IOS 13.. Any Idea.
Hi, its working great on IOS, but Android seems to let us visit to appstore.
I want to open app page with in unity. like a native ad do.