Example #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();
            }
        }
Example #2
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
        }