【发布时间】:2023-02-11 07:55:58
【问题描述】:
如果订阅的付款被拒绝,我正在尝试实施应用内消息传递以显示小吃店。
跟随documentation here 并添加billingClient.showInAppMessages 似乎不起作用。我使用 Test card, always approves 订阅并将其更改为 Test card, always declines 并等待付款进入宽限期,但即使在重新启动应用程序后,文档中的小吃店也没有出现。
应用程序内消息传递的工作原理是我可以通过 firebase 发送消息,但我不确定我是否遗漏了一些明显的东西?
执行: (这在应用程序启动时调用)
// onCreate
billingClient = createBillingClient()
setupInAppMessaging(activity)
if (!billingClient.isReady) {
logD { "BillingClient: Start connection..." }
billingClient.startConnection(this)
}
fun createBillingClient() = BillingClient.newBuilder(context)
.setListener(this)
.enablePendingPurchases()
.build()
fun setupInAppMessaging(activity: Activity) {
val inAppMessageParams = InAppMessageParams.newBuilder()
.addInAppMessageCategoryToShow(InAppMessageParams.InAppMessageCategoryId.TRANSACTIONAL)
.build()
billingClient.showInAppMessages(activity, inAppMessageParams) { inAppMessageResult ->
if (inAppMessageResult.responseCode == InAppMessageResult.InAppMessageResponseCode.NO_ACTION_NEEDED) {
// The flow has finished and there is no action needed from developers.
logD { "SUBTEST: NO_ACTION_NEEDED"}
} else if (inAppMessageResult.responseCode == InAppMessageResult.InAppMessageResponseCode.SUBSCRIPTION_STATUS_UPDATED) {
logD { "SUBTEST: SUBSCRIPTION_STATUS_UPDATED"}
// The subscription status changed. For example, a subscription
// has been recovered from a suspend state. Developers should
// expect the purchase token to be returned with this response
// code and use the purchase token with the Google Play
// Developer API.
}
}
}
【问题讨论】:
标签: android kotlin google-play