最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Can I use the BillingClient SDK to fetch the Play Store region without in-app purchases? - Stack Overflow

programmeradmin6浏览0评论

I am planning to use the BillingClient SDK in my Android app to fetch the user's Play Store region. However, my app does not include any in-app purchasing features.

Is it still acceptable to use the BillingClient SDK for this purpose, or would it violate Google Play policies?

Would my app risk rejection if I integrate BillingClient solely for retrieving the store region?

Any insights or alternative solutions would be greatly appreciated.

in build.gradle(app)

implementation "com.android.billingclient:billing:6.1.0"

code:

object PlayStoreUtil {
    @JvmStatic
    fun fetchPlayStoreRegion(context: Context, callback: PlayStoreRegionCallback) {
        val purchasesUpdatedListener = PurchasesUpdatedListener { _, _ ->
        }

        val billingClient = BillingClient.newBuilder(context)
            .setListener(purchasesUpdatedListener)
            .enablePendingPurchases()
            .build()

        billingClient.startConnection(object : BillingClientStateListener {
            override fun onBillingSetupFinished(billingResult: BillingResult) {
                if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
                    val billingConfigParams = GetBillingConfigParams.newBuilder().build()
                    billingClient.getBillingConfigAsync(billingConfigParams) { _, billingConfig ->
                        if (billingResult.responseCode == BillingClient.BillingResponseCode.OK && billingConfig != null) {
                            val playStoreCC = billingConfig.countryCode
                            callback.onCountryCodeFetched(playStoreCC)
                        } else {
                            callback.onFailure()
                        }
                    }
                    billingClient.endConnection()
                } else {
                    callback.onFailure()
                    billingClient.endConnection()
                }
            }

            override fun onBillingServiceDisconnected() {
                callback.onFailure()
                billingClient.endConnection()
            }
        })
    }
}

interface PlayStoreRegionCallback {
    fun onCountryCodeFetched(countryCode: String)
    fun onFailure()
}

Before implementing it, I want to ensure that my app won’t face rejection for integrating BillingClient without in-app purchases. I don't think there is actually an alternative way for this...does someone know anything about this ??

发布评论

评论列表(0)

  1. 暂无评论