A user can voluntarily cancel a subscription from the Play Store or have their subscription automatically cancelled if they don't recover after being in account hold. When a user cancels a subscription they retain access to the content until the end of the current billing cycle. When the billing cycle ends, access is revoked.
When a subscription is cancelled but not yet expired, it is returned from BillingClient.queryPurchasesAsync(). Cancelling a subscription triggers a SUBSCRIPTION_CANCELED notification. When you receive this notification, the subscription resource returned from the Google Play Developer API contains autoRenewing = false, and the expiryTime contains the date when the user should lose access to the subscription. If expiryTime is in the past, then the user loses entitlement immediately. Otherwise, the user should retain entitlement until it is expired. The subscription resource looks similar to the following:
{
"kind": "androidpublisher#subscriptionPurchaseV2",
...
"subscriptionState": "SUBSCRIPTION_STATE_CANCELED",
...
"lineItems": [
{
"productId": "sub_variant_plan01",
"expiryTime": expiration_time,
...
}
],
}
You app can look at the cancelReason in the subscription resource returned from the Google Play Developer API to learn why the subscription was cancelled (e.g. the customer cancelled or had billing issues). If the subscription was cancelled by the user, you can look at the cancelSurveyResult field to learn why the user cancelled the subscription.
Your app might want to display a message in your app informing the user that their subscription was cancelled, such as "Your subscription will expire on _somedate. Your app can also deep link to the Google Play Store to let users restore their subscription.
If you display this message, you should also offer users the ability to permanently dismiss the message.
Note also that cancellation messages might frustrate users, especially users who manually cancelled a subscription as opposed to having their subscription cancelled because their payment was outdated. You might choose not to inform users who manually cancelled a subscription.
Warning: Don't remove a subscription from Google Play while any user is still entitled to the content. Removing content to which a user is entitled results in penalties.