有料版と無料版で動作を変更すると思うが、どちらの状態か判定するには LicenseInformation クラスを使う。
var licenseInfo = CurrentAppSimulator.LicenseInformation;
if (licenseInfo.IsActive)
{
// ライセンスがアクティブ
if (licenseInfo.IsTrial)
{
// 試用版
}
else
{
// 購入
}
}
else
{
// ライセンスがアクティブではない
}
LicenseInformation クラスの実装には注意が必要で、実際にストアへ提出する際には
CurrentAppSimulator.LicenseInformation
ではなく
CurrentApp.LicenseInformation
を使用する必要がある。
(実際に自分のアプリ購入してみて動かなくて焦ったw)
ということで、以下のようにしておけば、提出時に忘れることはなくなるかな?
#if DEBUG
var licenseInfo = CurrentAppSimulator.LicenseInformation;
#else
var licenseInfo = CurrentApp.LicenseInformation;
#endif
var licenseInfo = CurrentAppSimulator.LicenseInformation;
if (licenseInfo.IsActive)
{
// ライセンスがアクティブ
if (licenseInfo.IsTrial)
{
// 試用版
}
else
{
// 購入
}
}
else
{
// ライセンスがアクティブではない
}