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

Banner

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.

Furthermore, it is worth noting that after version 46, Pangle will not support a client SDK-based refresh interval. As such, it is recommended to stay up-to-date with the latest versions of Pangle and make the necessary adjustments to ensure continued support and optimal ad performance.

Precondition

Create an app and banner ad placement on the Pangle platform

Banner Ads Implementation

  1. Create PAGBannerSize object and PAGBannerRequest object
  1. Load a banner ad and register PAGBannerAdLoadListener callback
  1. Register PAGBannerAdInteractionListener callback
  1. Setting the position of Banner
  1. Display the ad.
  1. Destroy the Ad

Load a Banner Ad

Loading an ad is accomplished using the load() method on the PAGBannerAd class. The load() method requires an ad slot id, instance objects of PAGBannerSizeand PAGBannerRequest, and it will notify you when ad loading succeeds or fails.

Create PAGBannerRequest object

PAGBannerRequest is an Ad Loading Manager. It is recommended to be the member variable of the Activity.

Load an ad and Register PAGBannerAdLoadListener callback

Use the method of PAGBannerAd to load the ad, and register the callback.

The description of PAGBannerAdLoadListener callback

PAGBannerAdLoadListener

description

OnLoadFailed

This method is invoked when an ad fails to load. It includes an error parameter of type Error that indicates what type of failure occurred. For more information, refer to the ErrorCode section

OnLoad

This method is executed when an ad material is loaded successfully.

Register Ad Event Callback

Ad event callbacks need to be registered before displaying an ad. Each method in the event callback corresponds to an event in the ad lifecycle.

The description of PAGBannerAdInteractionListener callback

PAGBannerAdInteractionListener

description

onAdShowed

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

onAdClicked

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

onAdDismissed

This method is invoked when the ad disappears.

Setting the position of Banner

PAGBannerPosition.Top

Centered text, at the top of the interface

PAGBannerPosition.Middle

In the middle of the interface

PAGBannerPosition.Bottom

Centered text, at the bottom of the interface

Display the Ad

Destroy the Ad

Destroy advertisements in time to avoid memory leaks

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 the Pangle platform.