Last active
August 29, 2015 14:02
-
-
Save wtuts/ccb4cfea9e68cd7c7cc8 to your computer and use it in GitHub Desktop.
admob in windows phone app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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