Example #1
0
        public void Init(AdConfig config)
        {
            if (config == null)
            {
                return;
            }

            mopub_keyword    = config.mopub_keyword;
            ad_callback_logs = config.ad_callback_logs;
            parameters       = config.parameters;
        }
Example #2
0
 public OpenResponse()
 {
     this.user_id            = "";
     this.consent_required   = false;
     this.gdpr_body_text     = "";
     this.gdpr_option_1      = "";
     this.gdpr_option_2      = "";
     this.gdpr_option_3      = "";
     this.gdpr_option_1_data = new GDPROptionDetailModel();
     this.gdpr_option_2_data = new GDPROptionDetailModel();
     this.gdpr_option_3_data = new GDPROptionDetailModel();
     this.remote_config_json = JsonUtility.ToJson(new ConfigResponse());
     this.ad_config          = AdConfig.GetInstance();
 }
Example #3
0
        public void Init(AdConfig config)
        {
            if (config == null)
            {
                return;
            }

            mopub_keyword               = config.mopub_keyword;
            ad_callback_logs            = config.ad_callback_logs;
            backup_ads_enabled          = config.backup_ads_enabled;
            backup_interstitial_ad_unit = config.backup_interstitial_ad_unit;
            backup_rewarded_ad_unit     = config.backup_rewarded_ad_unit;
            parameters = config.parameters;
        }
Example #4
0
        public static void AdEvent(string type, string adUnitId = "", string errorCode = "")
        {
            if (!AdConfig.GetInstance().ad_callback_logs)
            {
                return;
            }

            Params param = Params.New();

            if (!string.IsNullOrEmpty(adUnitId))
            {
                param.Set("adUnitId", adUnitId);
            }
            if (!string.IsNullOrEmpty(errorCode))
            {
                param.Set("error", errorCode);
            }

            CustomEvent("ads_sdk_" + type, -1, param);
        }
Example #5
0
        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();
            }
        }
Example #6
0
 public static AdConfig GetInstance()
 {
     return(_instance ?? (_instance = new AdConfig()));
 }