App产品购买中如何消费订阅类型

How to consume the subscription type in app product purchase

我已经在我的应用程序中实现了订阅类型的应用程序内产品,例如 1 个月或 2 个月的套餐,一旦用户订阅了该产品,我就会让服务器知道并相应地处理 him/her 它是工作得很好。

根据 Google 订阅期结束时:

Google auto-cut the credit and renew the package.

我的问题:如何知道下个月有没有付费的用户?

您可以从 Google Play 获取活跃购买的列表,然后相应地更新您的服务器(例如每天)。

IInAppBillingService service = ...;
Bundle items = service.getPurchases(API_VERSION, PACKAGE_NAME, "subs", null);
int response = getResponseCodeFromBundle(items);
if (response != RESULT_OK) {
  // handle error
}
ArrayList<String> productIDs = items.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
// update server with active product ids

回答问题:您不能消费订阅。您只能使用 inapps。

引自文档:

Important: Unlike in-app products, subscriptions cannot be consumed. 资料来源:https://developer.android.com/google/play/billing/api.html

该页面指向以下两个: https://developer.android.com/google/play/billing/billing_subscriptions.html https://developer.android.com/google/play/billing/billing_integrate.html#Subs

另请注意,在提供订阅时,最好允许用户恢复订阅。例如,如果用户登录您的应用程序,购买订阅,然后使用另一个用户名登录,则该订阅也应该在那里可用,因为它已附加到用户 google play 帐户。

要做到这一点,您应该查询购买的潜艇,如指定的 marmor