שילוב של Unity Ads עם תהליך בחירת הרשת (Mediation)

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 עבור שותף בתהליך בחירת הרשת, ולאחר מכן לוחצים על הבא.

בוחרים את הגדרות המודעות ולוחצים על הבא.

ממלאים את הטופס ולוחצים על הוספת פרויקט.

חשוב לשים לב למזהה המשחק.

יצירה של יחידת מודעות

עוברים אל מונטיזציה > יחידות של מודעות, ואז לוחצים על הוספה של יחידת מודעות.

מזינים שם של יחידת מודעות ובוחרים את הפלטפורמה ואת פורמט המודעה.

Android

iOS

לסיום, לוחצים על יצירה כדי לשמור את יחידת המודעות.

הוספת מיקום

לאחר יצירת הפרויקט, עוברים אל מונטיזציה > מיקומי מודעות. כדי ליצור מיקום חדש, לוחצים על Add Placement של יחידת המודעות.

ממלאים את הפרטים הנדרשים ולוחצים על הוספת מיקום.

חשוב לשים לב למזהה המיקום.

Android

iOS

אחזור פרטי הכניסה

כדי להגדיר אתAdMob מזהה יחידת המודעות, בנוסף למזהה המשחק ולמזהה המיקום, תצטרכו גם את מפתח ה-API של מודעות Unity Ads ומזהה הליבה של הארגון.

מנווטים אל מונטיזציה > הגדרה > ניהול API ושימו לב למפתח הגישה ל-מונטיזציה לנתונים סטטיסטיים.

לאחר מכן, עוברים לכרטיסייה מונטיזציה > הגדרות הארגון ורושמים את מזהה הליבה של הארגון.

הפעלת מצב בדיקה

אפשר להפעיל את מצב הבדיקה דרך מרכז הבקרה של Unity Ads. בהגדרות של הפרויקט, בוחרים בכרטיסייה Testing.

כדי לאלץ את מצב הבדיקה של האפליקציה, לוחצים על לחצן העריכה בכל פלטפורמה, מסמנים את האפשרות שינוי מצב הבדיקה של הלקוח ובוחרים באפשרות אילוץ מצב בדיקה מופעל (כלומר שימוש במודעות בדיקה) בכל המכשירים.

Android

iOS

לחלופין, אפשר להפעיל את מצב הבדיקה למכשירים ספציפיים באמצעות לחיצה על הלחצן Add Test Device.

ממלאים את הטופס ולוחצים על שמירה.

Step 2: Set up Unity Ads demand in AdMob UI

קביעת הגדרות של תהליך בחירת הרשת (Mediation) ביחידת המודעות

Android

לקבלת הוראות, עיינו בשלב 2 במדריך עבור Android.

iOS

לקבלת הוראות, עיינו בשלב 2 במדריך iOS.

Add Unity Ads to GDPR and US state regulations ad partners list

פועלים לפי השלבים המפורטים בקטע הגדרות GDPR וגם הגדרות של תקנות במדינות בארה"ב כדי להוסיף את Unity Ads לרשימת שותפי הפרסום לתקנות GDPR ומדינות בארה"ב בממשק המשתמש AdMob .

Step 3: Import the Unity Ads SDK and adapter

שילוב דרך pub.dev

מוסיפים את יחסי התלות הבאים עם הגרסאות העדכניות שלUnity Ads ה-SDK והמתאם בקובץ pubspec.yaml של החבילה:

dependencies:
  gma_mediation_unity: ^1.0.0

שילוב ידני

הורד את הגרסה האחרונה של פלאגין הגישור של Google Mobile Ads עבור Unity Ads, מחלצים את הקובץ שהורדתם ומוסיפים את תיקיית הפלאגין שחולצה (ואת התוכן שלה) לפרויקט Flutter שלכם. לאחר מכן, מוסיפים את התלות הבאה לפלאגין בקובץ pubspec.yaml:

dependencies:
  gma_mediation_unity:
    path: path/to/local/package

Step 4: Implement privacy settings on Unity Ads SDK

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 ממשק המשתמש.

אימות מודעות בדיקה

כדי לוודא שמוצגות לך מודעות לבדיקה מ-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