Hello,
I am trying to integrate admob to my mobile game. I want to call a function when admob request failed. But as I understand while callback function of admob request is async, it throws error.
error:
get_main can only be called from the main thread.
My question is how can I call a normal method from this async method.
Here is my code
private void RequestInterstitial()
{
//Test device
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-3940256099942544/6300978111";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
// Called when an ad request failed to load.
interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
MonoBehaviour.print("HandleFailedToReceiveAd event received with message: "
+ args.Message);
interstitial.Destroy();
//SceneManager.LoadScene(0);
normalMethod();
}