Skip to content

Commit

Permalink
Paywalls: fixed PaywallDialog.setRequiredEntitlementIdentifier (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto authored Oct 7, 2023
1 parent b2ffbf3 commit 8cfb938
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import kotlinx.coroutines.launch

/**
* Composable offering a dialog screen Paywall UI configured from the RevenueCat dashboard.
* This dialog will be shown as a full screen dialog in compact devices and a normal dialog othewise.
* This dialog will be shown as a full screen dialog in compact devices and a normal dialog otherwise.
* @param paywallDialogOptions The options to configure the PaywallDialog and what to do on dismissal.
*/
@Composable
Expand All @@ -37,11 +37,7 @@ fun PaywallDialog(
LaunchedEffect(paywallDialogOptions) {
launch {
shouldDisplayDialog = try {
// TODO-PAYWALLS: This won't receive updates in case the customer info changes and starts/stops
// being eligible to display the paywall dialog. We would need to support multiple customer info
// listeners to refresh this.
val customerInfo = Purchases.sharedInstance.awaitCustomerInfo()
shouldDisplayBlock.invoke(customerInfo)
shouldDisplayBlock.invoke(Purchases.sharedInstance.awaitCustomerInfo())
} catch (e: PurchasesException) {
Logger.e("Error fetching customer info to display paywall dialog", e)
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class PaywallDialogOptions(builder: Builder) {
fun setRequiredEntitlementIdentifier(requiredEntitlementIdentifier: String?) = apply {
requiredEntitlementIdentifier?.let { requiredEntitlementIdentifier ->
this.shouldDisplayBlock = { customerInfo ->
customerInfo.entitlements[requiredEntitlementIdentifier]?.isActive == true
customerInfo.entitlements[requiredEntitlementIdentifier]?.isActive != true
}
}
}
Expand Down

0 comments on commit 8cfb938

Please sign in to comment.