サブスクリプション付きのAndroidアプリを持っていて、ユーザーがアクティブなサブスクリプションを持っているかどうかを問い合わせるのにIabHelper
を使用します。今私はまた、この定期購読が自動更新されているかどうかを知る必要があります。IabHelper:サブスクリプションが自動更新されているかどうかをチェック
私はこのようなサブスクリプションのステータスを照会しています:
private boolean userIsSubscribed() {
ArrayList<String> skuList = new ArrayList<>();
skuList.add(PREMIUM_SUBSCRIPTION);
// Check the subscription status
try {
Inventory inventory = iabHelper.queryInventory(true, null, skuList);
Purchase purchase = inventory.getPurchase(PREMIUM_SUBSCRIPTION);
// Is the user subscribed?
if (purchase != null && purchase.getPurchaseState() == 0) {
// User is subscribed
Log.d(TAG, "Subscribed.");
// TODO check if subscription is auto-renewing
return true;
} else {
// User is not subscribed
Log.d(TAG, "Not subscribed.");
return false;
}
} catch (IabException | NullPointerException e) {
// There was an error with the subscription process
Log.e(TAG, e.getMessage(), e);
return false;
} catch (IllegalStateException e) {
// IabHelper not set up
Log.e(TAG, e.getMessage(), e);
return false;
}
}
Purchase
オブジェクトは、残念ながら、自動更新のフィールドを求めるための方法を持っていません。私はこの情報を得ることができる他の方法はありますか?