Help Center/Details/

Admob Custom Event for CSJ

Please set Admob in your app first.

Setup CSJ Platform

Create a CSJ account

Create an application and placements in CSJ

  • 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 CSJ 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 CSJ 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 CSJ.

add-custom-event.png

Set Class Name and Parameter

Set Class Name and Parameter in the mediation setting.

mediation-param.png

Class Name

If you are using gradle to integrate our adapters, please copy the contents below to Class Name .

Ad Type Class Name
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

Else if you are integrating our adapters by manual, please add adapter's package + adapter'class name to Class Name.

Ad Type adapter'class name (need add package of your app )
Reward Video Ads AdmobRewardVideoAdapter
Interstitial(Fullscreen Video) Ads AdmobFullScreenVideoAdapter
Banner Ads AdmobTemplateBannerAdapter
Native Ads AdmobNativeFeedAdAdapter
  • for example,com.bytedance.pangle.admob.adapter.demo.pangle.adapter.AdmobRewardVideoAdapter

class-name.png

Parameter

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

  • Parameter: Add {"placementID":"your placement ID on CSJ"} to Parameter , for example,{"placementID":"1234567"}

  • Please make sure to use JSON to set Parameter. Or you need to customize adapter yourself.

Initialize CSJ SDK and Adapter

Import and Init CSJ SDK

Add url 'https://artifact.bytedance.com/repository/pangle' maven in the allprojects section of your project-level build.gradle.

allprojects {
    repositories {
      maven {
        url 'https://artifact.bytedance.com/repository/pangle'
      }
    }
}

Next, open the app-level build.gradle file for your app, add implementation 'com.pangle.cn:ads-sdk-pro:x.x.x.x' in "dependencies" section.

dependencies {
    ...
    implementation 'com.pangle.cn:ads-sdk-pro:3.7.0.4'
    
    ...

}

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">

    <!--Required  permissions-->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
    <!--required-->
<uses-permission android:name="android.permission.INTERNET" />

    <!--required-->
    <permission      android:name="${applicationId}.openadsdk.permission.TT_PANGOLIN"
        android:protectionLevel="signature" />

    <uses-permission android:name="${applicationId}.openadsdk.permission.TT_PANGOLIN" /> 
    
    <!-- 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" />

    <application
        ...
        <!--Required->
        <provider
            android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"
            android:authorities="${applicationId}.TTMultiProvider"
            android:exported="false" />
            
        <!--Required->
        <provider        
        android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
    android:authorities="${applicationId}.TTFileProvider"
    android:exported="false"
    android:grantUriPermissions="true">
   <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

        ...

    </application>

</manifest>

In the res/xml directory, create a new xml file file_paths for TTFileProvider, and add the following code to the file:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android" data-tomark-pass >
   <!--为了适配所有路径可以设置 path = "." -->
   <external-path name="tt_external_root" path="."  data-tomark-pass />
   <external-path name="tt_external_download" path="Download"  data-tomark-pass />
   <external-files-path name="tt_external_files_download" path="Download"  data-tomark-pass />
   <files-path name="tt_internal_file_download" path="Download"  data-tomark-pass />
   <cache-path name="tt_internal_cache_download" path="Download"  data-tomark-pass />
</paths>

Initialize CSJ 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, we strongly recommend to do this on app launch.

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)
            
            .build()
    }

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

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

Embed CSJ Adapters

Gradle (preferred)

From our adapter v1.4.0, we support gradle integration.

Please open the app-level build.gradle file for your app, add implementation 'com.pangle.global:adapter-for-admob:1.4.0' in "dependencies" section.

dependencies {
    ...
    //CSJ SDK
    implementation 'com.pangle.cn:ads-sdk-pro:3.7.0.4'
    //Adapter
    implementation 'com.pangle.global:adapter-for-admob:1.4.0'
    ...

}

Demo

  • You can find simple use cases from Demo.
Did the content solve your problem?
Contact us