Help Center/Details/

Template rendering Draw video Ads

Introduction:

Template rendering Draw: The scene should be displayed interspersed with the application content in the application content stream, and the Draw information stream advertisement is displayed in full screen by default.

Supported ad size: portrait video (aspect ratio 16:9) & landscape video (aspect ratio 9:16)

Permission:

**Template rendering of Draw video ads: ** Provided by default

Template rendering Draw information flow advertisement

Instructions for use

The template Draw information flow advertisement uses the BUNativeExpressAdManager object to call loadAd to request the advertisement, and the BUNativeExpressAdView object to render the advertisement render, and obtain it by setting the BUNativeExpressAdViewDelegate agent Advertisement, display, click, and close callbacks.

Create an ad slot object and request an ad

BUNativeExpressAdManager

You need to pass in the ad slot object when requesting an ad, and the ad slot ID must be passed in when the ad slot object is created

Required parameters:

Field Definition Field Name Field Type Remarks
BUAdSlot / / Basic information configuration, see case for details
adSize Ad size CGSize Ad size, default full screen display

Before requesting ads, you need to configure the basic information of BUAdSlot ads, use BUNativeExpressAdManager to create objects, and use BUNativeExpressAdManager to call loadAd to request ads

 BUAdSlot *slot1 = [[BUAdSlot alloc] init];
 slot1.ID = self.viewModel.slotID;
 slot1.AdType = BUAdSlotAdTypeDrawVideo; //required
 slot1.isOriginAd = YES; //required
 slot1.position = BUAdSlotPositionTop;
 slot1.imgSize = [BUSize sizeBy:BUProposalSize_DrawFullScreen];
  if (!self.nativeExpressAdManager) {
       self.nativeExpressAdManager = [[BUNativeExpressAdManager alloc] initWithSlot:slot1 adSize:self.view.bounds.size];
    }
  self.nativeExpressAdManager.adSize = self.view.bounds.size;
  self.nativeExpressAdManager.delegate = self;
  [self.nativeExpressAdManager loadAdDataWithCount:count];

Notice:

  1. self.nativeExpressAdManager can be reused
  2. Template Draw information flow advertising size adSize default full screen display
  3. The template Draw information flow advertisement can request multiple advertisements at the same time, the maximum number of requests is 3**

Display ads

Since the official Demo uses tableView for the insertion and display of advertisements, you can directly update the data source to update the relevant insertion and display of the advertisement. It is recommended that the developer perform the rendering and display of the advertisement after receiving the nativeExpressAdSuccessToLoad callback to ensure playback. Smooth and smooth display, better user experience.

Show Draw information flow advertisement

After receiving the nativeExpressAdSuccessToLoad callback, the advertisement will be rendered and displayed, and the data source will be refreshed.

-(void)nativeExpressAdSuccessToLoad:(BUNativeExpressAdManager *)nativeExpressAd views:(NSArray<__kindof BUNativeExpressAdView *> *)views {
    if (views.count) {
        NSMutableArray *dataSources = [self.dataSource mutableCopy];
        [views enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            BUNativeExpressAdView *expressView = (BUNativeExpressAdView *)obj;
            expressView.rootViewController = self;
            // important: WKWebview will be rendered here. It is recommended to preload at most three ads at a time. If there are more than 3, it will cause WKWebview rendering to fail.
            [expressView render];
            NSUInteger index = rand()% (self.dataSource.count-3)+2;
            [dataSources insertObject:expressView atIndex:index];
        }];
        self.dataSource = [dataSources copy];
    }
    [self.tableView reloadData];
}

Precautions

  1. self.nativeExpressAdManager can be reused
  2. Template Draw information flow advertising size adSize default full screen display
  3. The template Draw information flow advertisement can request multiple advertisements at the same time, the maximum number of requests is 3**

resource

For detailed access, please refer to the BUDExpressDrawViewController class in Demo, refer to the loadData method for the advertisement loading request part, and the nativeExpressAdSuccessToLoad method for the advertisement display rendering part.

Did the content solve your problem?
Contact us