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

Native Ads

Introduction

Native ads allow you to customize the look and feel of the ads that appear in your app. You design the ads: how they look, where they’re placed, and how they work within your existing app design. This differs from other ad formats, which don't allow you to customize the appearance of the ad.

Note: Pangle supports 4 forms outside the chinese mainland: Large image with 1.91:1 ratio、1280*720 video、square image、 square video.

Precondition

Create an app and native ad placement on Pangle platform

Native Ads Implementation

Native ads are ad assets that are presented to users via UI components. It can be formatted to match your app's visual design. When a native ad loads, your app receives an ad object that contains its assets, and the app is then responsible for displaying them.

Broadly speaking, there are three steps to successfully implement Native Ads:

  1. Create PAGNativeRequest object
  1. Load a Native ad
  1. register PAGLNativeAdDelegate callback
  1. Display the ad.

Load an Ad

Loading an ad is accomplished using the load() method on the PAGLNativeAd class. The load() method requires an ad slot id, an instance object of PAGNativeRequest, and a PAGNativeADLoadCompletionHandler to be notified when ad loading succeeds or fails. The loaded PAGLNativeAd object is provided as a parameter in the success callback.

Create PAGNativeRequest object

PAGNativeRequest is a Ad Loading Manager. It is recommended to be the member variable of the Activity.

Load a Native ad and register PAGNativeADLoadCompletionHandler callback

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

The description of PAGNativeADLoadCompletionHandler callback

PAGNativeADLoadCompletionHandler

description

error

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

nativeAd

This object is returned when an ad material is loaded successfully.

Design your native ad layout

Register PAGLNativeAdDelegate 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 PAGLNativeAdDelegate callback

PAGLNativeAdDelegate

description

- (void)adDidShow:(PAGLNativeAd *)ad

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

- (void)adDidClick:(PAGLNativeAd *)ad

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

- (void)adDidDismiss:(PAGLNativeAd *)ad

This method is invoked when the ad disappears.

The description of PAGNativeAd

PAGNativeAd

description

@property (nonatomic, strong, readonly) PAGLMaterialMeta *data;

Returns a PAGLMaterialMeta ad data object

@property (nonatomic, weak, nullable) id<PAGLNativeAdDelegate> delegate;

Set up ad callback delegate

@property (nonatomic, weak) UIViewController *rootViewController;

Set up ad rootViewController

- (void)registerContainer:(__kindof UIView *)containerView

withClickableViews:(NSArray<__kindof UIView *> *_Nullable)clickableViews;

Calling time:The developer must call the PAGLNativeAd ad object before displaying it; this method is used to register ad billing events and ad interaction callback events

Parameter description

container :ad view

clickableViews : Ad component View collection that needs to register for ordinary click events

- (void)unregisterView;

Remove registered advertising billing events and advertising interaction callback events

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.