Reputation: 4056
I have set up in my app to query LicenseInformation.IsTrial
upon app launch and app activation as directed here http://msdn.microsoft.com/library/windows/apps/hh286402(v=vs.105).aspx . My main question is, when calling CheckLicense
to return _isTrial = _licenseInfo.IsTrial()
in release mode, if a user does not have an active connection (say they do not have cellular service where they are currently at) then will the app crash? My main concern is that this is called every time an app is activated or launched, so as a precaution to prevent the app from crashing, do I need to store the current trial state in IsolatedStorage? The documentation was not clear on this and I have not found anything anywhere else stating what to do in this situation.
App.xaml.cs
private static LicenseInformation _licenseInfo = new LicenseInformaItion();
private static bool _isTrial = true;
public bool IsTrial
{
get
{
return _isTrial;
}
}
/// <summary>
/// Check the current license information for this application
/// </summary>
private void CheckLicense()
{
// When debugging, we want to simulate a trial mode experience. The following conditional allows us to set the _isTrial
// property to simulate trial mode being on or off.
#if DEBUG
string message = "This sample demonstrates the implementation of a trial mode in an application." +
"Press 'OK' to simulate trial mode. Press 'Cancel' to run the application in normal mode.";
if (MessageBox.Show(message, "Debug Trial",
MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
_isTrial = true;
}
else
{
_isTrial = false;
}
#else
_isTrial = _licenseInfo.IsTrial();
#endif
}
private void Application_Launching(object sender, LaunchingEventArgs e)
{
CheckLicense();
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
CheckLicense();
}
Upvotes: 0
Views: 224
Reputation: 1257
No, the app does not crash if you do not have any internet connection. This is because the license gets embedded with the app itself so it can be accessible in offline mode as well. Another thing proving this is, when you purchase the full version of an app that offers a trial option, the app will know it runs in 'full' mode even when there is no internet connection.
The only thing that you won't be able to do is purchase the app in offline mode. Note that your app will not crash, you will just get a store error.
Upvotes: 1