private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); noAds += HasNoInternet; //init default ads helper defaultAdsNetworkHelpers = new List <IAdsNetworkHelper>(); defaultAdsNetworkPriority = new List <CustomMediation.AD_NETWORK>(); #if UNITY_EDITOR && UNITYADS if ((InitAdmobManager() as IAdsNetworkHelper) == null) { Debug.LogError("admob manager not found"); } AddDefaultNetworkHelper(CustomMediation.AD_NETWORK.Unity, InitUnityAdsManager()); #else AddDefaultNetworkHelper(CustomMediation.AD_NETWORK.GoogleAdmob, InitAdmobManager()); #if UNITYADS AddDefaultNetworkHelper(CustomMediation.AD_NETWORK.Unity, InitUnityAdsManager()); #endif #if ADS_FAN && !UNITY_EDITOR AddDefaultNetworkHelper(CustomMediation.AD_NETWORK.FAN, InitFANHelper()); #endif #endif adsNetworkHelpers = defaultAdsNetworkHelpers; //FirebaseRemoteConfigHelper.CheckAndHandleFetchConfig(InitializeRemoteConfigSingleAds); FirebaseRemoteConfigHelper.CheckAndHandleFetchConfig(SetupRemoteConfig); }
int[] GetRemoteAdsPriorityInt(bool isReady) { //Initialize remote config //0 is admob, 1 is unity string adsPriorityStr = FirebaseRemoteConfigHelper.GetString(RMCF_ADS_PRIORITY, ""); Debug.Log($"remote config value: {adsPriorityStr}"); if (!isReady || isDoneInitRemoteConfig || string.IsNullOrEmpty(adsPriorityStr)) { return(null); } var splitStr = adsPriorityStr.Split(','); if (splitStr.Length < defaultAdsNetworkHelpers.Count) { Debug.LogError("remote string not valid, length not match with number of ads helper"); return(null); } int[] adsPriorityInt = new int[defaultAdsNetworkHelpers.Count]; for (int i = 0; i < splitStr.Length; i++) { if (!int.TryParse(splitStr[i], out adsPriorityInt[i])) { Debug.LogError("parse ads priority to int failed"); return(null); } Debug.Log($"ads priority int: {adsPriorityInt[i]}"); } return(adsPriorityInt); }
/// <summary> /// Check if phone turn on Wifi or Data connection. Can be toggled through Firebase Remote Config /// </summary> /// <returns>If configured to not require internet, always return true. If configured to require internet, return internet state</returns> public static bool InternetReachableOptional() { if (FirebaseRemoteConfigHelper.GetBool(Const.RMCF_REQUIRE_INTERNET, false)) { return(Application.internetReachability != NetworkReachability.NotReachable); } else { return(true); //skip internet check } }
public static void GetRemoteConfig() { bool useV4 = FirebaseRemoteConfigHelper.GetBool(Const.RMCF_USE_DATABASE_V4, true); if (useV4) { databaseName = "simpledata.bytes"; } else { databaseName = "simpledatav3.bytes"; } Instance.service = new DataService(databaseName); Debug.Log($"Use database v4: {useV4}"); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); if (FirebaseManager.FirebaseReady) { OnFirebaseReady(this, true); } else { FirebaseManager.handleOnReady += OnFirebaseReady; } }
void SetupRemoteConfig(object sender, bool isSuccess) { string configJsonData = FirebaseRemoteConfigHelper.GetString(RMCF_ADS_PRIORITY, null); if (!string.IsNullOrEmpty(configJsonData)) { if ((configJsonData.StartsWith("{") && configJsonData.EndsWith("}")) || //For object (configJsonData.StartsWith("[") && configJsonData.EndsWith("]"))) //For array) { configData = LitJson.JsonMapper.ToObject <Dictionary <string, RemoteConfigAdsNetworkData> >(configJsonData); adsNetworkHelpers = new List <IAdsNetworkHelper>(); string deb = "ads_placement_config:\n"; foreach (var item in configData) { deb += ($"{item.Key} {item.Value}\n"); if (!item.Value.enable) { continue; } var adsHelper = GetAdsNetworkHelper(item.Value.adNetwork); if (adsHelper == null) { Debug.LogWarning("Reference to ads helper component is null, refused adding invalid ads helper"); continue; } AddNetworkHelper(item.Value.adNetwork, adsHelper); } Debug.Log(deb); } else { Debug.LogError($"AdsManager: {RMCF_ADS_PRIORITY} has invalid format. {configJsonData}"); } } else { Debug.LogError($"AdsManager: {RMCF_ADS_PRIORITY} is null"); } }
void SetupRemoteConfig(object sender, bool isSuccess) { string configJsonData = FirebaseRemoteConfigHelper.GetString(adsPlacementConfigKey, null); //test json data //configJsonData = Resources.Load<TextAsset>("TestPlacementConfig").text; if (!string.IsNullOrEmpty(configJsonData)) { //configData = LitJson.JsonMapper.ToObject<Dictionary<string, RemoteConfigAdsPlacementData>>(configJsonData); var data = LitJson.JsonMapper.ToObject <Dictionary <string, List <RemoteConfigAdsPlacementData> > >(configJsonData); List <RemoteConfigAdsPlacementData> listData = null; foreach (var item in data) { listData = item.Value; } configData = new Dictionary <string, RemoteConfigAdsPlacementData>(); for (int i = 0; i < listData.Count; i++) { configData.Add(listData[i].placementID.ToString(), listData[i]); } /*string deb = "ads_placement_config:\n"; * foreach (var item in configData) * { * deb += ($"{item.Key} {item.Value.show} {item.Value.priority[0]}\n"); * } * Debug.Log(deb);*/ AdsManager.instance.configPlacementHideAds += CheckHideAds; AdsManager.instance.configPlacementAdsNetworkPriority += GetAdsNetworkPriority; } else { Debug.LogError("RemoteConfigAdsPlacement: ads_placement_config is null"); } }
void Start() { FirebaseRemoteConfigHelper.CheckAndHandleFetchConfig(SetupRemoteConfig); }