穿山甲-全球开发者成长平台|接入文档
搜索
知识中心
本文尚无当前语言版本,相关翻译工作正在进行中,感谢您的理解!

Banner Ads

Introduction

Banner ads refer to a standard advertising format that occupies a designated space within an app's layout, usually positioned either at the top or bottom of the device screen.

[Important Note]: At present, Pangle supports only two specific banner ad sizes for traffic outside of the Chinese Mainland, namely 300x250(dp) and 320x50(dp). It is crucial to ensure that the banner ad placement and size comply with Pangle's specific requirements to ensure optimal ad performance and user experience.

Precondition

Create an app and banner ad placement on the Pangle platform

Banner Ads Implementation

The main steps to integrate banner ads are:

  1. Create PAGBannerRequest object
  1. Load the banner ad, set the rootViewController in the completionHandler callback
  1. set the ad delegate object that follows the PAGBannerAdDelegate and get the bannerView
  1. Display the ad.

Load a banner ad

Loading an ad is accomplished using the + (void)loadAdWithSlotID:request: completionHandler:() method in the PAGBannerAd class. The method requires an ad slot id, instance objects of PAGBannerRequest , and a block. In the block, please set the rootViewController, set the ad delegate of PAGBannerAdDelegate, and get the bannerView. After getting bannerView, choose the right time to add bannerView to your own view.

Create PAGBannerRequest object

Load a banner ad and set PAGBannerAdDelegate

Anchored Adaptive Banner

Note

Only Google bidding and Google AdMob, and Google Ad Manager support adaptive banners. Adaptive Banners and Inline adaptive banners are supported starting with Pangle sdk version 7.1.0.1.

Google recommends that developers include a 50px padding between the banner placement and the app content. This makes it less likely that users will accidentally click on the banner. Refer to Google’s “About Confirmed Click” policy for more information and best practices.

Adaptive banners are responsive banners with heights that derive from the device type and the width of the banner. You integrate adaptive banners in a similar way to how you integrate regular banners.The width passed in cannot exceed the screen width.

Return value

api

description

PAGBannerSize

PAGCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width)

Returns a PAGBannerSize suitable for small banners, with the specified width and a height generated based on the current screen orientation, maintaining a similar aspect ratio to PAGBannerSize. The height will never exceed 15% of the device's current orientation height and will never be less than 50pt. For any width/device combination, this function always returns the same height. If the context is null or the device height cannot be determined from the context, the returned PAGBannerSize width and height will be -1.

Inline Adaptive Banner

Adaptive banners are anchored by default. Alternatively, you can enable inline adaptive banners, which are meant to appear in scrolling content. Inline adaptive banners are typically larger and taller than anchored adaptive banners. They have variable heights that can extend to the full height of the device screen.

Return value

api

description

PAGBannerSize

PAGCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(CGFloat width);

Returns a PAGBannerSize with the specified width and a height of 0. The Pangle server will select the optimal ad size, with the height not exceeding the screen height. The actual ad size can be obtained by calling PAGBannerAd.getBannerSize() in the PAGBannerAdLoadListener.onAdLoaded callback. If the context is null or the device height cannot be determined from the context, the returned PAGBannerSize width and height will be -1.

PAGBannerSize

PAGInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width, CGFloat maxHeight);

Returns a PAGBannerSize with the specified width and a height of 0. The Pangle server will select the optimal ad size with a height not exceeding the maximum height specified in the maxHeight parameter. The actual ad size can be obtained by calling PAGBannerAd.getBannerSize() in the PAGBannerAdLoadListener.onAdLoaded callback.

Register PAGBannerAdDelegate callback

The description of PAGBannerAdDelegate callback

PAGBannerAdDelegate

description

- (void)adDidShow:(PAGBannerAd *)ad

This method is invoked when the ad is displayed, covering the device's screen.

- (void)adDidClick:(PAGBannerAd *)ad

This method is invoked when the ad is clicked by the user.

- (void)adDidDismiss:(PAGBannerAd *)ad

This method is invoked when the ad disappears.

Display the Ad

Test with test ads

Now you have finished the integration. If you wanna test your apps, make sure you use test ads rather than live, production ads. The easiest way to load test ads is to use test mode. It's been specially configured to return test ads for every request, and you're free to use it in your own apps while coding, testing, and debugging.

Refer to the How to add a test device? to add your device to the test devices on Pangle platform.