Help Center/Details/

[Unity] Admob Custom Event for Pangle

Please set Admob in your app first.

Setup Pangle Platform

Create a Pangle account

Create an application and placements in Pangle

  • Click Apps -> + Add App to create a app for mediation.

create-app-home.png

create-app.png

  • You will get an app with its app ID.

app-id.png

Create Ad Placement

  • Click Ad Placements -> + Add Ad Placement to create the placement for mediation.

create-placement.png

  • Select the ad's type for your app and finish the create.

ad-type.png

  • You will get a placement with its placement ID.

placement-id.png

Add Pangle to AdMob's mediation

Create mediation

  • Click Mediation -> CREATE MEDIATION GROUP to create a mediation group.

add-mediation.png

  • Select the same ad format which created on Pangle side.

ad-format.png

  • After select the ad unit you created on AdMob which you want to embed mediation, click ADD CUSTOM EVENT to set with Pangle.

add-custom-event.png

Set Class Name and Parameter

Set Class Name and Parameter in the mediation setting.

mediation-param.png

Class Name

Copy the contents below to Class Name based on your needs.

Ad Type Class Name for Android Adapter
Reward Video Ads com.google.ads.mediation.sample.customevent.adapter.AdmobRewardVideoAdapter
Interstitial(Fullscreen Video) Ads com.google.ads.mediation.sample.customevent.adapter.AdmobFullScreenVideoAdapter
Banner Ads com.google.ads.mediation.sample.customevent.adapter.AdmobTemplateBannerAdapter
Native Ads com.google.ads.mediation.sample.customevent.adapter.AdmobNativeFeedAdAdapter


Ad Type Class Name for iOS Adapter
Reward Video Ads BUDAdmob_RewardCustomEventAdapter
Interstitial(Fullscreen Video) Ads BUDAdmob_FullScreenVideoCustomEventAdapter
Banner Ads BUDAdmob_BannerCustomEventAdapter
Native Ads BUDAdmob_NativeFeedCustomEventAdapter



Parameter

Add {"placementID":"your slot ID"} to Parameter.

  • Parameter: Add {"placementID":"your placement ID on Pangle"} to Parameter , for example,{"placementID":"1234567"}
  • Please make sure to use JSON to set Parameter. Or you need to customize adapter yourself.

Import Pangle SDK and Adapter

Download the plugin from Pangle platform manually, then find PangleAdapterScriptsDependencies.unitypackage, as below:
mediation.png





adapter-download.png





截屏2021-09-10 上午12.43.11.png

Open your project in the Unity editor, select Assets > Import Package > Custom Package, and find the PangleAdapterScriptsDependencies.unitypackage. Make sure the file is selected, and then click Import.
The plugin will help to import Pangle SDK and Adapters automatically from Maven&Cocoa Pod when you export an Android or iOS project.
截屏2021-09-10 上午12.23.13.png

Additional Configuration for Android

Add following permissions and provider to your app's AndroidManifest.xml.

:warning: Please make sure to add provider or ad's loading will not work properly.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxxxxxxx" data-tomark-pass >

    <!--Required  permissions-->
    <uses-permission android:name="android.permission.INTERNET"  data-tomark-pass />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"  data-tomark-pass />
    <!-- If there is a video ad and it is played with textureView, please be sure to add this, otherwise a black screen will appear -->
    <uses-permission android:name="android.permission.WAKE_LOCK"  data-tomark-pass />

    <application
        ...
        <!--Required->
        <provider
            android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
            android:authorities="${applicationId}.TTMultiProvider"
            android:exported="false"  data-tomark-pass />

        ...

    </application>

</manifest>

Initialize Pangle SDK

Once you finish the steps above, you need to initialized Pangle SDK. For now, you have to initialize Pangle SDK after exporting an Android or iOS project, we would strongly recommend to initialized Pangle SDK on app launch.

Initialize Android SDK

Initialize Pangle Android SDK asynchronously is supported since the v3.5.0.0 SDK, please call TTAdSdk.init(final Context var0, final TTAdConfig var1, final TTAdSdk.InitCallback var2) to initializes the SDK before you send any ad requests. init only need to be called once per app’s lifecycle.

TTAdSdk.InitCallback will be informed about the result of the initialize.

If you use TextureView for video ads, please set useTextureView(true) in the Builder and add add WAKE_LOCK permission in the manifest.

class PangleApplication: Application() {

    override fun onCreate() {
        super.onCreate()

        if (BuildConfig.DEBUG) {
            Timber.plant(Timber.DebugTree())
        }

        initSdk()
    }

    private fun initSdk() {
        TTAdSdk.init(this, buildAdConfig(), mInitCallback)
    }

    private val mInitCallback: TTAdSdk.InitCallback = object : TTAdSdk.InitCallback {
        override fun success() {
            Timber.d("init succeeded")
        }

        override fun fail(p0: Int, p1: String?) {
            Timber.d("init failed. reason = $p1")
        }
    }

    private fun buildAdConfig(): TTAdConfig {
        return TTAdConfig.Builder()
            // Please use your own appId,
            .appId("your_app_id")
            // Turn it on during the testing phase, you can troubleshoot with the log, remove it after launching the app
            .debug(BuildConfig.DEBUG)
            // The default setting is SurfaceView. We strongly recommend to set this to true.
            // If using TextureView to play the video, please set this and add "WAKE_LOCK" permission in manifest
            .useTextureView(true)
            // Fields to indicate whether you are a child or an adult ,0:adult ,1:child
            .coppa(0)
            .build()
    }

You also could check the initialization status with the method TTAdSdk.isInitSuccess()

private fun checkInitResult(): Boolean {
   return TTAdSdk.isInitSuccess()
}

Please refer to Initialize Pangle Android SDK for manual integration and more information.

Initialize iOS SDK

Initialize Pangle with the APP ID as the argument. Unless there is a particular reason, stipulate asUIApplicationDelegate application(_:didFinishLaunchingWithOptions:)

We recommand to use asynchronize initialization method + (void)startWithAsyncCompletionHandler:(BUCompletionHandler)completionHandler; to init the SDK, and also set allowModifyAudioSessionSetting to true to not interrupt the background's audio playback.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let configuration = BUAdSDKConfiguration()

    #if DEBUG
    // enable log print. default is none.
    configuration.logLevel = .debug
    #endif
    configuration.appID = "your app id"
    configuration.coppa = 0

    //Set to true to NOT interrupt background app's audio playback
    configuration.allowModifyAudioSessionSetting = true

    BUAdSDKManager.start(asyncCompletionHandler:) { (success, error) in
        if ((error) != nil) {
            //init failed
        }
    };

    return true
}

Please refer to Initialize Pangle iOS SDK for manual integration and more information.

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.

Did the content solve your problem?