presentPaywallIfNeeded static method
Presents the paywall as an activity on android or a modal in iOS as long as the user does not have the given entitlement identifier active. Returns a PaywallResult indicating the result of the paywall presentation.
@param requiredEntitlementIdentifier Entitlement identifier to check if the user has access to before presenting the paywall.
@param offering If set, will present the paywall associated to the given Offering.
@param displayCloseButton Optionally present the paywall with a close button. Only available for original template paywalls. Ignored for V2 Paywalls.
@param customVariables A map of custom variable names to their values. These values can be used for text substitution in paywalls using the {{ custom.variable_name }} syntax.
Implementation
static Future<PaywallResult> presentPaywallIfNeeded(
String requiredEntitlementIdentifier, {
Offering? offering,
bool displayCloseButton = false,
Map<String, CustomVariableValue>? customVariables,
}) async {
final presentedOfferingContext = offering?.availablePackages
.elementAtOrNull(0)
?.presentedOfferingContext;
final result = await _methodChannel.invokeMethod('presentPaywallIfNeeded', {
'requiredEntitlementIdentifier': requiredEntitlementIdentifier,
'offeringIdentifier': offering?.identifier,
'presentedOfferingContext': presentedOfferingContext?.toJson(),
'displayCloseButton': displayCloseButton,
'customVariables': convertCustomVariablesToStrings(customVariables),
});
return _parseStringToResult(result);
}