Native Video

app_show_type: 50012/50013/70017/70018

Here are steps to show Native Video Ads

Add a view with class “CMANativeVideoView” in storyboard/XIB.

Import Header Files

// if CheetahMobileAds.framework
@import CheetahMobileAds;

// else if CheetahMobileAds.a
#import "CMANativeVideoView.h"
#import "CMAPosIDConfig.h"
@property (weak, nonatomic) IBOutlet CMANativeVideoView *videoView;

Setup POSID and AdsView

CMAPosIDConfig *config = [[CMAPosIDConfig alloc] 
    initWithOrionPosID:@"YOUR_POSID" liehuPosID:@"YOUR_POS_ID_FOR_CHINA"];
self.videoView.posIDConfig = config;
self.videoView.rootViewController = self;

Set up event notifications

To set up event notification, insert the line before your load request call.

// Setup delegate.
@interface ViewController ()<CMANativeVideoViewDelegate>

self.videoView.delegate = self;

The following sample illustrates how to log each of the events available in CMANativeVideoViewDelegate:

- (void)nativeVideoViewDidStartPlaying:(CMANativeVideoView *)view;
- (void)nativeVideoViewDidStopPlaying:(CMANativeVideoView *)view;
- (void)nativeVideoViewDidEnterFullScreen:(CMANativeVideoView *)view;
- (void)nativeVideoViewDidExitFullScreen:(CMANativeVideoView *)view;
- (void)nativeVideoViewDidDidLoadVideoFailed:(CMANativeVideoView *)view;

Load Ads

[self.videoView loadAd];

If the ad is loaded successfully, following method will be called!

(void)nativeVideoViewDidLoadAd:(CMANativeVideoView *)view

Show Ads

[self.videoView playNext];

And then, you are good to go.

Last updated