Я планирую использовать в моем приложении Android SDK BillingClient , чтобы получить регион Play Store пользователя. Тем не менее, мое приложение не включает в себя какие-либо функции покупки в приложении. Strong> Google Play политики? область?implementation "com.android.billingclient:billing:6.1.0"
< /code>
code: < /p>
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()
}
< /code>
Перед тем, как его реализовать, я хочу убедиться, что мое приложение не столкнется с отказом для интеграции BillingClient без покупок в приложении. Я не думаю, что на самом деле есть альтернативный способ этого ... кто -то знает что -нибудь об этом?>
Подробнее здесь: https://stackoverflow.com/questions/794 ... -in-app-pu