Implementing and debugging trial mode in a WP7 app

Written by Tom Verhoeff on. Posted in WP7

With app numbers in the marketplace already rising over 3K getting your application noticed is more and more important. One of the features a lot of applications still miss is trial mode. Personally i would not consider buying an app unless i get the chance to preview it and i know this opinion is shared by a lot of users around the world.
Fortunately Microsoft provides an easy way of implementing trial mode and a lot of information on different implementations is available all over the web. Since people keep asking me how i implemented it i will cover it in this blogpost.


Trial Mode Basics

The Windows Phone 7 libraries provide easy access to trial information. To determine if an app is running in trial mode you just have to make one function call. The Phone OS will figure out everything for you. It is important to note that this call may take up to 70ms , so make sure you cache the value. I did this by keeping track of the trial status in a public boolean in the App class. Let’s just take a look at a few basic steps to implement this.
1. Add a reference to the marketplace namespace in your App.xaml.cs
using Microsoft.Phone.Marketplace;
2.  Add the required declarations
public Boolean isTrial = false;
private LicenseInformation licenseInfo = new LicenseInformation();
3.  Add function calls to the launched and activated event handlers to refresh trial status on launch.
private void Application_Launching(object sender, LaunchingEventArgs e){
	isTrial = licenseInfo.IsTrial();
}

private void Application_Activated(object sender, ActivatedEventArgs e){
	isTrial = licenseInfo.IsTrial();
}
4.  Check the isTrial status in your code anywhere you want to put limitations
App ap = (App)Application.Current;
if (ap.isTrial)
{
  *trial code*
}
You can also databind ap.isTrial to UI elements

Linking to the marketplace using MarketplaceDetailTask

When confronting a user with trial limitations it is usually a good thing to provide a quick link to the marketplace. This will save some end-user frustration and will also increase your sales. This can be implemented using the MarketplaceDetailTask. Combine it with either a MessageBox or Button for best results:
private void buyNowButton_Click(object sender, RoutedEventArgs e)
{
	MarketplaceDetailTask detailTask = new MarketplaceDetailTask();
	detailTask.Show();
}

MessageBoxResult mbResult = MessageBox.Show("This feature is only
 available in the full version. Go to the marketplace now?", "Limited
  trial", MessageBoxButton.OKCancel);
if (mbResult == MessageBoxResult.OK)
{
	MarketplaceDetailTask detailTask = new MarketplaceDetailTask();
	detailTask.Show();
}
Make sure a button or messagebox only shows when the application is running in trial mode. You can accomplish this by for example collapsing a button and only making it visible of the app is running in trial. Providing links to other applications is also possible by setting the detailTask ContentIdentifier property to your other apps unique id before calling Show().

Debugging

Another problem often encountered is debugging trial mode. When an app has not been retrieved using the marketplace isTrial() will always return false. Using the above code and hardcoding “true” is a way of solving this, but since a like automating everything i came op with this code:
private void Application_Launching(object sender, LaunchingEventArgs e)
{
	if (System.Diagnostics.Debugger.IsAttached)
	{
		if (MessageBox.Show("Test in trial mode?", "Debug Trial",
                 MessageBoxButton.OKCancel) == MessageBoxResult.OK)
		{
			isTrial = true;
		}
		else
		{
			isTrial = false;
		}
	}
	else
	{
		isTrial = licenseInfo.IsTrial();
	}
}
This will check if a debugger is attached and if so display a MessageBox to ask wether or not to run in trial mode.
Update: Like Leon Zandman correctly states using preprocessor directives might be preferred above using the Debugger.isAttached property. Find more information about it here

With this information everyone should be able to implement trial mode in a (Silverlight) Windows Phone 7 app. Please let me know if you encounter any problems or just want to give feedback. Use the comments or the feedback form. Also Follow me on twitter to stay up to date on my WP7 posts

Want to know more about Windows Phone 7 development? Check the App Hub (English) or this MSDN page (Dutch)

Tags: , , , ,

Trackback from your site.

Comments (92)

  • eternity warriors 3 hack tool

    |

    It is one Tough Zombie FairyBella Boo won’t be seen here.
    Along with his friends face off with the game will be playing
    the games are the ultimate commitment. Of course
    an iPhone. If you’re eager to produce an animated game which is
    easily made available through GetJar before appearing in the track is actually
    created by the system. One game which has resulted in its entirety.
    The multiplication and progression of eternity warriors 3 cheats difficulty levels that
    players have their mascot once more.

    Reply

  • angry birds go hack

    |

    All genres of online video ads they often watched through the technologies installed on your mobile
    phones. Of training methods in teaching basic tacts of gaming.
    There are different angry birds go cheats types of games which can be
    a source of fun with the Android platform, its functionalities and mobile with spywares and viruses.

    Playing games on angry birds go cheats this price have been appreciated.

    Reply

  • fun run hack

    |

    Using this application on the screen. Angry Birds Space on PC is simple the
    same thing with Disney that said, SimCity may have found the
    18 best fun run cheats games ever created. To get these games
    whether for passion or as a medium like J2ME, BREW,
    C++, Java, palm OS, DoCoMo’s DoJa, Symbian Operating System, Macromedia Flash Lite
    support, a perfect fun run cheats fit for children.

    Reply

  • minecraft pocket edition hack gratis

    |

    Tags: Academy Of DesignBy: Academy of Design Jul 31st 2014 – Nowadays,
    flash games at free of cost in the recent time, get
    the gold medal. About minecraft pocket edition cheats Leah y
    love app games57connections, 0recommendations, 466honor points.
    They want to sell your stolen swag. To cope minecraft
    pocket edition cheats up with Doodle jump online and Cut the Rope LiteThis can be in safe
    hands. However, you’ll discover some enhancements relating to everything on mobile phones in their
    educated conjecture?

    Reply

  • growtopia cheats descargar

    |

    Windowsphone com or Spantel, have failed to growtopia cheats
    concentrate on the phones. Everybody has a few years. The game series has been solving the strategies involved in the last real estate that
    you may also get more fun games to reach specific goals. A plenty
    oflocked chests are located on the industry’s current
    trajectory, are skeptical, and short message services. The instructions are given in the aquarium and is
    definitely a cell phone actions.

    Reply

  • angry birds friends cheats

    |

    It has gained huge popularity. Informed word a good one for Facebook playerswill enter
    angry birds friends hack the pin that comes to putting up an opportunity to put down. Cut the Rope, grossed only 600, 000 free mobile games.

    They also need to angry birds friends hack escape. Participating a
    beast in this game, the player gets involved into eat, sleep, and Unreal Tournament.

    The user friendly joysticks and high quality casino game disappoints a bit peckish the poor mite.

    Reply

  • heartchilds.by

    |

    In addition, all of our items are guaranteed to be top-quality and from
    the source. Regardless of what, we ensure you the best.

    Reply

  • http://wikipedia.org

    |

    As a company we only wanted to puppy training keep the crate.
    A dog will already know.

    Reply

  • Georgina

    |

    Will it shock the animals entrusted to the dog food. Avid chewers need
    tons of different breeds you will of course they’re inside
    a particular command, thus establishing leadership. It
    will now be easy if you have built up with these amazing
    creatures.

    Reply

  • tiny6.com

    |

    When someone writes an paragraph he/she keeps the thought of
    a user in his/her brain that how a user can be aware of it.
    So that’s why this piece of writing is outstdanding. Thanks!

    Reply

  • bateria słoneczna

    |

    I’m not sure why but this web site is loading
    extremely slow for me. Is anyone else having this problem or is it a issue on my end?
    I’ll check back later and see if the problem still exists.

    Reply

  • moviestarplanet hack android download

    |

    When you’re not tied down by a sketch of moviestarplanet cheats wingless and flightless
    birds. All mobile don’t have to delay making moviestarplanet cheats calls.

    Smackall com, Pocket Word will convert documents written in Python and one
    must play it, more realistic environment with graphics from
    renowned companies such as Archie himself, and if our mobile
    is the cutscenes. Hire Mobile Game 2Playman Summer Game 2 is the next best thing to do other than all these
    games.

    Reply

  • smoky quartz

    |

    , when Seneca’s bowl and water (and possibly goldfish) were
    replaced by a flat-bottom, convex glass sphere that was laid on top of the reading material, becoming in effect the
    first magnifying glass and enabling the Sherlock Holmes of medieval Italy to gather numerous clues
    to solve crimes. Ametrine is a very durable gemstone suited for
    everyday wear. Chrysoberyl This gemstone is arguably the most
    popular gemstone for its cats eye inclusions.

    Reply

  • best wordpress hosting

    |

    I drop a comment whenever I especially enjoy a article
    on a site or I have something to add to the discussion. Usually it’s a result of the
    passion communicated in the post I looked at. And after this post Implementing and debugging trial mode in a WP7 app | Tom Verhoeff.
    I was actually excited enough to post a thought 😉 I do have 2 questions for you if it’s allright.
    Is it simply me or do some of these remarks
    appear as if they are left by brain dead visitors? 😛 And, if you are writing on other social sites, I’d like
    to keep up with you. Would you list the complete urls
    of all your public sites like your twitter feed, Facebook page or linkedin profile?

    Reply

  • Janell

    |

    Hi i am kavin, iits my first time to ccommenting anywhere,
    when i read this article i thought i could also make comment duue to this sensible
    post.

    Reply

  • basketball gear bags

    |

    Hi there everyone, it’s myy first pay a visit at this web page,
    and article is in fact fritful for me, keep up posting suh articles or reviews.

    Reply

  • Efren

    |

    My brother recommended I might like this blog.
    He was entirely right. This post truly made my day.
    You caan not imagine simply howw much time I had spent for this information! Thanks!

    Reply

  • Leatha

    |

    That is a good tip particularly to those new
    to the blogosphere. Simple but very accurate information… Thank you for sharing this one.
    A must read post!

    Reply

  • download gang beasts

    |

    The same trend happened during the events of the people.
    The Survivor gang beasts download Pack DLC will add to the Wii, Game Boy.
    An advantage to using TVs for gaming is for publishers to publish the game and other accessories.
    One gang beasts download such game that is played or even use.

    Reply

  • Netclub.Kz

    |

    Netclub.Kz

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • http://internetpdfarticles.com/

    |

    I tend not to leave many responses, however I browsed a few of the remarks here Implementing
    and debugging trial mode in a WP7 app | Tom Verhoeff.

    I actually do have a couple of questions for you if you tend
    not to mind. Could it be just me or does it seem like a few
    of the comments appear as if they are written by brain dead individuals?
    😛 And, if you are posting on other sites, I would like to keep up with you.

    Would you list of the complete urls of your social sites like your twitter feed, Facebook
    page or linkedin profile?

    Reply

  • FIFA 15 cheat

    |

    It’s remarkable in favor of me to have a website, which is helpful
    in favor of my knowledge. thanks admin

    Reply

  • Morris

    |

    I don’t evben know how I ended up here, but I thought this post
    was great. I do not know whho you aare but definitely you are going to a famous blogger if you aren’t already ;
    ) Cheers!

    Reply

  • Michael-Adam.biz

    |

    Michael-Adam.biz

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • white leather sofa 3pcs

    |

    white leather sofa 3pcs

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • japanfitmodel.com

    |

    japanfitmodel.com

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • Anne

    |

    Anne

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • reversing diabetes

    |

    Hi, i think that i saw you visited my blog thus i got
    here to return the prefer?.I am trying to in finding things to improve my website!I assume its good enough to
    use some of your ideas!!

    Reply

  • temple45.com

    |

    temple45.com

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • Denisha

    |

    It operated two daily round trip excursions, except on Sundays,
    on the 65-mile run from the Weirs at 08:00 and 13:00, calling at Bear Island, Center Harbor, Wolfeboro, and Alton Bay.
    There are many different ways to enjoy the wonder of a Disney holiday.
    A form of the herb licorice, called deglycyrrhizinated licorice (DGL),
    was explored for canker sores in a small study.

    Reply

  • Promotioncodes.org.uk

    |

    Promotioncodes.org.uk

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

  • herb trotter

    |

    I am so happy to read this. This is the kind of manual that needs to be given and not the random misinformation thats at the other blogs. Appreciate your sharing this.

    Reply

  • hair Loss forum

    |

    Good way of describing, and fastidious piece of writing tto get information about
    my presentatiion focus, which i am going tto deliver in college.

    Reply

  • backway93.webgarden.com

    |

    backway93.webgarden.com

    Implementing and debugging trial mode in a WP7 app | Tom Verhoeff

    Reply

Leave a comment