Class name: ATCocosSdk
| API | Parameter description | Function description |
|---|---|---|
| loadRewardedVideoAd | const char * placementId, cocos2d::ValueMap parameters | Used to load rewarded video ads, unitId is the ad slot id; parameters can set information for third-party platforms for incentives |
| showRewardedVideoAd | const char * placementId | Display rewarded video ads in designated ad slots |
| showRewardedVideoAdInScenario | const char * placementId, const char * scenario | Display rewarded video ads in designated ad slots, where scenario is the ad display scenario, and scenario parameters can be created from the background |
| isRewardedVideoAdReady | const char * placementId | Determine whether the ads in the specified ad slot have been loaded |
| checkRewardedVideoAdStatus | const char * placementId | Get 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 |
| setRewardedVideoAdListener | ATCocosRewardedVideoAdListener * listener, const char * placementId | Set callback object |
Interface name: ATCocosRewardedVideoAdListener
| API | Parameter description | Function description |
|---|---|---|
| onRewardedVideoLoadSuccess | const char * placementId | Ad loading completed |
| onRewardedVideoLoadFailed | const char * placementId, const char * errorString | Ad loading failed, errorString is the reason for the loading failure |
| onRewardedVideoClickedWithExtra | const char * placementId,const char * extra | Incentive video generates clicks extra contains the current ad Additional information |
| onRewardedVideoPlayStartWithExtra | const char * placementId,const char * extra | Video playback starts extra contains other information about the current ad |
| onRewardedVideoPlayEndWithExtra | const char * placementId,const char * extra | Video playback ends extra contains other information about the current ad |
| onRewardedVideoShowFailWithExtra | unitId: char , errorMsg: char ,const char * extra | Video playback failed, errorMsg is the reason for the loading failure. extra contains other information about the current advertisement. Information |
| onRewardedVideoCloseWithExtra | const char * placementId, bool isRewarded,const char * extra | Video 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 |
| onRewardedVideoDidRewardSuccessWithExtra | const char * placementId,const char * extra | Whether to generate incentives extra contains other information about the current advertisement |
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");
}