void Start() { RebuildQueue(); processQueues = true; #if !UNITY_EDITOR && UNITY_ANDROID ElephantAndroid.Init(); #endif }
IEnumerator Post(ElephantRequest elephantRequest) { Log(elephantRequest.tryCount + " - " + (Utils.Timestamp() - elephantRequest.lastTryTS) + " -> " + elephantRequest.url + " : " + elephantRequest.data); elephantRequest.tryCount++; elephantRequest.lastTryTS = Utils.Timestamp(); var elephantData = new ElephantData(elephantRequest.data, GetCurrentSession().GetSessionID()); string bodyJsonString = JsonUtility.ToJson(elephantData); string authToken = Utils.SignString(bodyJsonString, GameSecret); #if UNITY_EDITOR var request = new UnityWebRequest(elephantRequest.url, "POST"); byte[] bodyRaw = Encoding.UTF8.GetBytes(bodyJsonString); request.uploadHandler = new UploadHandlerRaw(bodyRaw); request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Authorization", authToken); request.SetRequestHeader("GameID", ElephantCore.Instance.GameID); yield return(request.SendWebRequest()); Log("Status Code: " + request.responseCode); if (request.responseCode != 200) { // failed will be retried if (_failedQueue.Count < MAX_FAILED_COUNT) { _failedQueue.Add(elephantRequest); } else { Log("Failed Queue size -> " + _failedQueue.Count); } } #else #if UNITY_IOS ElephantIOS.ElephantPost(elephantRequest.url, bodyJsonString, GameID, authToken, elephantRequest.tryCount); #elif UNITY_ANDROID ElephantAndroid.ElephantPost(elephantRequest.url, bodyJsonString, GameID, authToken, elephantRequest.tryCount); #endif yield return(null); #endif }
private void RequestIDFAAndOpen(bool isOldUser) { idfv = SystemInfo.deviceUniqueIdentifier; #if UNITY_EDITOR idfa = "UNITY_EDITOR_IDFA"; StartCoroutine(OpenRequest(isOldUser)); #elif UNITY_IOS idfa = ElephantIOS.IDFA(); Debug.Log("Native IDFA -> " + idfa); StartCoroutine(OpenRequest(isOldUser)); #else idfa = ElephantAndroid.FetchAdId(); Debug.Log("Native IDFA -> " + idfa); StartCoroutine(OpenRequest(isOldUser)); #endif }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != null && Instance != this) { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); #if !UNITY_EDITOR && UNITY_ANDROID ElephantAndroid.Init(); #endif }