要取消订阅,用户必须在Google Play应用中手动进行。但是,您可以通过在应用中包含以下代码来检查订阅是否已过期并在需要时提示用户重新订阅:
Purchases.subscriptions().get(packageName, subscriptionId, token)
.executeAsync(new PurchaseResponseListener() {
@Override
public void onCompleted(Purchase purchase, String itemId, responseStatus
status) {
if (purchase == null) {
// The subscription has expired or has never been purchased
} else if (purchase.isAutoRenewing()) {
// The subscription is active and is set to auto-renew
} else {
// The subscription is active but not set to auto-renew
// Prompt the user to re-subscribe manually
}
}
});
此代码将检查订阅是否仍在进行中,并根据订阅是否已自动续订,提示用户手动重新订阅。