Max Plugin

Đây là 1 Plugin có các Class Base để phục vụ Init, Load và Show Ads của Max và 1 một số tracking tự động với GSM

1. Điều kiện sử dụng

  • Tích hợp GSM SDK V1.2.4.4 trở lên

Max Plugin Documentation

Tài liệu hướng dẫn sử dụng Max Plugin cho Unity - Tích hợp AppLovin MAX Ads với hệ thống GSM.


1. Cấu trúc thư mục và các Class

Assets/CSCMobiPlugin/MaxPlugin/

├── Scripts/
│   ├── MaxAdsHybridController.cs          (Abstract) Controller chính - nhiều AdUnitId
│   ├── BaseMaxAdsController.cs            (Abstract) Controller cơ bản - 1 AdUnitId
│   │
│   ├── GSMMaxInitialization.cs            Khởi tạo MAX SDK
│   ├── GSMMaxInfo.cs                      Thông tin MAX + cấu hình AppLovin
│   ├── MaxAdUnitConfig.cs                 Cấu hình loadFailMax cho từng AdUnit
│   ├── MaxLoadStatus.cs                   Trạng thái load của AdUnit
│   ├── GSMMaxTracking.cs                  Tracking impressions
│   ├── GSMMaxCounterLog.cs                Counter log cho analytics
│   └── AndroidToast.cs                    Toast notification (Android)

├── Editor/
│   └── MaxPluginPreBuildProcessor.cs      Xử lý trước khi build

├── Resources/
│   └── ApplovinSettingData.json           Cấu hình AppLovin (runtime)

└── Documents/
    └── README.md                          ← Tài liệu chính

Mô tả ngắn gọn các Class

Class
Loại
Mô tả

MaxAdsHybridController

Abstract

Controller nâng cao: nhiều AdUnitId, rotation theo eCPM, override từ GSM server

BaseMaxAdsController

Abstract

Controller cơ bản: 1 Interstitial + 1 Rewarded cố định

GSMMaxInitialization

Static

Quản lý khởi tạo MAX SDK, kiểm tra trạng thái init

GSMMaxInfo

Static

Lấy thông tin MAX, SDK key, network adapters, đọc GSMSettings

MaxAdUnitConfig

Data

Cấu hình loadFailMax cho từng AdUnit

MaxLoadStatus

Data

Trạng thái: loadFailCount, isLoading, disabled

GSMMaxTracking

Static

Gửi tracking khi load ad

GSMMaxCounterLog

Static

Counter log cho analytics

AndroidToast

Static

Hiển thị toast trên Android


2. GSMMaxInfo - Chức năng và cách sử dụng

2.1 Chức năng

GSMMaxInfo là class static chịu trách nhiệm:

  1. Đọc cấu hình MAX từ GSMSettings

    • Ad Unit IDs cho Android và iOS

    • Platform detection (tự động chọn đúng danh sách theo platform)

  2. Lấy SDK Key và thông tin network

    • Editor: Đọc từ AppLovinSettings asset

    • Runtime: Đọc từ ApplovinSettingData.json trong Resources

  3. Gửi thông tin MAX lên GSM Core

    • SDK Key

    • MAX Version

    • Danh sách AdUnitIds

    • Network adapter versions (AdMob, Facebook, Vungle, etc.)

    • AdMob App IDs

  4. Hỗ trợ build

    • Tự động tạo ApplovinSettingData.json khi build

2.2 Cách hoạt động

3. MaxAdsHybridController - Hướng dẫn sử dụng

3.1 Tổng quan

MaxAdsHybridControllerabstract class quản lý quảng cáo MAX với các tính năng:

  • Nhiều AdUnitId: Hỗ trợ danh sách AdUnitId theo thứ tự eCPM (Cao → Trung → Thấp)

  • Tự động rotation: Chuyển sang AdUnitId tiếp theo khi fail

  • Override từ GSM Server: Có thể lấy danh sách AdUnitId từ server

  • Config riêng từng AdUnit: loadFailMax có thể config qua GSM config

  • Auto retry: Retry với delay tăng dần (2^n giây, max 64s)

3.2 Kiến trúc

3.3 Các method Abstract cần implement

Format AdUnitId (CỐ ĐỊNH):

Hệ thống quy định chặt chẽ format tên AdUnitId như sau:

Loại
Format
Ví dụ
Ghi chú

Rewarded

Reward + số thứ tự

Reward0, Reward1, Reward2...

Sắp xếp theo eCPM (0 = cao nhất)

Rewarded Default

RewardDefault

RewardDefault

Luôn ở cuối danh sách

Interstitial

Interstitial + số thứ tự

Interstitial0, Interstitial1, Interstitial2...

Sắp xếp theo eCPM (0 = cao nhất)

Interstitial Default

InterstitialDefault

InterstitialDefault

Luôn ở cuối danh sách

Các method public để truy xuất AdUnitId mặc định:

3.4 Ví dụ triển khai hoàn chỉnh

Lưu ý quan trọng:

  • Base class tự động lấy AdUnitId từ GSMSettings trong Awake()

  • Chỉ cần implement các method tracking (GetTargetLevel, GetGroup, GetSubGroup, GetUserType)

3.5 Thiết lập AdUnitId trong GSMSettings

QUAN TRỌNG: Format tên AdUnitId (adName) là CỐ ĐỊNH, bắt buộc phải theo đúng quy tắc bên dưới:

Trong GSMSettings Inspector, bạn cấu hình AdUnitIds với các adName đúng format:

Quy tắc đặt tên (CỐ ĐỊNH):

  • Reward0, Reward1, Reward2... → Tự động được thêm vào rewardAdUnitIds theo thứ tự số tăng dần

  • RewardDefault → Luôn ở cuối danh sách rewardAdUnitIds

  • Interstitial0, Interstitial1, Interstitial2... → Tự động được thêm vào interAdUnitIds theo thứ tự số tăng dần

  • InterstitialDefault → Luôn ở cuối danh sách interAdUnitIds

Lưu ý: Tên AdUnitId phải tuân thủ đúng format trên. Nếu đặt sai tên (ví dụ: RewardedVideo thay vì Reward0), hệ thống sẽ không nhận diện được.

Ví dụ kết quả:

  • Nếu có: Reward5, Reward1, Reward3, RewardDefault

  • rewardAdUnitIds = ["id_of_Reward1", "id_of_Reward3", "id_of_Reward5", "id_of_RewardDefault"]

3.6 Cách sử dụng trong game

Kế thừa từ GSMAdManager để quản lý ads tập trung:

Sử dụng trong game:

Cấu trúc trong Scene:

Flow hoạt động:

3.7 Các SerializeField config

Property
Type
Default
Mô tả

IsAutoLoadRewardVideo

bool

true

Tự động load sau khi SDK init

IsAutoLoadInterstitial

bool

true

Tự động load sau khi SDK init

3.8 Event và Callback

3.9 Cơ chế Fail và Retry

Config loadFailMax qua GSM Config:

  • Mặc định: loadFailMax = 1

  • AdUnit mặc định: KHÔNG BAO GIỜ bị loại bỏ

3.10 Override từ GSM Server

Hệ thống tự động gọi GSMApp.GetMaxAdUnitIds() để lấy danh sách AdUnitId từ server. Nếu server trả về danh sách, nó sẽ override danh sách từ GSMSettings.

3.11 So sánh với BaseMaxAdsController

Tiêu chí
BaseMaxAdsController
MaxAdsHybridController

Số AdUnit

1 Inter + 1 Reward

Nhiều AdUnit (list)

Rotation

Không

Có (theo eCPM)

Override từ server

Không

loadFailMax config

Không

Có (qua GSM config)

Độ phức tạp

Thấp

Trung bình

Phù hợp

Game đơn giản

Game cần tối ưu revenue


Version

Plugin Version: 0.0.0.15

Last Updated: 2026-02-24

Last updated