Skip to content

Instantly share code, notes, and snippets.

@wtuts
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtuts/ccb4cfea9e68cd7c7cc8 to your computer and use it in GitHub Desktop.
Save wtuts/ccb4cfea9e68cd7c7cc8 to your computer and use it in GitHub Desktop.
admob in windows phone app
//This is a function for creating a admob add dynamically using c#
void admob(StackPanel stck)
{
//Create a admob banner
AdView bannerAd = new AdView
{
Format = AdFormats.Banner,
AdUnitID = "YOUR_AD_UNIT_ID"
};
//Make a request for the add view
AdRequest adRequest = new AdRequest();
//Add the banner into the specific stackpannel
stck.Children.Add(bannerAd);
//Load the add
bannerAd.LoadAd(adRequest);
//Check for the exceptions and failures
bannerAd.FailedToReceiveAd += bannerAd_FailedToReceiveAd;
bannerAd.ReceivedAd += bannerAd_ReceivedAd;
}
//Recieved add function
void bannerAd_ReceivedAd(object sender, AdEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Ad received");
}
//Failed add function
void bannerAd_FailedToReceiveAd(object sender, AdErrorEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Ad failed");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment