It provides attractive option when the user can download and try your application before he/she can purchase your app. But just because you provide trial application means you can’t make money doing so. You can display Microsoft ad when the application is deployed as trial app and make money off of advertising. You will be building demo as shown below that displays the ad.
Preparing your Microsoft Ad control SDK
You can go to http://advertising.microsoft.com/mobile-apps and download Ad SDK and sign up for Microsoft advertising.
Preparing for advertising you want to display in Windows Phone app
Once you are registered at Microsoft advertising and installed Microsoft Ad SDK on your machine you will need to login to https://pubcenter.microsoft.com/ and create “apps” that will give you Application ID as show in figure below.
Then you would need to create Ad units which will give you Ad Unit ID as show in below figure.
Create Windows Phone with Microsoft Ad SDK in Trial Mode
Add Microsoft Ad SDK assembly
Once you created Windows Phone project you would need to add reference to Microsoft.Advertising.Mobile.UI.dll found in C:\Program Files (x86)\Microsoft Advertising SDK for Windows Phone 7 (64 bit) or C:\Program Files\Microsoft Advertising SDK for Windows Phone 7 (32 bit) as show in below figure.
Add Ad Control to XAML
In XAML, you would need to add two things xml namespace and the ad control as shown below.
mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”768″
<Grid x:Name=”LayoutRoot” Background=”Transparent”>
<my:AdControl Height=”80″ HorizontalAlignment=”Left” Margin=”0,688,0,0″ x:Name=”ad” VerticalAlignment=”Top” Width=”480″/>
Add Code to Codebehind
Then in code behind you would need to properly display ad control when your app is in trial mode. In Microsoft.Phone.Marketplace namespace you will find LicenseInformation class that contains IsTrial() method that return true if the current app is in trial mode. If the app is in trial mode simply collapse the control. BY DEFAULT IsTrial() method ALWAYS RETURNS FALSE.
By default your AdControl will be in test mode and before shipping out your application you want to make sure to test AdControl in none test mode by setting AdControl.TestMode to false. Also you would want to set ApplicationId and AdUnitId properties using the values ontained in Microsoft ad center in above steps. See below for the code that shows these explanations.
public partial class MainPage : PhoneApplicationPage
// Ad if trial
AdControl.TestMode = false;
ad.ApplicationId = “your app id”;
ad.AdUnitId = “your ad unit id”;
ad.Visibility = System.Windows.Visibility.Collapsed;
if (new LicenseInformation().IsTrial())
ad.Visibility = System.Windows.Visibility.Visible;
In this demo you learn about how to make money while you allow the user to install you app in trial mode and still make money using Microsoft Ad.