Пример #1
0
        // Executed when the manager's game object is recognized by the engine.  If "whenToSendOpen" is set to
        // Awake, PlayHaven will be notified that your game has opened.
        void Awake()
        {
            _instance = FindInstance();

            DetectNetworkReachable();

            if (token.Length == 0)
            {
                Debug.LogError("PlayHaven token has not been specified in the PlayerHavenManager");
            }
            if (secret.Length == 0)
            {
                Debug.LogError("PlayHaven secret has not been specified in the PlayerHavenManager");
            }

            gameObject.name = this.GetType().ToString();
            if (doNotDestroyOnLoad)
            {
                DontDestroyOnLoad(this);
            }

                        #if UNITY_EDITOR
            DetermineInEditorDevice();
            integrationSkin = (GUISkin)Resources.Load("PlayHavenIntegrationSkin", typeof(GUISkin));
                        #endif

            //
                        #if UNITY_ANDROID
            PlayHavenBinding.SetKeys(tokenAndroid, secretAndroid);
                        #else
            PlayHavenBinding.SetKeys(token, secret);
                        #endif
            PlayHavenBinding.listener = this;
                        #if UNITY_ANDROID
            PlayHavenBinding.Initialize();
                        #endif

            // launch counting
            if (suppressContentRequestsForLaunches > 0)
            {
                launchCount = PlayerPrefs.GetInt(KEY_LAUNCH_COUNT, 0);
                launchCount++;
                PlayerPrefs.SetInt(KEY_LAUNCH_COUNT, launchCount);
                PlayerPrefs.Save();
                if (Debug.isDebugBuild)
                {
                    Debug.Log("Launch count: " + launchCount);
                }
            }

            if (whenToSendOpen == PlayHavenManager.WhenToOpen.Awake)
            {
                OpenNotification();
            }

            if (whenToGetNotifications == PlayHavenManager.WhenToGetNotifications.Awake)
            {
                BadgeRequest();
            }
        }
Пример #2
0
 /// <summary>
 /// Cancel any requests that are currently pending.
 /// </summary>
 public void CancelAllPendingRequests()
 {
     foreach (int requestId in requestsInProgress)
     {
         PlayHavenBinding.CancelRequest(requestId);
     }
     requestsInProgress.Clear();
 }
Пример #3
0
 // Inform PlayHaven that the game has opened.  This can be called automatically upon Awake, Start, or
 // manually by calling this method anywhere in your own code.
 public int OpenNotification()
 {
     if (networkReachable)
     {
         int requestId = PlayHavenBinding.Open(CustomUDID);
                         #if !UNITY_EDITOR
         requestsInProgress.Add(requestId);
                         #endif
         return(requestId);
     }
     return(NO_HASH_CODE);
 }
Пример #4
0
 void OnApplicationPause(bool pause)
 {
                 #if UNITY_IPHONE
     if (!pause)
     {
         DetectNetworkReachable();
         if (autoCallOpenUponUnpause)
         {
             OpenNotification();
         }
     }
                 #elif UNITY_ANDROID
     if (!pause)
     {
         DetectNetworkReachable();
     }
     PlayHavenBinding.RegisterActivityForTracking(!pause);
                 #endif
 }
Пример #5
0
 /// <summary>
 /// Track an in-app purchase.
 /// </summary>
 public void ProductPurchaseTrackingRequest(Purchase purchase, PurchaseResolution resolution)
 {
     PlayHavenBinding.SendIAPTrackingRequest(purchase, resolution);
 }
Пример #6
0
 /// <summary>
 /// Resolve a purchase request (buy, cancel, fail).
 /// </summary>
 public void ProductPurchaseResolutionRequest(PurchaseResolution resolution)
 {
     PlayHavenBinding.SendProductPurchaseResolution(resolution);
 }
Пример #7
0
        // Executed when the manager's game object is recognized by the engine.  If "whenToSendOpen" is set to
        // Awake, PlayHaven will be notified that your game has opened.
        void Awake()
        {
            _instance = FindInstance();

            DetectNetworkReachable();

            gameObject.name = "PlayHavenManager";
            if (doNotDestroyOnLoad)
            {
                DontDestroyOnLoad(this);
            }

                        #if UNITY_EDITOR
            DetermineInEditorDevice();
            integrationSkin = (GUISkin)Resources.Load("PlayHavenIntegrationSkin", typeof(GUISkin));
                        #endif

            // launch counting
            if (suppressContentRequestsForLaunches > 0)
            {
                launchCount = PlayerPrefs.GetInt(KEY_LAUNCH_COUNT, 0);
                launchCount++;
                PlayerPrefs.SetInt(KEY_LAUNCH_COUNT, launchCount);
                PlayerPrefs.Save();
                if (Debug.isDebugBuild)
                {
                    Debug.Log("Launch count: " + launchCount);
                }
            }

            //
                        #if UNITY_ANDROID
            PlayHavenBinding.Initialize();
                        #endif

                        #if !ENABLE_MANUAL_PH_MANAGER_INSTANTIATION
                        #if UNITY_IPHONE
            if (string.IsNullOrEmpty(token))
            {
                Debug.LogError("PlayHaven token has not been specified in the PlayerHavenManager");
            }
            if (string.IsNullOrEmpty(secret))
            {
                Debug.LogError("PlayHaven secret has not been specified in the PlayerHavenManager");
            }
                        #elif UNITY_ANDROID
            if (string.IsNullOrEmpty(tokenAndroid))
            {
                Debug.LogError("PlayHaven token has not been specified in the PlayerHavenManager");
            }
            if (string.IsNullOrEmpty(secretAndroid))
            {
                Debug.LogError("PlayHaven secret has not been specified in the PlayerHavenManager");
            }
                        #endif
                        #if UNITY_ANDROID
            PlayHavenBinding.SetKeys(tokenAndroid, secretAndroid);
                        #elif UNITY_IPHONE
            PlayHavenBinding.SetKeys(token, secret);
                        #endif
            PlayHavenBinding.listener = this;
            if (whenToSendOpen == PlayHavenManager.WhenToOpen.Awake)
            {
                OpenNotification();
            }

            if (whenToGetNotifications == PlayHavenManager.WhenToGetNotifications.Awake)
            {
                BadgeRequest(badgeMoreGamesPlacement);
            }
                        #endif
        }