Implement CECardADRequestDelegate to handle ad loaded event.
#pragma mark - CECardADRequestDelegate
- (void)cardADDidLoaded:(CECardAD*)cardAD
{
// Called when ad is ready.
UIView *view = cardAD.adUIView; // Add this to view hierarchy.
}
- (void)cardADDidFail:(CECardAD *)cardAD withError:(NSError *)error {
NSLog(@"Failed to load cardAD:%@", error);
}
Add CECardADEventDelegate to get the ad event callback.
If you want to trace the click, impression, progress event, please implement CECardADEventDelegate to handle it.
/*!
* @brief protocol CECardADEventDelegate that can receive AD events
*/
@protocol CECardADEventDelegate <NSObject>
@optional
/*!
* @brief callback while this card ad is clicked by user
*
* @param cardAD CECardAD instance that own this card ad component
*/
- (void) cardADDidClick:(nonnull CECardAD *)cardAD;
/*!
* @brief callback while card ad is about to log impression
*
* @param cardAD CECardAD instance that own this card ad component
*/
- (void) cardADWillTrackImpression:(nonnull CECardAD *)cardAD;
/*!
* @brief callback while this card ad is video format and muted.
*
* @param cardAD CECardAD instance that own this card ad component
*/
- (void) cardADDidMute:(nonnull CECardAD *)cardAD;
/*!
* @brief callback while this card ad is video format and unmuted.
*
* @param cardAD CECardAD instance that own this card ad component
*/
- (void) cardADDidUnmute:(nonnull CECardAD *)cardAD;
/*!
* @brief callback while this card ad is video format and start playback.
*
* @param cardAD CECardAD instance that own this card ad component
*/
- (void) cardADDidVideoStart:(nonnull CECardAD *)cardAD;
/*!
* @brief callback while this card ad is video format and playback to end.
*
* @param cardAD CECardAD instance that own this card ad component
*/
- (void) cardADDidVideoEnd:(nonnull CECardAD *)cardAD;
/*!
* @brief callback while this card ad is video format and progress state.
*
* @param cardAD CECardAD instance that own this card ad component
* @param totalDuration this video total duration time (ms)
* @param currentPosition this video current play back position time (ms)
*/
- (void) cardADDidVideoProgress:(nonnull CECardAD *)cardAD
duration:(int)totalDuration
position:(int)currentPosition;
/*!
* @brief callback while this card ad ad view ready to do animation
*
* @param cardAD CECardAD instance that own this card ad component
* @param adView current display ad view
*/
- (void) cardADOnPullDownAnimation:(nonnull CECardAD *)cardAD withAdView:(nullable UIView *)adView;
/**
* @brief callback while this card ad is failed to render
*
* @param cardAD CECardAD instance that own this card ad component
* @param error Error for rendering
*/
- (void) cardADOnFailedToRender:(nonnull CECardAD *)cardAD error:(nonnull NSError *)error;
@end