This guide shows you how to use the Google Mobile Ads SDK to load and display ads from Unity Ads using mediation, covering waterfall integrations. It covers how to add Unity Ads to an ad unit's mediation configuration, and how to integrate the Unity Ads SDK and adapter into a Flutter app.
Supported integrations and ad formats
The AdMob mediation adapter for Unity Ads has the following capabilities:
Integration | |
---|---|
Bidding | |
Waterfall | |
Formats | |
Banner | |
Interstitial | |
Rewarded |
Requirements
- Latest Google Mobile Ads SDK
- Flutter 3.7.0 or higher
- To deploy on Android
- Android API level 21 or higher
- To deploy on iOS
- iOS deployment target of 12.0 or higher
- A working Flutter project configured with Google Mobile Ads SDK. See Get Started for details.
- Complete the mediation Get started guide
Step 1: Set up configurations in Unity Ads UI
注册或登录 Unity Ads。
创建项目
在 Unity Ads 信息中心内,前往 Projects,然后点击 Create Project。
填写表单,然后点击 Create Project(创建项目)以添加项目。
依次前往创收 > 开始,然后点击开始。
在项目设置模态窗口中,选择我打算使用中介,并针对中介合作伙伴选择 Google AdMob,然后点击下一步。
选择您的广告设置,然后点击下一步。
填写表单,然后点击添加项目。
记下游戏 ID。
创建广告单元
依次前往创收 > 广告单元,然后点击添加广告单元。
输入广告单元名称,然后选择平台和广告格式。
Android
iOS
最后,点击创建,保存您的广告单元。
添加展示位置
创建项目后,依次前往创收 > 展示位置。如需创建新的展示位置,请为您的广告单元点击添加展示位置。
填写必要的详细信息,然后点击添加展示位置。
记下展示位置 ID。
Android
iOS
检索凭据
除了游戏 ID 和展示位置 ID 之外,您还需要 Unity Ads API 密钥和组织核心 ID 来设置AdMob 广告单元 ID。
依次前往创收 > 设置 > API 管理,然后记下 Monetize Stats API 访问密钥。
然后,依次转到创收 > 组织设置,并记下组织核心 ID。
开启测试模式
您可以从 Unity Ads 信息中心启用测试模式。在项目的设置下,选择测试标签页。
您可以通过以下方式强制应用测试模式:点击每个平台的修改按钮,选中替换客户端测试模式,然后选择对所有设备强制开启测试模式(即使用测试广告)。
Android
iOS
或者,您也可以通过点击 Add Test Device 按钮为特定设备启用测试模式。
填写表单并点击保存。
Step 2: Set up Unity Ads demand in AdMob UI
광고 단위에 대한 미디에이션 설정 구성
Add Unity Ads to GDPR and US state regulations ad partners list
GDPR 설정 및 미국 주 규정 설정 Unity Ads 를 AdMob UI의 GDPR 및 미국 주 규정 광고 파트너 목록에 추가합니다.
Step 3: Import the Unity Ads SDK and adapter
pub.dev를 통한 통합
패키지의 pubspec.yaml
파일에 있는 최신 버전의Unity Ads SDK 및 어댑터와 함께 다음 종속 항목을 추가합니다.
dependencies:
gma_mediation_unity: ^1.0.0
수동 통합
Unity Ads용 Google 모바일 광고 미디에이션 플러그인의
최신 버전을 다운로드하고,
다운로드한 파일의 압축을 풀고, 추출된 플러그인 폴더(및 폴더 콘텐츠)를 Flutter 프로젝트에
추가합니다. 그런 다음 다음 종속 항목을 추가하여 pubspec.yaml
파일에서 플러그인을 참조합니다.
dependencies:
gma_mediation_unity:
path: path/to/local/package
Step 4: Implement privacy settings on Unity Ads SDK
EU Consent and GDPR
Under the Google EU User Consent Policy, you must ensure that certain disclosures are given to, and consents obtained from, users in the European Economic Area (EEA) regarding the use of device identifiers and personal data. This policy reflects the requirements of the EU ePrivacy Directive and the General Data Protection Regulation (GDPR). When seeking consent, you must identify each ad network in your mediation chain that may collect, receive, or use personal data and provide information about each network's use. Google currently is unable to pass the user's consent choice to such networks automatically.
The Google Mobile Ads mediation plugin for Unity Ads
includes the
GmaMediationUnity.setGDPRConsent()
method. The following sample code shows how to pass consent information to the
Unity Ads SDK. If you choose to call this method, it is recommended that you do
so prior to requesting ads through the Google Mobile Ads SDK.
import 'package:gma_mediation_unity/gma_mediation_unity.dart';
// ...
GmaMediationUnity.setGDPRConsent(true);
See Unity Ads' Privacy Consent and data APIs and Complying with GDPR guides for more details and the values that can be provided in each method.
US states privacy laws
U.S. states privacy laws require giving users the right to opt out of the "sale" of their "personal information" (as the law defines those terms), with the opt-out offered via a prominent "Do Not Sell My Personal Information" link on the "selling" party's homepage. The U.S. states privacy laws compliance guide offers the ability to enable restricted data processing for Google ad serving, but Google is unable to apply this setting to each ad network in your mediation chain. Therefore, you must identify each ad network in your mediation chain that may participate in the sale of personal information and follow guidance from each of those networks to ensure compliance.
The Google Mobile Ads mediation plugin for Unity Ads
includes the
GmaMediationUnity.setCCPAConsent()
method. The following sample code shows how to pass consent information to the
Unity Ads SDK. If you choose to call this method, it is recommended that you do
so prior to requesting ads through the Google Mobile Ads SDK.
import 'package:gma_mediation_unity/gma_mediation_unity.dart';
// ...
GmaMediationUnity.setCCPAConsent(true);
Step 5: Add required code
Android
No Additional code required for Unity Ads Android integrations.
iOS
SKAdNetwork integration
Follow Unity Ads' documentation
to add the SKAdNetwork identifiers to your project's Info.plist
file.
Step 6: Test your implementation
테스트 광고 사용 설정
AdMob 용 테스트 기기를 등록하고 Unity Ads UI에서 테스트 모드를 사용 설정해야 합니다.
테스트 광고 확인
Unity Ads에서 테스트 광고를 수신하고 있는지 확인하려면 광고 검사기에서 Unity Ads (Waterfall) 광고 소스를 사용하여 단일 광고 소스 테스트를 사용 설정하세요.
Error codes
If the adapter fails to receive an ad from Unity Ads, publishers can check the
underlying error from the ad response using
ResponseInfo
under the
following classes:
Android
com.google.ads.mediation.unity.UnityAdapter
com.google.ads.mediation.unity.UnityMediationAdapter
iOS
GADMAdapterUnity
GADMediationAdapterUnity
Here are the codes and accompanying messages thrown by the UnityAds adapter when an ad fails to load:
Android
Error code | Reason |
---|---|
0-10 | UnityAds SDK returned an error. See code for more details. |
101 | UnityAds server parameters configured in the Admob UI are missing/invalid. |
102 | UnityAds returned a placement with a NO_FILL state. |
103 | UnityAds returned a placement with a DISABLED state. |
104 | UnityAds tried to show an ad with a null context. |
105 | Context used to initialize, load and/or show ads from Unity Ads is not an Activity instance. |
106 | UnityAds tried to show an ad that's not ready to be shown. |
107 | UnityAds is not supported on the device. |
108 | UnityAds can only load 1 ad per placement at a time. |
109 | UnityAds finished with an ERROR state. |
200-204 | UnityAds Banner a specific error. See code for more details. |
iOS
0-9 | UnityAds SDK returned an error. See Unity's documentation for more details. |
101 | UnityAds server parameters configured in the Admob UI are missing/invalid. |
102 | Device not supported by UnityAds. |
103 | UnityAds finished presenting with error state kUnityAdsFinishStateError. |
104 | The Unity ad object is nil after calling its initializer. |
105 | Failed to show Unity Ads due to ad not ready. |
106 | UnityAds called a placement changed callback with placement state kUnityAdsPlacementStateNoFill. |
107 | UnityAds called a placement changed callback with placement state kUnityAdsPlacementStateDisabled. |
108 | An ad was already loaded for this placement. UnityAds SDK does not support loading multiple ads for the same placement. |
Unity Ads Flutter Mediation Adapter Changelog
Version 1.0.0
- Initial release.
- Verified compatibility with Unity Android adapter version 4.10.0.0
- Verified compatibility with Unity iOS adapter version 4.10.0.0