Skip to main content

useRewardedAd

Use this hook to use Rewarded Ad with its various states.

Arguments

unitId

Your Ad's ad Unit ID

If unitId is set or changed, new ad instance will be created automatically. If unitId is set to null, ad will be destroyed automatically and derived states will be initialized to initial state.

Type
string

options

Options for your hook. Available values are listed below:

Type
FullScreenAdOptions

Properties:

NameTypeDefaultDescription
loadOnMountedbooleantrueWhether your ad to load automatically on mounted.
showOnLoadedbooleanfalseWhether your ad to show automatically on loaded.
loadOnDismissedbooleanfalseWhether your ad to load new ad automatically on dismissed.
requestOptionsRequestOptions{}Optional RequestOptions used to load the ad.

Returns

Type
object

Properties:

NameTypeDescription
adLoadedbooleanWhether your ad is loaded and ready to present.
adPresentedbooleanWhether your ad is presented to user. The value remains true until new ad is requested.
adDismissedbooleanWhether your ad is dismissed. The value remains true until new ad is requested.
adShowingbooleanWhether your ad is showing. The value is equal with adPresented && !adDismissed.
adLoadErrorAdError | undefinedAdError object throwed during ad load.
adPresentErrorAdError | undefinedAdError object throwed during ad present.
rewardReward | undefinedReward earned by user. The value is undefined until user earns reward. Available only in RewardedAd or RewardedInterstitialAd.
loadFunctionLoads new ad.
showFunctionShows loaded ad. Ad must be loaded prior to this call.
tip

Note that adPresented value remains true after the ad is dismissed. The value changes to false when ad is initialized via load(). To determine whether the ad is showing, use adShowing value.

caution

When using with loadOnDismissed option to true, changed adDimissed and reward value will appear for a very short time and initialized to false and undefined respectively as derived states are initialized just after new ad is requested.