Beispiel #1
0
        public static Yodo1U3dAdError createWithJson(string errorJsonString)
        {
            Yodo1U3dAdError             error    = new Yodo1U3dAdError();
            Dictionary <string, object> errorDic = (Dictionary <string, object>)Yodo1JSON.Deserialize(errorJsonString);

            if (errorDic != null)
            {
                if (errorDic.ContainsKey("code"))
                {
                    error.Code = int.Parse(errorDic["code"].ToString());
                }
                if (errorDic.ContainsKey("message"))
                {
                    error.Message = errorDic["message"].ToString();
                }
            }
            return(error);
        }
Beispiel #2
0
        private string RequestAdmobConfig(string appKey)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                return("Please check your network. You can also fill in manually.");
            }

            string result = string.Empty;

            if (!string.IsNullOrEmpty(appKey))
            {
                string api = "https://sdk.mas.yodo1.com/v1/unity/setup/" + appKey;
#if UNITY_2018
                string response = HttpGet(api);
                Dictionary <string, object> obj = (Dictionary <string, object>)Yodo1JSON.Deserialize(response);
                Debug.Log("response:" + response);
                if (obj != null)
                {
                    if (obj.ContainsKey("app_key"))
                    {
                        app_key = (string)obj["app_key"];
                    }
                    if (obj.ContainsKey("name"))
                    {
                        app_name = (string)obj["name"];
                    }
                    if (obj.ContainsKey("bundle_id"))
                    {
                        app_bundle_id = (string)obj["bundle_id"];
                    }
                    if (obj.ContainsKey("platform"))
                    {
                        app_platform = (string)obj["platform"];
                    }
                    if (obj.ContainsKey("admob_key"))
                    {
                        app_admob_key = (string)obj["admob_key"];
                    }

                    if (app_platform == "ios")
                    {
                        this.adSettings.iOSSettings.AdmobAppID = app_admob_key;
                    }
                    else if (app_platform == "android")
                    {
                        this.adSettings.androidSettings.AdmobAppID = app_admob_key;
                    }
                }
                else
                {
                    result = "MAS App Key not found. please fill in correctly.";
                }
#else
                ApiCallback callback = delegate(string response)
                {
                    Dictionary <string, object> obj = (Dictionary <string, object>)Yodo1JSON.Deserialize(response);
                    Debug.Log("response:" + response);
                    if (obj != null)
                    {
                        if (obj.ContainsKey("app_key"))
                        {
                            app_key = (string)obj["app_key"];
                        }
                        if (obj.ContainsKey("name"))
                        {
                            app_name = (string)obj["name"];
                        }
                        if (obj.ContainsKey("bundle_id"))
                        {
                            app_bundle_id = (string)obj["bundle_id"];
                        }
                        if (obj.ContainsKey("platform"))
                        {
                            app_platform = (string)obj["platform"];
                        }
                        if (obj.ContainsKey("admob_key"))
                        {
                            app_admob_key = (string)obj["admob_key"];
                        }

                        if (app_platform == "ios")
                        {
                            this.adSettings.iOSSettings.AdmobAppID = app_admob_key;
                        }
                        else if (app_platform == "android")
                        {
                            this.adSettings.androidSettings.AdmobAppID = app_admob_key;
                        }
                    }
                    else
                    {
                        result = "MAS App Key not found. please fill in correctly.";
                    }
                };
                EditorCoroutineRunner.StartEditorCoroutine(SendUrl(api, callback));
#endif
            }
            else
            {
                result = "Please enter the correct MAS App Key.";
            }
            return(result);
        }
Beispiel #3
0
        public void Yodo1U3dMasCallbackResult(string result)
        {
            Debug.Log("[Yodo1 Mas] The SDK callback result:" + result + "\n");

            Dictionary <string, object> obj = (Dictionary <string, object>)Yodo1JSON.Deserialize(result);

            if (obj == null)
            {
                return;
            }

            if (!obj.ContainsKey("flag") || !obj.ContainsKey("data"))
            {
                return;
            }

            string jsonData = obj["data"].ToString();
            Dictionary <string, object> dataDic = (Dictionary <string, object>)Yodo1JSON.Deserialize(jsonData);

            if (dataDic == null)
            {
                return;
            }

            int flag = int.Parse(obj["flag"].ToString());

            if (flag == FLAG_INITIALIZE)
            {
                bool            success = false;
                Yodo1U3dAdError error   = new Yodo1U3dAdError();

                if (dataDic.ContainsKey("success"))
                {
                    success = int.Parse(dataDic["success"].ToString()) == EVENT_INITIALIZE_SUCCESS ? true : false;
                }
                if (dataDic.ContainsKey("error"))
                {
                    string errorStr = dataDic["error"].ToString();
                    error = Yodo1U3dAdError.createWithJson(errorStr);
                }

                if (_initializeDelegate != null)
                {
                    _initializeDelegate(success, error);
                }
            }
            else if (flag == FLAG_AD_EVENT)
            {
                AdType type = AdType.Rewarded;
                if (dataDic.ContainsKey("type"))
                {
                    type = (AdType)int.Parse(dataDic["type"].ToString());
                }
                else
                {
                    return;
                }
                Yodo1U3dAdEvent eventCode = Yodo1U3dAdEvent.AdError;
                if (dataDic.ContainsKey("code"))
                {
                    eventCode = (Yodo1U3dAdEvent)int.Parse(dataDic["code"].ToString());
                }
                string message;
                if (dataDic.ContainsKey("message"))
                {
                    message = dataDic["message"].ToString();
                }
                Yodo1U3dAdError error = new Yodo1U3dAdError();
                if (dataDic.ContainsKey("error"))
                {
                    error = Yodo1U3dAdError.createWithJson(dataDic["error"].ToString());
                }

                switch (type)
                {
                case AdType.Rewarded:
                {
                    if (_rewardedAdDelegate != null)
                    {
                        _rewardedAdDelegate(eventCode, error);
                    }
                }
                break;

                case AdType.Interstitial:
                    if (_interstitialAdDelegate != null)
                    {
                        _interstitialAdDelegate(eventCode, error);
                    }
                    break;

                case AdType.Banner:
                    if (_bannerDelegate != null)
                    {
                        _bannerDelegate(eventCode, error);
                    }
                    break;

                default:
                    break;
                }
            }
        }