Prepare paywall for display. This method should ideally be called every time before calling NamiPaywallManager.raisePaywall()
This method helps you ensure that all data is available for the paywall before displaying it!
NamiPaywallManager.preparePaywallForDisplay(developerPaywallID: String, backgroundImageRequired: Bool, imageFetchTimeout: Float) { (success: Bool, error: Error?) in
// raise paywall if success is true
}
[NamiPaywallManager preparePaywallForDisplayWithDeveloperPaywallID:@"Paywall1" backgroundImageRequired:BOOL imageFetchTimeout:10.0 prepareHandler:^((BOOL) success, (NSError * _Nullable) error) {
// display paywall or handle error
}];
[NamiPaywallManager preparePaywallForDisplayWithBackgroundImageRequired:BOOL imageFetchTimeout:FLOAT prepareHandler:^((BOOL) success, (NSError * _Nullable) error) {
// display paywall or handle error
}];
NamiPaywallManager.preparePaywallForDisplay { success, error ->
// RaisePaywall if success or react to error
}
NamiPaywallManager.preparePaywallForDisplay(new NamiResultCallback<PreparePaywallResult>() {
@Override
public void invoke(PreparePaywallResult result) {
result.onSuccessOrElse(new NamiSuccessHandler() {
@Override
public void invoke() {
NamiPaywallManager.raisePaywall(activity);
}
}, new NamiFailureHandler<PreparePaywallError>() {
@Override
public void invoke(@NonNull PreparePaywallError error) {
Log.d("TAG", "preparePaywallForDisplay Error -> " + error);
}
});
}
});
var preparePaywallResult = await NamiPaywallManager.preparePaywallForDisplay();
Optional Parameters:
- A [developerPaywallId] if you want to prepare a specific paywall before raising it.
- A bool for [backgroundImageRequired] to force whether background image is required to display paywall or not. By default it is
false
. If passed astrue
then sdk would try to re-fetch the background image and invoke callback based on image availability - An optional timeout [imageFetchTimeout] in
seconds
value for above image fetching operation
The error returned may be one of several possibilities, each with a specific error code:
Code | Description |
---|---|
0 | Paywall already displayed |
1 | Paywall data not available |
2 | No campaign is live |
3 | Image load failed, and the flag was set to require an image be loaded. |
4 | The Paywall Developer ID used was not found in your Nami config, check to make sure the value you entered matches the paywall developer ID specified in the Nami Control Center. |
5 | The SDK is not yet initialized, make sure you call Nami.configure() before this call. |