Integrate InMobi with mediation

本指南将向您介绍如何使用 Google 移动广告 SDK,利用中介从 InMobi 加载和展示广告,其中包括广告瀑布流和出价集成。该指南介绍了如何将 InMobi 添加到广告单元的中介配置,以及如何将 InMobi SDK 和适配器集成到 Unity 应用中。

支持的集成和广告格式

集成
出价  1
瀑布
表现形式
横幅
插页式广告
已奖励

1 出价集成功能目前处于封闭式 Beta 版测试阶段,请与您的客户经理联系,申请访问权限。

要求

  • Unity 4 或更高版本
  • 最新版 Google 移动广告 SDK
  • 在 Android 上部署
    • Android API 级别 19 或更高级别
  • 在 iOS 上部署
    • iOS 部署目标为 10.0 或更高版本
  • 配置了 Google 移动广告 SDK 且处于有效状态的 Unity 项目。如需了解详情,请参阅使用入门
  • 完成中介 入门指南

第 1 步:在 InMobi 界面中设置配置

Sign up for an InMobi account.

Bidding

Select Use InMobi SSP with Google Open Bidding and enter your Google Publisher ID.

Waterfall

No additional step is required for waterfall integrations.

Log in to your InMobi account once verified.

Add an app

To add your app to the InMobi dashboard, click Inventory > Inventory Settings.

Click Add Inventory and select the Mobile App channel from the drop-down menu.

Start typing your published app store URL in the search bar and select the app from the auto-populated results. Click Continue.

If your app in not published, click Link manually and enter the required details. Click Continue.

Review the App & Website Compliance settings and then click Save and Create Placements.

Placements

After you set up your inventory, the system redirects you to the placement creation workflow.

Bidding

Select the type of ad unit. The enter a Placement Name, select On and Google Open Bidding for Audience Bidding and Partner respectively, and fill out the rest of the form. Click Create Placement when done.

Waterfall

Select the type of ad unit. Then enter a Placement Name, select Off for Audience Bidding, and fill out the rest of the form. Click Create Placement when done.

Once the placement is created, its details are shown. Take note of the Placement ID, which will be used for setting up your AdMob ad unit.

Account ID

Your InMobi account ID is available under Finance > Payment Settings > Payment Information.

Locate InMobi Reporting API Key

Bidding

This step isn't required for bidding integrations.

Waterfall

Go to My Account > Account Settings. Navigate to the API Key tab and click Generate API Key.

Select the email of the user the key is required for and click Generate API Key. A file containing the API key and username/login name will be generated.

Only the publisher administrator of the account will be able to generate an API key for all users. If you have forgotten the previously generated API key, reset your API key by hovering over your mail on the API Key tab.

Turn on test mode

Enable Test Mode for your placement on all live impressions or certain test devices only.

第 2 步:在界面中设置 InMobi 需求 AdMob

Configure mediation settings for your ad unit

Android

For instructions, see step 2 in the guide for Android.

iOS

For instructions, see step 2 in the guide for iOS.

添加到 GDPR 和美国州级法规的广告合作伙伴列表中 InMobi

Follow the steps in GDPR settings and US state regulations settings to add InMobi to the GDPR and US state regulations ad partners list in the AdMob UI.

第 3 步:导入 InMobi SDK 和适配器

请访问更新日志中的下载链接,下载适用于 InMobi 的最新版 Google 移动广告中介插件,然后从 ZIP 文件中提取 GoogleMobileAdsInMobiMediation.unitypackage

在 Unity 项目编辑器中,依次选择 Assets > Import Package > Custom Package,然后选择您下载的 GoogleMobileAdsInMobiMediation.unitypackage 文件。确保选择所有文件,然后点击 Import

然后,依次选择 Assets > Play Services Resolver > Android Resolver > Force Resolve。Unity Play 服务解析器库将从头开始执行依赖项解析,并将声明的依赖项复制到 Unity 应用的 Assets/Plugins/Android 目录中。

第 4 步:在 InMobi SDK 上实现隐私设置

根据 Google 欧盟地区用户意见征求政策,您必须确保就设备标识符和个人数据的使用向欧洲经济区 (EEA) 用户披露特定披露信息,并征得其同意。此政策反映了欧盟《电子隐私指令》和《一般数据保护条例》(GDPR) 的要求。在征求用户意见时,您必须指明中介链中可能会收集、接收或使用个人数据的各个广告联盟,并提供有关每个广告联盟使用情况的信息。Google 目前无法自动将用户的同意情况传送给此类广告联盟。

适用于 InMobi 版本 2.1.0 的 Google 移动广告中介插件添加了 InMobi.UpdateGDPRConsent() 方法,可让您将用户意见征求信息传递给 InMobi。以下示例代码展示了如何将用户意见征求信息传递给 InMobi SDK。如果您选择调用此方法,请在使用 Google 移动广告 SDK 请求广告之前调用此方法。

using GoogleMobileAds.Api.Mediation.InMobi;
using System.Collections.Generic;
// ...

Dictionary<string, string> consentObject = new Dictionary<string, string>();
consentObject.Add("gdpr_consent_available", "true");
consentObject.Add("gdpr", "1");

InMobi.UpdateGDPRConsent(consentObject);

如需详细了解 InMobi 可在此意见征求对象中接受的键和值,请参阅 InMobi 的 GDPR 实现详情

美国州级隐私保护法律

美国州级隐私保护法律 规定,必须让用户有权选择不“出售”其“个人信息”(该法律对这些术语进行了定义)。“出售”方须在首页醒目位置提供“请勿出售我的个人信息”链接,以供用户选择。美国州级隐私保护法律合规性指南让您可以为 Google 广告投放启用受限的数据处理,但 Google 无法将此设置应用于中介链中的每个广告联盟。因此,您必须确定中介链中可能参与个人信息出售的每个广告网络,并遵循每个广告网络的指导以确保合规性。

如需了解如何为 InMobi 启用 CCPA 设置,请参阅 InMobi 的 CCPA 文档

第 5 步:添加所需的其他代码

Android

不需要进行额外的代码集成 InMobi。

iOS

SKAdNetwork 集成

按照 InMobi 的文档操作,将 SKAdNetwork 标识符添加到项目的 Info.plist 文件中。

第 6 步:测试实现效果

Enable test ads

Make sure you register your test device for AdMob and enable test mode in InMobi UI.

Verify test ads

To verify that you are receiving test ads from InMobi, enable single ad source testing in ad inspector using the InMobi (Bidding) and InMobi (Waterfall) ad source(s).

可选步骤

Android

权限

为了获得最佳性能,InMobi 建议将以下可选权限添加到应用的 AndroidManifest.xml 文件中。

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />

您可以选择将这些权限添加到 Plugins/Android/GoogleMobileAdsInMobiMediation/AndroidManifest.xml 文件中。

iOS

无需执行额外的步骤,即可进行 iOS 集成。

错误代码

如果适配器无法从 InMobi 接收广告,发布商可以使用以下类中的 ResponseInfo 检查广告响应的根本错误:

Android

com.google.ads.mediation.inmobi.InMobiAdapter
com.google.ads.mediation.inmobi.InMobiMediationAdapter

iOS

GADMAdapterInMobi
GADMediationAdapterInMobi

以下是广告加载失败时 InMobi 适配器抛出的代码及相应消息:

Android

错误代码 原因
0-99 InMobi SDK 错误。如需了解详情,请参阅代码
100 在界面中配置的 InMobi 服务器参数 AdMob 缺失/无效。
101 未能初始化 InMobi SDK。
102 请求的广告尺寸与 InMobi 支持的横幅广告尺寸不匹配。
103 广告请求不是统一的原生广告请求。
104 尝试在未初始化 InMobi SDK 的情况下请求 InMobi 广告。理论上应该不会出现这种情况,因为适配器会在请求 InMobi 广告之前初始化 InMobi SDK。
105 InMobi 的广告还未准备好展示。
106 InMobi 未能展示广告。
107 InMobi 返回的原生广告缺少必需的素材资源。
108 InMobi 的原生广告图片素材资源包含格式错误的网址。
109 适配器无法下载 InMobi 的原生广告图片素材资源。

iOS

错误代码 原因
101 在界面中配置的 InMobi 服务器参数 AdMob 缺失/无效。
102 InMobi 适配器不支持请求的广告格式。
103 已针对此广告网络配置加载了一个 InMobi 广告。
其他 InMobi SDK 返回了错误。如需了解详情,请参阅 IMRequestStatus.h

InMobi Unity 中介插件更新日志

版本 4.4.1

版本 4.4.0

版本 4.3.3

版本 4.3.0

版本 4.2.2

版本 4.2.1

版本 4.2.0

版本 4.1.0

版本 4.0.4

版本 4.0.3

版本 4.0.2

版本 4.0.1

版本 4.0.0

版本 3.2.0

版本 3.1.2

版本 3.1.1

版本 3.1.0

版本 3.0.3

版本 3.0.2

版本 3.0.1

版本 3.0.0

版本 2.4.0

版本 2.3.0

  • 支持 Android 适配器版本 7.2.9.0。
  • 支持 iOS 适配器版本 7.3.2.0。

版本 2.2.2

  • 更新了插件以支持新的激励广告 API。
  • 支持 Android 适配器版本 7.2.7.0。
  • 支持 iOS 适配器版本 7.2.7.0。

版本 2.2.1

  • 支持 Android 适配器版本 7.2.2.0。
  • 支持 iOS 适配器版本 7.2.4.0。

版本 2.2.0

  • 支持 Android 适配器版本 7.2.1.0。
  • 支持 iOS 适配器版本 7.2.0.0。

版本 2.1.2

  • 支持 Android 适配器版本 7.1.1.1。
  • 支持 iOS 适配器版本 7.1.2.0。

版本 2.1.1

  • 支持 Android 适配器版本 7.1.1.1。
  • 支持 iOS 适配器版本 7.1.1.2。

版本 2.1.0

  • 支持 Android 适配器版本 7.1.0.0。
  • 支持 iOS 适配器版本 7.1.1.1。
  • 添加了 InMobi.UpdateGDPRConsent() 方法。

版本 2.0.0

  • 支持 Android 适配器版本 7.0.4.0。
  • 支持 iOS 适配器版本 7.1.1.0。

版本 1.0.0

  • 首个版本!
  • 支持 Android 适配器版本 6.2.4.0。
  • 支持 iOS 适配器版本 6.2.1.0。