Menu

Rewarded Ads

1.1 API Description

Class name: ATCocosSdk

APIParameter descriptionFunction description
loadRewardedVideoAdconst char * placementId, cocos2d::ValueMap parametersUsed to load rewarded video ads,
unitId is the ad slot id;
parameters can set information for third-party platforms for incentives
showRewardedVideoAdconst char * placementIdDisplay rewarded video ads in designated ad slots
showRewardedVideoAdInScenarioconst char * placementId, const char * scenarioDisplay rewarded video ads in designated ad slots, where scenario is the ad display scenario, and scenario parameters can be created from the background
isRewardedVideoAdReadyconst char * placementIdDetermine whether the ads in the specified ad slot have been loaded
checkRewardedVideoAdStatusconst char * placementIdGet the current ad status (Json string):
1. isLoading: whether it is loading
2. isReady: whether there is an ad cache (same function as isRewardedVideoAdReady)
3. AdInfo: the current highest priority ad cache Information
setRewardedVideoAdListenerATCocosRewardedVideoAdListener * listener, const char * placementIdSet callback object

1.2 Listener callback method description

Interface name: ATCocosRewardedVideoAdListener

APIParameter descriptionFunction description
onRewardedVideoLoadSuccessconst char * placementIdAd loading completed
onRewardedVideoLoadFailedconst char * placementId, const char * errorStringAd loading failed,
errorString is the reason for the loading failure
onRewardedVideoClickedWithExtraconst char * placementId,const char * extraIncentive video generates clicks
extra contains the current ad Additional information
onRewardedVideoPlayStartWithExtraconst char * placementId,const char * extraVideo playback starts
extra contains other information about the current ad
onRewardedVideoPlayEndWithExtraconst char * placementId,const char * extraVideo playback ends
extra contains other information about the current ad
onRewardedVideoShowFailWithExtraunitId: char , errorMsg: char ,const char * extraVideo playback failed,
errorMsg is the reason for the loading failure.
extra contains other information about the current advertisement. Information
onRewardedVideoCloseWithExtraconst char * placementId, bool isRewarded,const char * extraVideo is closed,
isRewarded is whether to generate incentives, possibly There is no normal incentive due to delayed incentives
extra contains other information about the current advertisement
onRewardedVideoDidRewardSuccessWithExtraconst char * placementId,const char * extraWhether to generate incentives
extra contains other information about the current advertisement

1.3 Calling example

1. Load ads

 ATCocosSdk::setRewardedVideoAdListener(this, rvPlacementId);

 cocos2d::ValueMap extra;
 // If you need to deliver rewards through the developer's server (some advertising platforms support server incentives), 
 // you need to pass the following two keys
// ATCocosSdk::KEY_USER_ID,Identifies each user; ATCocosSdk::KEY_MEDIA_EXT,Callback to the developer's server parameters
 extra[ATCocosSdk::KEY_USER_ID] = "test_user_id";//require
 extra[ATCocosSdk::KEY_MEDIA_EXT] = "test_user_data";//option
 ATCocosSdk::loadRewardedVideoAd(rvPlacementId, extra);

2. Display advertising

if (ATCocosSdk::isRewardedVideoAdReady(rvPlacementId)) {
    ATCocosSdk::showRewardedVideoAd(rvPlacementId);

    // Scenario show ad
    //ATCocosSdk::showRewardedVideoAdInScenario(rvPlacementId, YourScenario);
} else {
    CCLOG("ATCocosSdk::isRewardedVideoAdReady is false");
}


Last modified: 2025-05-30Powered by