Skip to content

Instantly share code, notes, and snippets.

@rtroe
Created March 17, 2018 00:42
Show Gist options
  • Save rtroe/71e73dba1f3d41395718a2d50b7f600e to your computer and use it in GitHub Desktop.
Save rtroe/71e73dba1f3d41395718a2d50b7f600e to your computer and use it in GitHub Desktop.
public void LoadIniterstialelAd()
{
#if __ANDROID__
if (mInterstitialAd.IsLoaded==false)
{
var adRequest = new AdRequest.Builder()
#if DEBUG
.AddTestDevice("DEADBEEF9A2078B6AC72133BB7E6E177") // Prevents generating real impressions while testing
#endif
.Build();
mInterstitialAd.LoadAd(adRequest);
}
#elif __IOS__
Request request = Request.GetDefaultRequest();
#if DEBUG
request.TestDevices = new[] { "GAD_SIMULATOR_ID", "kGADSimulatorID" };
#endif
if (AdViewInterstitial == null || AdViewInterstitial.HasBeenUsed == true)
{
Console.WriteLine("Creating AdViewInterstitial");
AdViewInterstitial = new Interstitial(this.AdUnitID);
AdViewInterstitial.AdReceived += (object sender, EventArgs e) =>
{
Console.WriteLine("Add Recived");
};
AdViewInterstitial.ScreenDismissed += delegate
{
Console.WriteLine("Dissmised");
Engine.Pause = false;
};
AdViewInterstitial.ReceiveAdFailed += (object sender, InterstitialDidFailToReceiveAdWithErrorEventArgs e) =>
{
Console.WriteLine(e.Error.DebugDescription);
};
AdViewInterstitial.LoadRequest(request);
}
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment