Help Center/Details/

Template rendering Banner

Introduction

Template rendering Banner: It is a small bar advertisement displayed at the bottom or top of the content. Banner ads should not be placed in text, images and other clickable parts of the application to avoid mistakes

Supported ad sizes: Supports 8 sizes including 600*300, 600*400, 600*500, 600*260, 600*90, 600*150, 640*100, 690*388 , The developer selects according to the display scene. The created size does not support modification

Permission:

**Template Banner Ads: ** Provided by default

  1. When carousel: Yes When the carousel function is selected, the client does not need to implement the operation of re-requesting at a certain interval by itself. The carousel function is implemented internally by the SDK. The client only needs to ensure that the advertisement is displayed in time. Carousel interval is between 30s~120s
  2. When carousel: No When the carousel function is not selected, the client can realize the carousel effect by itself, such as re-requesting advertisements at a certain interval to ensure that the advertisement content is new content within a certain interval. The ad request interval is recommended to be consistent with the carousel function implemented by the platform, and the request interval is between 30s and 120s

Template Banner Ads

Instructions for use

The template banner uses the BUNativeExpressBannerView object to call loadAdData to request the advertisement, and uses addSubview to add the advertisement object to display the advertisement. By setting the BUNativeExpressBannerViewDelegate agent, get the advertisement, display, click, and close Wait for callback.

Create an ad slot object, request an ad

BUNativeExpressBannerView

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
slotID Code bit NSString Code bit ID
adSize Ad size CGSize Ad size, the size set must be in the same proportion as the media platform configuration

Use BUNativeExpressBannerView to create an object, use BUNativeExpressBannerView to call loadAdData to request ads

    UIWindow *window = nil;
    if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) {
        window = [[UIApplication sharedApplication].delegate window];
    }
    if (![window isKindOfClass:[UIView class]]) {
        window = [UIApplication sharedApplication].keyWindow;
    }
    if (!window) {
        window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    }
    CGFloat bottom = 0.0;
    if (@available(iOS 11.0, *)) {
        bottom = window.safeAreaInsets.bottom;
    } else {
        // Fallback on earlier versions
    }
    
    NSValue *sizeValue = [self.sizeDcit objectForKey:slotID];
    CGSize size = [sizeValue CGSizeValue];
self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:slotID rootViewController:self adSize:CGSizeMake(screenWidth, bannerHeigh)];
self.bannerView.frame = CGRectMake(0, self.view.height-bannerHeigh, screenWidth, bannerHeigh);
self.bannerView.delegate = self;
[self.bannerView loadAdData];

Optional parameters:

Field Definition Field Name Field Type Remarks
interval Carousel interval NSInteger The carousel interval is between 30s and 120s, and the shortest carousel time is 2.5s

Remarks: This parameter needs to be set when the media platform selects the carousel function, and the time interval is between 30s and 120s

    UIWindow *window = nil;
    if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) {
        window = [[UIApplication sharedApplication].delegate window];
    }
    if (![window isKindOfClass:[UIView class]]) {
        window = [UIApplication sharedApplication].keyWindow;
    }
    if (!window) {
        window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    }
    CGFloat bottom = 0.0;
    if (@available(iOS 11.0, *)) {
        bottom = window.safeAreaInsets.bottom;
    } else {
        // Fallback on earlier versions
    }
    
    NSValue *sizeValue = [self.sizeDcit objectForKey:slotID];
    CGSize size = [sizeValue CGSizeValue];
// important: upgrade users please note that the initialization method removes the imgSize parameter
    self.bannerView = [[BUNativeExpressBannerView alloc] initWithSlotID:realSlotId rootViewController:self adSize:size interval:30];
    self.bannerView.frame = CGRectMake((self.view.width-size.width)/2.0, self.view.height-size.height-bottom, size.width, size.height);
   self.bannerView.delegate = self;
   [self.bannerView loadAdData];

Receive ads loading results

BUNativeExpressBannerViewDelegate

Callback Method Notes
nativeExpressBannerAdView:didLoadFailWithError The returned error code (error) indicates the reason why the ad failed to load. Please see the link for details of all error codes. Link
nativeExpressBannerAdViewRenderFail Rendering failure, network or hardware reasons cause rendering failure, you can replace the mobile phone or network environment test. It is recommended to upgrade to the latest version of the CSJ platform
nativeExpressBannerAdViewDidLoad Callback for successful ad loading
nativeExpressBannerAdViewRenderSuccess Render success callback

BUNativeExpressBannerViewDelegate callback description

Callback Method Notes
nativeExpressBannerAdViewDidLoad:bannerAdView Callback for successful loading
nativeExpressBannerAdView: didLoadFailWithError: The returned error code (error) indicates the reason why the ad failed to load. Please refer to the link for details of all error codes. Link
nativeExpressBannerAdViewRenderSuccess: Rendering success callback
nativeExpressBannerAdViewRenderFail:error: Rendering failed, the rendering failed due to network or hardware reasons, you can change the mobile phone or network environment to test. It is recommended to upgrade to the latest version of the CSJ platform
nativeExpressBannerAdViewWillBecomVisible: This method is called when a new ad is displayed
nativeExpressBannerAdViewDidClick: Click callback
nativeExpressBannerAdView:dislikeWithReason: dislike callback method, you need to remove the advertisement in this callback method, and set the advertisement object to nil. If this callback method is not implemented, the close button will not take effect
nativeExpressBannerAdViewDidCloseOtherController: interactionType: This callback is called when the ad jumps to another controller and the controller is closed. InteractionType: This parameter can be distinguished from the open appstore/webpage/detail page, etc.

By setting BUNativeExpressBannerViewDelegate agent, get callbacks such as advertisement, display, click, and close. For other proxy methods, please refer to the section of BUDExpressBannerViewController class#pragma ---BUNativeExpressBannerViewDelegate in Demo

Display ads

Use addSubview to add ad objects to display ads. It is recommended that developers display Banner ads after receiving nativeExpressBannerAdViewRenderSuccess callbacks, to ensure smooth playback and smooth display, and a better user experience .

Display Banner Ads

-(void)showBanner {
    [self.view addSubview:self.bannerView];
}

Timing

After receiving the nativeExpressBannerAdViewRenderSuccess callback, the advertisement is displayed, which can ensure smooth playback and smooth display, and a better user experience.

-(void)nativeExpressBannerAdViewRenderSuccess:(BUNativeExpressBannerView *)bannerAdView {
 //Ads are displayed in this callback method to ensure smooth playback and smooth display, and a better user experience.
}

Dislike callback description

-(void)nativeExpressAdView:(BUNativeExpressAdView *)nativeExpressAdView dislikeWithReason:(NSArray<BUDislikeWords *> *)filterWords {
    //[Important] You need to remove the view in this callback after clicking the fork, otherwise, the user may click the fork to be invalid
    [self.expressAdViews removeObject:nativeExpressAdView];
    NSUInteger index = [self.expressAdViews indexOfObject:nativeExpressAdView];
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:index inSection:0];
    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

-(void)nativeExpressBannerAdViewDidRemoved:(BUNativeExpressBannerView *)nativeExpressAdView {
//[Important] If the developer receives this callback, it means that the CSJ will actively close the ad. After the ad is removed, the developer needs to adapt the interface
  [UIView animateWithDuration:0.25 animations:^{
    nativeExpressAdView.alpha = 0;
  } completion:^(BOOL finished) {
    [nativeExpressAdView removeFromSuperview];
    self.bannerView = nil;
  }];
  self.selectedView.promptStatus = BUDPromptStatusDefault;
}

Precautions

  1. To avoid the situation of displaying ads first and then requesting data, banner ads are displayed by using addSubview to add ad objects to display ads
  2. When implementing the carousel function by yourself, it is recommended to keep the same as the platform carousel interval. The request interval is between 30s~120s to avoid the scenario of too frequent advertisement requests. The minimum rotation interval should not be less than 2.5s* *
  3. When the media platform selects the carousel function, the client can request and display advertisements, and the subsequent implementations are implemented internally by the SDK
  4. At present, the banner advertisement supports the display at the bottom or the top center of the content. Developers can adjust the left and right margins by themselves.

resource

For detailed access, please refer to the BUDExpressBannerViewController class in Demo, refer to the loadBannerWithSlotID method for the advertisement loading request part, and the showBanner method for the advertisement display part.

Did the content solve your problem?
Contact us