Link 管理 Play 商店订阅

Link to manage Play Store subscription

在iOS,我们可以使用https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions,它会打开本地订阅管理器。

是否可以通过 Play 商店执行此操作,或者是否有任何其他可能的方法来打开 Google Play 商店的本机订阅管理器?

与此问题相同,但对于 Android:Link to app manage subscriptions in app store

用户现在可以在 App 商店页面上查看他们的订阅。

https://developer.android.com/google/play/billing/subscriptions#deep-link

"After users have purchased subscriptions, they can view the subscriptions and cancel them from the My Apps screen in the Play Store app or from the app's product details page in the Play Store app."

market://details?id=YOUR_APP_ID

我使用操作视图打开 Google Play 商店 -> 帐户。

    private fun openPlaystoreAccount() {
        try {
            startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/account?utm_source=google&utm_medium=account&utm_campaign=my-account")));
        } catch (e: ActivityNotFoundException) {
            showToast("Cant open the browser")
            e.printStackTrace()
        } 
    }

更新:

Google 发布了一个新的深度 link,它将用户直接带到您的应用程序管理订阅页面。您需要两个东西 SKU 和您的应用程序包名称。

示例URL:

https://play.google.com/store/account/subscriptions?sku=yoursku&package=com.yourpackagename

Kotlin 示例代码:

 private val packageName = "com.mydomain.myapp"
 private val sku = "mySku"

 private fun openPlaystoreAccount() {
     try {
         startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/account/subscriptions?sku=$sku&package=$packageName")))
     } catch (e: ActivityNotFoundException) {
         showToast("Cant open the browser")
         e.printStackTrace()
     }
 }

我无法找到如何link 到特定应用程序的订阅页面。但是进入订阅页面的 url 是:https://play.google.com/store/account/subscriptions。此 url 将在您使用 Android 时在 Play 商店应用中打开。

自今年的 IO 以来,可以使用 深度 link 到 link 订阅:

https://play.google.com/store/account/subscriptions?sku=*yoursku*&package=*com.yourpackagename*

只需打开此 URL 即可。

更详细的解释-

1) 用户已拥有订阅

在这种情况下,当您调用 billingClient.queryPurchases() 时,returns 会调用 PurchaseResult。其中包含 purchaseTokensku 以及 packagename 等详细信息。每次应用程序启动或 MainActivity 恢复时都会进行此调用,因为如果有人离线购买您的 IAP,您还需要 acknowledge 购买(更多关于此 here

这意味着您还可以让用户“管理”订阅,所以 deeplink 到 link 是:

https://play.google.com/store/account/subscriptions?sku=skuName&package=packageName

2) 用户即将购买订阅:

执行此操作的方法是捕获您在 Play 控制台中创建的 SUBS IAP 的 productIdSku。然后你构建flowParams,然后你可以调用

val flowParams = BillingFlowParams.newBuilder()
            .setSkuDetails(skuDetails)
            .build()

billingClient.launchBillingFlow(activity, flowParams)

如果成功,这意味着你得到了两个东西:BillingResultMutableList<Purchase>。如果BillingResultOK,且返回的列表不为空,则购买成功。此对象也有 skupackageName,因此您按照与上面相同的深度 link 为用户 Manage 他们的订阅。

3) 用户取消了他们的订阅,并且他们的订阅已经过期但是在here[=]规定的任何Resubscribe期限内37=]

这就是你表现得这么深的时候link:

https://play.google.com/store/account/subscriptions,这样他们就可以恢复或重新订阅之前的 Sku

p.s。需要注意的一件事是 Play Store 应用程序支持多个用户。所以 deeplink 只有在 Play Store 应用程序选择了正确的用户时才会起作用。