by Morten
26. November 2012 15:06
When you are testing In-App purchasing in your Windows 8 app, you need to use “Windows.ApplicationModel.Store.CurrentAppSimulator” static class instead of “Windows.ApplicationModel.Store.CurrentApp”. This means you’ll end up writing a lot of code like this:
var licenseInformation =
#if DEBUG
Windows.ApplicationModel.Store.CurrentAppSimulator.LicenseInformation;
#else
Windows.ApplicationModel.Store.CurrentApp.LicenseInformation;
#endif
//...
string receipt = await
#if DEBUG
Windows.ApplicationModel.Store.CurrentAppSimulator.
#else
Windows.ApplicationModel.Store.CurrentApp.
#endif
RequestProductPurchaseAsync(featureName, true)
Yes this gets ugly really quick. Here’s a neat little trick to get around that. Right below your using statements at the top of your file, simply add this alias mapping:
#if DEBUG
using Store = Windows.ApplicationModel.Store.CurrentAppSimulator;
#else
using Store = Windows.ApplicationModel.Store.CurrentApp;
#endif
And in your code you can now simply write:
var licenseInformation = Store.LicenseInformation;
string receipt = await Store.RequestProductPurchaseAsync(featureName, true);
0646589e-7581-4ab2-ae5d-51bbb203fa51|4|5.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags:
Windows Runtime