18. November 2010 15:18
I would like to share my lessons learned while I was working with the Windows Phone 7 Ad SDK for my textContact Light application. For a more detailed explanation of how to set up your account and the AdControl, download the SDK.
While debugging the application I was using the test values for the ApplicaitonId and AdUnitId and everything was working fine. When I uploaded my app to the marketplace with the correct values my AdControl was hiding itself and I didn’t know why. I started playing around with the control a little more and found the reason to be that there was no ads to display. Here are the lessons learned.
- Make sure your ad unit has categories selected. You can do so by logging into PubCenter, under Setup – Ad units.
- Make sure your ad unit is the right size. Some sizes are not as popular as others and therefore will probably yield 0 results, hiding your AdControl. I use the 480X80 size now.
- Make sure you set the AdUnitId of the AdControl to the ad unit ID found in the PubCenter.
- Make sure you set the ApplicationId of the AdControl to the application ID found in the PubCenter, under Setup – Sites & apps.
- Make sure you set static property AdControl.TestMode = false in your code behind. A lot of people get confused and think it is a property of the Control, but is not. You have to use the namespace Microsoft.Advertising.Mobile.UI.
- If it doesn’t work on the emulator it will probably not work on the device. When I was testing with the real IDs the AdControl was disappearing. I thought that was because the application wasn’t downloaded from the Marketplace with the right certificate. It turns out I was wrong. Make sure you are serving ads while testing before publishing.
- If all fails and your AdControl is still disappearing then register to the AdControlError event and query the e.ErrorCode and e.ErrorDescription properties to get more details on what is going on.
I hope these lessons learned help you out so you don’t have to spend the same amount of time I did on something that should be very straight forward. Right now I’m working on trying to programmatically change the AdUnitId if e.ErrorCode == ErrorCode.NoAdAvailable, but so far I have been unsuccessful.
Happy programming (and monetizing)