So, you’d like to put some ads in your awesome App Studio app? No problem! I thought I would write a post to show just how easy it can be. Follow these easy steps and you’ll start earning money from ads…
The ad provider is the service the AdControl in your app gets the ad to display and also where you earn the revenue. As of Windows Phone 8 there is a PubCenter AdControl built into the framework, all you need to do is get an ApplicationId and an AdUnitId. You get that information from Windows Phone DevCenter, find out how to get your ApplicationId and AdUnitId in this great blog post.
If you want to use a separate Ad provider, for example AdDuplex, you’ll need to add the provider’s DLLs to your project. I’m using AdDuplex in the example below, learn how to add AdDuplex to your project here.
Step One: Enable ads in App Studio
Before generating your App Studio app, you’ll want to enable ad support. On the Publish Info tab, turn on the Enable ad client in the source code switch (see #2 in this screenshot):
Next, generate the app and download the source code.
Step Two: Open App in Visual Studio
After downloading the source code, you might need to unblock the binaries before unzipping the folder. This is a built-in security feature that prevents internet-downloaded code from running on your machine. Since we know where these files came from, it’s ok to go and unblock them. Here is how to do that:
- Right click on the downloaded zip folder
- Select “Properties“
- If you see an “Unblock” button, click it. If you do not, continue to step 4.
- Now you can safely unzip the folder
Next, drill down into the unzipped folder until you see the Visual Studio solution file. Double click to open it in Visual Studio (Note: You need Visual Studio installed. If you do not, you’ll need to download and install the Windows Phone SDK from here).
Step Three: AdControl on MainPage.xaml
Drill Down to MainPage.xaml, see this screenshot to help you find it:
Near the top of the page, you will see a commented out section of code (approximately line #50). This is the built-in AdControl. All you need to do is:
- Uncomment the AdControl (delete the <!– and –> characters before and after the AdControl)
- Replace the placeholder ApplicationId and AdUnitId with yours
In this screenshot, I demonstrate how to use an AdDuplex ad control instead of the built-in AdControl.
That’s all there is to it! Now you can do a Build and publish the generated XAP file. (If you are not familiar with how to publish an app built with Visual Studio, see this documentation)
This image shows what the published app looks like running on a phone, see for yourself and download the app.
Here are some follow-up resources to help you monetize your apps:
- AdDuplex Home and AdDuplex on Nuget
- Video about PubCenter
- Video about monetization with Carlos Rivera