Ad Lifecycle Callbacks
The SDK provides two callback properties for tracking the advertisement lifecycle:
onAdStart— Called when the advertisement begins showing.onAdEnd— Called when the advertisement has finished.
onAdStart
- The callback is called before the ad display begins.
- Signature:
PortalSDK.onAdStart = () => void - Parameters: None.
- Usage Example:
onAdEnd
- The callback is called after the ad finishes (whether successful or not).
- Signature:
PortalSDK.onAdEnd = (result: boolean) => void - Parameters:
- result (boolean) — true if the ad was shown successfully, false if the ad was not shown (e.g.,
error,cooldown,ads_free, etc.). - Usage Example:
Disabling Callbacks
To disable a callback, set its value to null:
Notes
- Callbacks are triggered for both methods:
requestAd()andrequestRewardAd(). onAdEndis called in all completion scenarios (success,error,cooldown,ads_free).- Callbacks are synchronous — they do not block the execution of the ad display logic.
- By default, both properties are set to null.