// 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(); } }
public void Send(bool showsOverlayImmediately) { #if UNITY_IPHONE || UNITY_ANDROID if (Application.isEditor) { Debug.Log("PlayHaven: metadata request (" + mPlacement + ")"); PlayHavenManager manager = PlayHavenManager.instance; if (manager != null) { // mimic a payload for in-editor integration validation Hashtable notification = new Hashtable(); notification["type"] = "badge"; notification["value"] = "1"; Hashtable data = new Hashtable(); data["notification"] = notification; Hashtable result = new Hashtable(); result["data"] = data; result["hash"] = hashCode; // not part of a real result; for in-editor only result["name"] = "success"; // not part of a real result; for in-editor only result["content"] = mPlacement; string jsonResult = JsonMapper.ToJson(result); manager.HandleNativeEvent(jsonResult); } } else { if (Debug.isDebugBuild) { Debug.Log(string.Format("PlayHaven: metadata request (id={0}, placement={1})", hashCode, mPlacement)); } #if UNITY_IPHONE _PlayHavenMetadataRequest(hashCode, PlayHavenBinding.token, PlayHavenBinding.secret, mPlacement); #elif UNITY_ANDROID if (PlayHavenManager.IsAndroidSupported) { PlayHavenBinding.obj_PlayHavenFacade.Call("metaDataRequest", hashCode, mPlacement); } #endif } #endif }
public static void CancelRequest(int requestId) { #if UNITY_IPHONE if (Application.isEditor) { Debug.Log("PlayHaven: cancel request for request code = " + requestId); PlayHavenManager manager = PlayHavenManager.instance; if (manager != null) { manager.RequestCancelSuccess(requestId.ToString()); } } else { _PlayHavenCancelRequest(requestId); } #endif }
private static PlayHavenManager FindInstance() { PlayHavenManager i = GameObject.FindObjectOfType(typeof(PlayHavenManager)) as PlayHavenManager; if (!i) { GameObject go = GameObject.Find("PlayHavenManager"); if (go != null) { i = go.GetComponent <PlayHavenManager>(); } } if (!i && !wasWarned) { Debug.LogWarning("unable to locate a PlayHavenManager in the scene"); wasWarned = true; } return(i); }
public void Send(bool showsOverlayImmediately) { #if UNITY_IPHONE || UNITY_ANDROID if (Application.isEditor) { Debug.Log("PlayHaven: open request"); PlayHavenManager manager = PlayHavenManager.instance; if (manager != null) { // mimic a payload for in-editor integration validation // going to "dismiss" Hashtable data = new Hashtable(); data["notification"] = new Hashtable(); Hashtable result = new Hashtable(); result["data"] = data; result["hash"] = hashCode; result["name"] = "success"; string jsonResult = JsonMapper.ToJson(result); manager.HandleNativeEvent(jsonResult); } } else { if (Debug.isDebugBuild) { Debug.Log(string.Format("PlayHaven: open request (id={0})", hashCode)); } #if UNITY_IPHONE _PlayHavenOpenRequest(hashCode, PlayHavenBinding.token, PlayHavenBinding.secret, customUDID); #elif UNITY_ANDROID if (PlayHavenManager.IsAndroidSupported) { PlayHavenBinding.obj_PlayHavenFacade.Call("openRequest", hashCode); } #endif } #endif }
public void Send(bool showsOverlayImmediately) { hashCode = GetHashCode(); #if UNITY_IPHONE || UNITY_ANDROID if (Application.isEditor) { Debug.Log("PlayHaven: content request (" + mPlacement + ")"); PlayHavenManager manager = PlayHavenManager.instance; if (manager != null) { // mimic a payload for in-editor integration validation // going to "dismiss" Hashtable data = new Hashtable(); data["notification"] = new Hashtable(); Hashtable result = new Hashtable(); result["data"] = data; result["hash"] = hashCode; result["name"] = "dismiss"; string jsonResult = JsonMapper.ToJson(result); manager.HandleNativeEvent(jsonResult); } } else { #if UNITY_IPHONE _PlayHavenContentRequest(hashCode, PlayHavenBinding.token, PlayHavenBinding.secret, mPlacement, showsOverlayImmediately); #elif UNITY_ANDROID if (PlayHavenManager.IsAndroidSupported) { PlayHavenBinding.obj_PlayHavenFacade.Call("contentRequest", hashCode, mPlacement); } #endif } #endif }
// 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 }
void Awake() { playHaven = PlayHavenManager.instance; }