DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Make Money During your WP7 App's Free Trial

Make Money During your WP7 App's Free Trial

Henry Lee user avatar by
Henry Lee
·
Dec. 08, 11 · Mobile Zone · Interview
Like (0)
Save
Tweet
5.65K Views

Join the DZone community and get the full member experience.

Join For Free
With the big news about the Windows Store yesterday and the new flexible app trials it will bring (time OR feature-based trials), DZone thought it would be good to share a tutorial about how to create a free trial and also make money with ads during the free trial.

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 a free trial application doesn't mean you can’t make money doing so. You can display a Microsoft ad when the application is deployed as trial app and make money off of advertising! Today we will be building demo as shown below that displays the ad.

SNAGHTML1d7bdeb

Preparing your Microsoft Ad control SDK

You can go to http://advertising.microsoft.com/mobile-apps and download the Ad SDK and sign up for Microsoft advertising.

Preparing advertising you want to display in Windows Phone apps

Once you are registered at Microsoft advertising and have installed the 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.

image

Then you would need to create Ad units which will give you an Ad Unit ID as show in below figure.

image

Create Windows Phone with Microsoft Ad SDK in Trial Mode

Add Microsoft Ad SDK assembly

Once you created a Windows Phone project you would need to add a 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 the figure below.

image

Add Ad Control to XAML

In XAML, you need to add two things to the xml namespace and the ad control as shown below.

<phone:PhoneApplicationPage

   x:Class=”HowToCreateTrialAppWithAdSdk.MainPage”

   xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

   xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

   xmlns:phone=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone”

   xmlns:shell=”clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone”

   xmlns:d=”http://schemas.microsoft.com/expression/blend/2008″

   xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006″

   mc:Ignorable=”d” d:DesignWidth=”480″ d:DesignHeight=”768″

   FontFamily=”{StaticResource PhoneFontFamilyNormal}”

   FontSize=”{StaticResource PhoneFontSizeNormal}”

   Foreground=”{StaticResource PhoneForegroundBrush}”

   SupportedOrientations=”Portrait” Orientation=”Portrait” 

   shell:SystemTray.IsVisible=”True”

  xmlns:my=”clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI”>

    <Grid x:Name=”LayoutRoot” Background=”Transparent”>

 

        <my:AdControl Height=”80″ HorizontalAlignment=”Left” Margin=”0,688,0,0″ x:Name=”ad” VerticalAlignment=”Top” Width=”480″/>

   </Grid>

 </phone:PhoneApplicationPage>

Add Code to Codebehind

Then in code behind you need to properly display ad control when your app is in trial mode. In the Microsoft.Phone.Marketplace namespace you will find the LicenseInformation class that contains the IsTrial() method that returns '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 test mode by setting the AdControl.TestMode to false. Also you would want to set ApplicationId and AdUnitId properties using the values obtained in Microsoft ad center in the above steps. See below for the code that shows these explanations.

using Microsoft.Phone.Controls;

using Microsoft.Advertising.Mobile.UI;

using Microsoft.Phone.Marketplace;

 

namespace HowToCreateTrialAppWithAdSdk

{

    public partial class MainPage : PhoneApplicationPage

    {

        public MainPage()

        {

            InitializeComponent();

 

            // 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;

            }

        }

    }

}

 

Download Code

Conclusion

In this demo you learn about how to allow the user to install you app in trial mode and still make money using a Microsoft Ad.

Source: http://blog.toetapz.com/2010/11/03/how-to-create-trial-mode-application-with-microsoft-ad-support/

app ADS (motorcycle) Windows Phone application Software development kit Advertising Testing Download DZone

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Internal Developer Platform in Plain English
  • 12 Modern CSS Techniques For Older CSS Problems
  • Java’s Encapsulation - When the Getter and Setter Became Your Enemy
  • Getting Started With RSocket Kotlin

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo