I have no idea why this happens, so I have several variables on the firebase remote config which is the Admob Id I want to fetch for loading the ads because I don't want to update from the script so I'm using firebase remote config to store the AdsId.
then the problem happens when the first launch of the App always no Ads request
, but on the second launch the ads show up.
but if I'm not using firebase remote config or manually Add AdsId on the script, the first launch app the Ads show up
this preview :
- first time launch with fetch from firebase remote config :
- this Second launch or re-open the app or add AdsId manually :
here the script:
- Ads script :
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
DontDestroyOnLoad(this);
bannerAdId = Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("Android_BannerAdsId").StringValue;
InterstitialAdID = Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("Android_IntersitialAdsId").StringValue;
rewarded_Ad_ID = Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("Android_VideoAdsId").StringValue;
rewardedAd = RewardBasedVideoAd.Instance;
}
// Start is called before the first frame update
void Start()
{
MobileAds.Initialize(GameID);
}
- calling fetch on start :
private void Start()
{
_FirebaseRemoteConfig.instance.InitializeFirebase();
....................................................
}
private void Awake()
{
if (instance != null)
{
Destroy(gameObject);
}
else
{
DontDestroyOnLoad(gameObject);
instance = this;
}
InitializeFirebase();
}
public int countingUpdate;
public int maxCount;
Firebase.DependencyStatus dependencyStatus = Firebase.DependencyStatus.UnavailableOther;
// Use this for initialization
void Start()
{
}
public void InitializeFirebase()
{
System.Collections.Generic.Dictionary<string, object> defaults =
new System.Collections.Generic.Dictionary<string, object>();
defaults.Add("config_test_string", "default local string");
defaults.Add("config_test_int", 1);
defaults.Add("config_test_float", 1.0);
defaults.Add("config_test_bool", false);
Firebase.RemoteConfig.FirebaseRemoteConfig.SetDefaults(defaults);
Debug.Log("Remote config ready!");
FetchFireBase();
}
public void FetchFireBase()
{
FetchDataAsync();
}
- when add AdsId manually
string GameID = "ca-app-pub-6738378604910121~6166276301";
// Sample ads
string bannerAdId = "ca-app-pub-3940256099942544/6300978111";
string InterstitialAdID = "ca-app-pub-3940256099942544/1033173712";
string rewarded_Ad_ID = "ca-app-pub-3940256099942544/5224354917";
public BannerView bannerAd;
public InterstitialAd interstitial;
public RewardBasedVideoAd rewardedAd;
public static _AdmobAds instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
DontDestroyOnLoad(this);
//bannerAdId = Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("Android_BannerAdsId").StringValue;
//InterstitialAdID = Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("Android_IntersitialAdsId").StringValue;
//rewarded_Ad_ID = Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("Android_VideoAdsId").StringValue;
rewardedAd = RewardBasedVideoAd.Instance;
}
// Start is called before the first frame update
void Start()
{
MobileAds.Initialize(GameID);
}