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

Rewarded Video Ads

Introduction

Rewarded Video is an immersive, full-screen video advertisement that presents a value proposition to users by providing incentives upon watching the video. With Pangle's robust rewarded video ad offerings, publishers can tailor their ads to a variety of formats that best suit their specific needs. At present, the forms of Pangle rewarded video ads can:

  • Display an Endcard after the video.
  • Display a playable ad after the video.
  • Display a playable ad directly.

Precondition

Create an app and reward video ad placement on the Pangle platform

Pangle Platform Parameter Setting:

  • Orientation: Select the orientation of the video.
  • Reward amount: Enter the number of reward items the user will receive. Must be a whole number.
  • Reward item: Enter the name of the reward item the user will receive. Examples: Coins, extra lives.
  • Reward deliver setting: Validate each completed rewarded video ad view by the third-party server and ensure you're only rewarding users who have actually finished watching the video in your app.

Rewarded Video Implementation

The main steps to integrate rewarded video ads are:

  1. Create PAGRewardedRequest object
  1. Load a Rewarded ad and Register PAGRewardedAdDelegate callbacks.
  1. Display the ad.

Load a Rewarded Ad

Loading an ad is accomplished using the loadAdWithSlotID: request: completionHandler:() method in the PAGRewardedAd class. The method requires an ad slot id, an instance object of PAGRewardedRequest, and a completionHandler to be notified when ad loading succeeds or fails. The loaded PAGRewardedAd object is provided as a parameter in the success callback.

Create PAGRewardedRequest object

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

Load an ad and Register completionHandler callback

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

The description of callback

callback

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.

rewardedAd

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

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

PAGRewardedAdDelegate

description

- (void)adDidShow:(PAGRewardedAd *)ad

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

- (void)adDidClick:(PAGRewardedAd *)ad

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

- (void)adDidDismiss:(PAGRewardedAd *)ad

This method is invoked when the ad disappears.

- (void)rewardedAd:(PAGRewardedAd *)rewardedAd userDidEarnReward:(PAGRewardModel *)rewardModel

The method is invoked when the user should be rewarded.

- (void)rewardedAd:(PAGRewardedAd *)rewardedAd userEarnRewardFailWithError:(NSError *)error

The method is invoked when the user rewarded failed.

Display the Ad

An instance of the PAGRewardedAd object will be returned when the ad is loaded successfully. Call the presentFromRootViewController: method of PAGRewardedAd to show 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.

Server-Side Reward Verification Callback

Note:The Server-side verification is not necessary. Server-side verification acts as an additional layer of validation for rewarded ad views in your app. It’s performed in addition to the standard client-side callback. You can use server-side verification to validate each completed rewarded video ad view and ensure you're only rewarding users who have actually finished watching the video in your app.

The server-side verification callback will append query parameters to your postback url describing the rewarded video interaction:&trans_id=%s&reward_name=%s&reward_amount=%d&extra=%s&sign=%s

Field Name

Field Definition

Field Type

Remarks

sign

signSignature of the request

string

Signature of the request guarantees security

trans_id

Transaction id

string

Unique transaction ID for completing viewing the ad

reward_amount

number of rewards

int

Pangle platform configuration

reward_name

Name of rewards

string

Pangle platform configuration

extra

Extra

string

Call SDK input and pass-through. Leave it empty if not needed.

Signature Generation:

  • appSecurityKey: The key you get for adding rewarded video ad code bit on the Pangle Network
  • transId: transaction id
  • sign: sha256(appSecurityKey:transId)

Python sample:

Return:

Returns json data with the following fields:

Field Definition

Field Name

Field Type

Remarks

isValid

Validation result

BOOL

determines the result, whether to award or not

Instance:

Note

  1. All the rootViewController parameters in Ad APIs must be provided to process ad redirects. In the SDK, all redirects use the present method of UIViewController. Therefore, make sure that the passed rootViewController parameters are not null and do not have other present controllers. Otherwise the present will fail because presentedViewController already exists.
  1. Select the server callback, please ensure that the type of userid is NSString and not empty. The callback URL instance
  1. In order to ensure smooth playback and display, we recommend checking the rewardedVideoAdVideoDidLoad: callback before showing the ad to verify if the video is finished loading and cached successfully.
  2. The extra , a property of object PAGRewardedVideoModel should be a string serialized by JSON to ensure that it is not null.
  3. The isAdValid method has been deprecated since V3.3.0.0. Please do not use this field to verify whether the reward video ad is valid.