Pangle: A global platform dedicated to developer growth.|Integration Docs
Knowledge Center

Banner Ads

Introduction

Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen.

Note: Pangle only supports 300x250(dp) and 320x50(dp) for traffic outside of Chinese Mainland at this time. And Pangle will not support refresh interval by client SDK after v46.

Precondition

Create an app and banner ad placement on 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. Display 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 a PAGBannerAdLoadListener to be notified when ad loading succeeds or fails. The loaded PAGBannerAd object is provided as a parameter in the success callback.

Create PAGBannerRequest object

PAGBannerRequest is a 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 PAGBannerAdLoadListener callback.

The description of PAGBannerAdLoadListener callback

PAGBannerAdLoadListener

description

onError

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

onAdLoaded

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.

Display the Ad

After the advertisement is loaded successfully, an instance of the PAGBannerAd object is returned. Call the getBannerView of the PAGBannerAd object to obtain the View of the Banner advertisement. After adding BannerView to the ViewContainer (such as FrameLayout), the advertisement can be displayed automatically.

Distroy the Ad

When destroying the ad, call destroy() of TTNativeExpressAd. This method needs to be called on the main thread.

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.