If you have a tokenized paywall, skip this section — it's only relevant for regular paywalls.
In the paywall settings, you can specify a trial period based on time or number of actions.
If Trial Actions is set to 5, then when calling paywall.open(), the paywall won't open for the first 5 times. If you set a trial period of 24 hours, the paywall won't open via paywall.open() for 24 hours from the first call.
Code example with trial actions set to 5:
try { await paywall.open(); // the paywall opened, trial actions have ended } catch (errorState: State) { // paywall didn't open if (error.visibility_status_reason: 'openings-trial') { // Trial actions have not expired } else { // Optionally, you can also handle other events if desired, for example, the paywall may not open if the user's country does not match the paywall's targeting settings or if the user has closed the paywall } }
interface State { visibility_status?: 'init' | 'invisible' | 'visible'; purchase_status?: 'init' | 'paid' | 'failed'; auth_status?: 'init' | 'signed-in' | 'signed-out' | 'failed'; visibility_status_reason?: | 'openings-trial' | 'time-trial' | 'country-not-match' | 'visibility-turned-off' | 'closed-by-user' | 'active-payment-found' | 'success-payment' | 'tokenization-sign-in' | 'error'; purchase_status_reason?: | 'restored' | 'active-payment-found' | 'success-payment'; user?: {}; subscription?: {}; payment?: {}; }
Visibility status reasons
REASON | DESCRIPTION |
openings-trial | When calling paywall.open() , if the type of trial specified in the paywall settings is "number of trial actions" and the user's actions have not exceeded the specified number, the paywall will not open. |
time-trial | When calling paywall.open() , if the type of trial specified in the paywall settings is "trial time" and the user's first time open have not exceeded the specified time in hours, the paywall will not open. |
country-not-match | The user's country does not match the country specified in the paywall settings. |
visibility-turned-off | Paywall’s visibility setting is turned off. |
closed-by-user | The user closed the paywall. |
active-payment-found | The user's purchase has been restored after the account recovery. |
success-payment | The user made a purchase. |
tokenization-sign-in | The user is authenticated, which triggers when tokenization is enabled. |
error | An error occurred. |