In my previous artilce Part 62 - Windows Phone 7 - pubCenter Setup for app I explained how to setup pubCenter for Windows Phone 7. In this article I will explain how to setup AdControl in Windows Phone 7 to display ad setup of pubCenter in your app.
I would recomment to read Part 62 - Windows Phone 7 - pubCenter Setup for app before proceeding.
Step 1: If you don't see Microsoft.Advertising.Mobile and Microsoft.Advertising.Mobile.UI in the Add Reference window. Download Microsoft Advertising SDK for Windows Phone
Step 2: Add reference of Microsoft.Advertising.Mobile and Microsoft.Advertising.Mobile.UI
Step 3: Open toolbox and drag AdControl from Toolbox to design view of MainPage.xaml.
You will notice below code will be added to MainPage.xaml
<my:AdControl AdUnitId="Image480_80" ApplicationId="test_client" Height="80" HorizontalAlignment="Left" Name="adControl1" VerticalAlignment="Top" Width="480" />
Step 4: Now run the application on your device you will notice that AdControl will appear on the device with Microsoft Advertising on it. In emulator(in my system) there will be white space without any text.
If you change ApplicationId anything apart from "test_client" and AdUnitId anything apart from "Image480_80", only black rectangle will appear on device as well as on emulator.
Step 5: If you read my previous mentioned article I had created AdUnitId and ApplicationId in pubCenter which I will place in AdUnitId and ApplicationId property of AdControl like below.
<my:AdControl AdUnitId="XXXXXXX" ApplicationId="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" Height="80" HorizontalAlignment="Left" Name="adControl1" VerticalAlignment="Top" Width="480" />
Step 6: Now run the application and you will see add on your app as shown below.
AdControl has two importan properties IsAutoRefreshEnabled and IsAotoCollapseEnabled.
If IsAutoRefreshEnabled is set to true, the AdControl will show new ad every 60 seconds. As you ad is chaning in every 60 seconds chances of better revenue increases.
If IsAutoCollapseEnabled is set to true, the AdControl will hide itself till ad get downloaded.
<my:AdControl IsAutoCollapseEnabled="True" IsAutoRefreshEnabled="True" AdUnitId="XXXXXXXX" ApplicationId="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" Height="80" HorizontalAlignment="Left" Name="adControl1" VerticalAlignment="Top" Width="480" />
AdControl looks for few information from your app, these information are
Your application manifest should have all these information.
If you want ad to be display on location wise, you need to add ID_CAP_LOCATION to enable location based advertising which improves quality and revenue of ad
This ends the article of using AdControl and Microsoft Advertising in Windows Phone 7.