using UnityEngine; using Viveport; public class QuitGoHome { const int SUCCESS = 0; private static bool isSubscriber = false; static void Quit() { Debug.Log("Quitting"); if(isSubscriber) Deeplink.GoToStore(DeeplinkGoToStoreCallback); } [RuntimeInitializeOnLoadMethod] static void RunOnStart() { Application.quitting += Quit; Subscription.IsReady(IsReadyHandler); // check for viveport init and isready } private static void DeeplinkGoToStoreCallback(int code, string message) { if (code == SUCCESS) { Debug.Log("[VIVEPORT][DEEPLINK][GOTOSTORE] Go to store success."); } else { Debug.Log(string.Format("[VIVEPORT][DEEPLINK][GOTOSTORE] Code: {0}, Message: {1}", code, message)); } } private static void IsReadyHandler(int nResult, string message) { if (nResult == 0) { Viveport.Core.Logger.Log("Subscription is ready"); CheckSubscriber(); // check if user is subscriber } else { Viveport.Core.Logger.Log("Subscription IsReadyHandler error: " + nResult + " Message : " + message); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// !!!IMPORTANT!!! Please wait for the IsReadyHandler before calling the GetUserStatus function /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // check if user is infinity member private static void CheckSubscriber() { var userStatus = Subscription.GetUserStatus(); if (userStatus.Type != SubscriptionStatus.TransactionType.Unknown) isSubscriber = true; if (isSubscriber) Debug.Log("Viveport Infinity Member"); else Debug.Log("Not Viveport Infinity Member"); } }