public void FillBaseData(long sessionID) { this.bundle = Application.identifier; this.idfa = ElephantCore.Instance.idfa; this.idfv = ElephantCore.Instance.idfv; this.app_version = Application.version; this.lang = Utils.GetISOCODE(Application.systemLanguage); this.user_tag = RemoteConfig.GetInstance().GetTag(); this.os_version = SystemInfo.operatingSystem; this.sdk_version = ElephantVersion.SDK_VERSION; this.ad_sdk_version = VersionCheckUtils.GetInstance().AdSdkVersion; this.device_model = SystemInfo.deviceModel; this.create_date = Utils.Timestamp(); this.session_id = sessionID; try { TimeZone localZone = TimeZone.CurrentTimeZone; DateTime currentDate = DateTime.Now; TimeSpan currentOffset = localZone.GetUtcOffset(currentDate); this.timezone_offset = currentOffset.ToString(); } catch (Exception e) { Debug.Log(e); } }
public static RemoteConfig GetInstance() { if (instance == null) { instance = new RemoteConfig(); } return(instance); }
void ExampleSDKUsage() { int currentLevel = 1; // make sure you send this at the start of the each level Elephant.LevelStarted(currentLevel); // basic SDK event Elephant.Event("user_clicked_something", currentLevel); // SDK event with parameter Elephant.Event("custom_reward_event", currentLevel, Params.New().Set("gold", 1000)); // SDK transaction for currencies (consumable user properties) Elephant.Transaction("gem", currentLevel, -10, 90, "skin_unlock"); // SDK event with some parameters Params param2 = Params.New() .Set("gems", 10) .Set("source", "level_reward") .Set("some_double", 3.141592).CustomString("{\"t\": 1}"); Elephant.Event("custom_reward_event2", currentLevel, param2); // send level completed or failed event if (LevelPassed()) { Elephant.LevelCompleted(currentLevel); } else { Elephant.LevelFailed(currentLevel); } // use some remote config parameters to change the game remotely ( useful for A\B testing ) string someString = RemoteConfig.GetInstance().Get("test_string", "default"); int someInt = RemoteConfig.GetInstance().GetInt("test_int", 0); long someLong = RemoteConfig.GetInstance().GetLong("test_long", 1L); }
private IEnumerator InitSDK(bool isOldUser) { if (Utils.IsFileExists(OLD_ELEPHANT_FILE)) { isOldUser = true; } string savedConfig = Utils.ReadFromFile(REMOTE_CONFIG_FILE); userId = Utils.ReadFromFile(USER_DB_ID) ?? ""; Log("Remote Config From File --> " + savedConfig); var isUsingRemoteConfig = 0; openResponse = new OpenResponse(); if (savedConfig != null) { RemoteConfig.GetInstance().Init(savedConfig); openResponse.remote_config_json = savedConfig; } openRequestWaiting = true; openRequestSucceded = false; float startTime = Time.time; var realTimeBeforeRequest = DateTime.Now; RequestIDFAAndOpen(isOldUser); while (openRequestWaiting && (Time.time - startTime) < 5f) { yield return(null); } if (openRequestSucceded) { isUsingRemoteConfig = 1; } Log(JsonUtility.ToJson(openResponse)); var parameters = Params.New() .Set("real_duration", (DateTime.Now - realTimeBeforeRequest).TotalMilliseconds) .Set("game_duration", (Time.time - startTime) * 1000) .Set("is_using_remote_config", isUsingRemoteConfig) .CustomString(JsonUtility.ToJson(openResponse)); Elephant.Event("open_request", -1, parameters); RemoteConfig.GetInstance().Init(openResponse.remote_config_json); AdConfig.GetInstance().Init(openResponse.ad_config); Utils.SaveToFile(REMOTE_CONFIG_FILE, openResponse.remote_config_json); Utils.SaveToFile(USER_DB_ID, openResponse.user_id); currentSession.user_tag = RemoteConfig.GetInstance().GetTag(); if (onOpen != null) { if (openResponse.consent_required) { onOpen(true); } else { onOpen(false); } } else { Debug.LogWarning("ElephantSDK onOpen event is not handled"); } sdkIsReady = true; if (onRemoteConfigLoaded != null) { onRemoteConfigLoaded(); } }