Partager via


PhoneGap on WP7 Tip #7: Marketplace tricks

This is a quick follow up tip to the last one I posted about using Trial Mode with a PhoneGap application on Windows phone.

As I mentioned in that article, having your application available for users to try without laying out any money is a great way to grab them as a customer. But successfully converting them is about more than just limiting the functionality. It’s about driving your desired behaviors for them. This can be prompting them to download your app, review it (good reviews are another key marketing tool in the marketplace) or even seeing other apps published by you in the marketplace.

Fortunately, there is an easy way to do this through the Marketplace tasks that are available to us. We will add a way to call those relevant tasks from PhoneGap by using the Marketplace Plugin from the previous article.

Revisiting the code from the previous article, we need to make a few changes. First, add this statement at the top of the marketplace.cs file.

 using Microsoft.Phone.Tasks;

Then, add a wrapper for the task to show the detail in the Marketplace for the current application using the MarketplaceDetailTask class.

 public void showInMarketplace(string args)
{
    MarketplaceDetailTask _marketplaceDetailTask = new MarketplaceDetailTask();
    _marketplaceDetailTask.Show();
}

This does not return a result to the calling JavaScript code, so you don’t need the DispatchCommandResult call as in the previous article.

Next up, a JavaScript wrapper in the marketplace.js file.

 marketplace.prototype.showInMarketplace = function () {
    var args = {}
    PhoneGap.exec(null, null, "Marketplace", "showInMarketplace", args);
}

 

A small change to the index.html page will let us provide the user with a way to quickly jump to the marketplace and buy the app.

 

 function licenseCallback(isTrial) {
    if (isTrial) {
        licenseDiv.innerHTML = 
        'Trial mode, please <a onClick=window.plugins.marketplace.showInMarketplace();>buy me</a>!';
    }
    else {
        licenseDiv.innerHTML = 'Thanks for buying!';
    }

If you try this in the phone emulator, you’ll notice a few things. First of all, the marketplace entry won’t display and in fact you’ll get an error. That’s expected, as your app didn’t get installed on the emulator from the marketplace in the first place. Be assured it will certainly work once your app is published. Second, after you go to the marketplace and then press the back button to return to the app, you get prompted to simulate trial or full mode again. That’s not only expected, but by design. If a user upgrades to paid, when they come back to the app, we want to know then. Not when the app is restarted.

There are other useful marketplace functions, including:

  • MarketplaceHubTask - Allows an application to launch the Windows Phone Marketplace client application.
  • MarketplaceReviewTask - Allows an application to launch the Windows Phone Marketplace client application and display the review page for the specified product. This is an EXCELLENT way to encourage reviews, and good reviews are key to a prominent position in the marketplace!
  • MarketplaceSearchTask - Allows an application to launch the Windows Phone Marketplace client application and display the search results from the specified search terms. You could search for other apps you’ve published by putting the app name or the publisher name in as a parameter to this call. Great for cross selling as in “Like this app? Try the my others!”

It’s easy to leverage the trial mode and the marketplace API in your PhoneGap apps on Windows Phone to get more purchases!