Skip to content

Commit

Permalink
fix: isBillingClientConnected issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4rl3x committed Aug 7, 2024
1 parent b16d167 commit e73f54b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion billing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apply from: '../_ktlint.gradle'

ext {
PUBLISH_GROUP_ID = 'de.charlex.billing'
PUBLISH_VERSION = '7.0.0-1.0.1'
PUBLISH_VERSION = '7.0.0-1.0.2'
PUBLISH_ARTIFACT_ID = 'billing-suspend'
}

Expand Down
4 changes: 3 additions & 1 deletion billing/src/main/java/de/charlex/billing/BillingHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.android.billingclient.api.queryPurchasesAsync
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand Down Expand Up @@ -96,7 +97,8 @@ class BillingHelper(

private suspend fun isBillingClientConnected(): Boolean =
withTimeoutOrNull(5_000) {
billingClientStatus.firstOrNull() == BillingClient.BillingResponseCode.OK
billingClientStatus.first { it == BillingClient.BillingResponseCode.OK }
true
} ?: false

suspend fun BillingClient.endConnection() = withContext(Dispatchers.Main) {
Expand Down

0 comments on commit e73f54b

Please sign in to comment.