This guide shows you how to use the Google Mobile Ads SDK to load and display ads from Meta Audience Network using AdMob Mediation, covering bidding integrations. It covers how to add Meta Audience Network to an ad unit's mediation configuration, and how to integrate the Meta Audience Network SDK and adapter into an iOS app.
Supported integrations and ad formats
The mediation adapter for Meta Audience Network has the following capabilities:
Integration | |
---|---|
Bidding | |
Waterfall 1 | |
Formats | |
Banner | |
Interstitial | |
Rewarded | |
Rewarded Interstitial | |
Native |
1 Meta Audience Network became bidding only in 2021.
Requirements
Latest Google Mobile Ads SDK
Complete the mediation Get started guide
iOS deployment target of 10.0 or higher
Meta Audience Network adapter 5.10.0.0 or higher (latest version recommended)
The latest Meta Audience Network SDK usually requires the latest version of Xcode
Step 1: Set up configurations in Meta Audience Network UI
注册并登录商家管理工具初始页。
依次点击开始使用和创建新帐号。
在必填字段中填写您的商家详情,然后点击下一步。
创建媒体资源
填写所需信息后,系统会提示您为应用创建媒体资源。为应用输入所需的媒体资源名称,然后点击下一步。
接下来,请选择要用于创收的平台。
添加应用详细信息,然后点击 Next。
![](https://developers.google.cn/admob/images/mediation/facebook/app_details_iOS.png?authuser=1&hl=ur)
点击添加新的付款帐号,设置您的付款帐号。系统会将您重定向到一个新页面,以便您输入付款信息。填写必要的详细信息,然后点击下一步。
选择 Google AdMob 作为中介平台,然后点击创建展示位置。
选择一种格式,填写表单,然后点击创建。
记下展示位置 ID。
点击完成。
开启测试模式
有关如何启用 Meta Audience Network 测试广告的详细说明,请参阅测试 Audience Network 实现指南。
Step 2: Set up Meta Audience Network demand in AdMob UI
为广告单元配置中介设置
您需要将 Meta Audience Network 添加到广告单元的中介配置。
首先,登录您的 AdMob 帐号。接下来,前往中介标签页。如果您想修改现有的中介组,请点击该中介组的名称进行修改,然后直接跳转到添加 Meta Audience Network 作为广告来源。
要创建新的中介组,请选择创建中介组。
输入您的广告格式和平台,然后点击继续。
为中介组命名,然后选择要定位到的地理位置。接下来,将中介组的状态设置为已启用,然后点击添加广告单元。
将此中介组与您的一个或多个现有AdMob 广告单元相关联。接着,点击完成。
现在,您应该会看到广告单元卡片内填充了您选择的广告单元:
添加为广告来源 Meta Audience Network
在广告来源部分的出价卡片下,选择添加广告来源。然后选择 Meta Audience Network。
点击如何签署合作伙伴协议,然后与Meta Audience Network设置出价合作伙伴关系。
点击确认并同意,然后点击继续。
如果您已有 Meta Audience Network的映射,则可以选择它。否则,请点击添加映射。
接下来,输入在上一部分中获取的 Placement ID。接着,点击完成。
Add Facebook to GDPR and US state regulations ad partners list
按照 GDPR 设置 和 美国州级法规设置 中的步骤,将 Facebook 添加到 AdMob 界面中的 GDPR 和美国州级法规广告合作伙伴列表中。
Step 3: Import the Meta Audience Network SDK and adapter
Using CocoaPods (recommended)
Add the following line to your project's Podfile:
pod 'GoogleMobileAdsMediationFacebook'
From the command line run:
pod install --repo-update
Manual integration
Download the latest version of the Meta Audience Network SDK for iOS and link
FBAudienceNetwork.framework
in your project.Download the latest version of the Meta Audience Network adapter from the download link in the Changelog and link
MetaAdapter.framework
in your project.
Step 4: Implement privacy settings on Meta Audience Network 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.
Follow the guidance in Meta's documentation for GDPR and Meta advertising.
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.
Follow the guidance in Meta's documentation for data processing options for users in California.
Step 5: Add required code
Compile errors
Swift
No additional code required for Swift integration.
Objective-C
For Meta Audience Network adapter 6.9.0.0 or higher, you must follow the steps below to add Swift paths to your target's Build Settings to prevent compile errors.
Add the following paths to the target's Build Settings under Library Search Paths:
$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)
$(SDKROOT)/usr/lib/swift
Add the following path to the target's Build Settings under Runpath Search Paths:
/usr/lib/swift
Advertising tracking enabled
If you are building for iOS 14 or later, Meta Audience Network requires that you explicitly set their Advertising Tracking Enabled flag using the following code:
Swift
// Set the flag as true
FBAdSettings.setAdvertiserTrackingEnabled(true)
Objective-C
// Set the flag as true.
[FBAdSettings setAdvertiserTrackingEnabled:YES];
SKAdNetwork integration
Follow Meta Audience Network's documentation
to add the SKAdNetwork identifiers to your project's Info.plist
file.
Step 6: Test your implementation
启用测试广告
请务必为AdMob 注册您的测试设备,并在 Meta Audience Network 界面中启用测试模式。
验证测试广告
如需验证您收到的是来自Meta Audience Network的测试广告,请使用相应广告来源在广告检查器中启用单一广告来源测试。 Meta Audience Network (Bidding)
Optional steps
Native ads
Some
Meta Audience Network native ad
assets do not map one-to-one to Google native ad assets. Such assets are passed
back to the publisher in the extraAssets
property of GADNativeAd
. The
adapter supports passing the following assets:
Request parameters and values | |
---|---|
GADFBSubtitle
|
String. The ad subtitle |
GADFBSocialContext
|
String. The ad social context |
Here's a code example showing how to extract these assets:
Swift
let socialContext: String = nativeAd.extraAssets[GADFBSocialContext]
Objective-C
NSString *socialContext = nativeAd.extraAssets[GADFBSocialContext];
Using Meta Audience Network native ads without a MediaView
Meta Audience Network's native ad format requires rendering the
GADMediaView
asset. If you plan to render native ads without that asset, make sure to use
Meta Audience Network's
native banner
ad format.
To use Meta Audience Network's native banner ads instead, you must select the
Native Banner
format when setting up Meta Audience Network and the
adapter will automatically load the corresponding native ad format.
Ad rendering
The Audience Network adapter returns its native ads as
GADNativeAd
objects. It populates the following
Native ads field descriptions
for a
GADNativeAd
.
Field | Populated by Meta Audience Network adapter |
---|---|
Headline | |
Image | 1 |
Body | |
App icon | |
Call to action | |
Advertiser Name | |
Star rating | |
Store | |
Price |
1 The Meta Audience Network adapter
does not provide direct access to the main image asset
for its native ads. Instead, the adapter populates the
GADMediaView
with a video or an image.
Impression and click tracking
The following table highlights when native ad impressions and clicks are recorded by the Google Mobile Ads SDK.
Impression recording | Click recording |
---|---|
1px of Meta Audience Network native ad asset on screen + asset rendering requirements | Meta Audience Network SDK callback |
Meta Audience Network has specific asset rendering requirements in order for an impression to be considered valid, depending on whether you selected the Native or Native Banner format when setting up Meta Audience Network.
Meta Audience Network native format | Required asset | Required rendering class |
---|---|---|
Native | Media View |
GADMediaView
|
Native Banner | App icon |
UIImageView
|
Error codes
If the adapter fails to receive an ad from Audience Network, you can check the
underlying error from the ad response using
GADResponseInfo.adNetworkInfoArray
under the following classes:
GADMAdapterFacebook
GADMediationAdapterFacebook
Here are the codes and accompanying messages thrown by the Audience Network adapter when an ad fails to load:
Error code | Reason |
---|---|
101 | Invalid server parameters (e.g. missing Placement ID). |
102 | The requested ad size does not match a Meta Audience Network supported banner size. |
103 | The Meta Audience Network ad object failed to initialize. |
104 | The Meta Audience Network SDK failed to present their interstitial/rewarded ad. |
105 | Root view controller of the banner ad is nil . |
106 | The Meta Audience Network SDK failed to initialize. |
1000-9999 | The Meta Audience Network returned an SDK-specific error. See Meta Audience Network's documentation for more details. |
Meta Audience Network iOS Mediation Adapter Changelog
Version 6.15.1.0
- Verified compatibility with Meta Audience Network SDK 6.15.1.
Built and tested with:
- Google Mobile Ads SDK version 11.2.0.
- Meta Audience Network SDK version 6.15.1.
Version 6.15.0.0
- Verified compatibility with Meta Audience Network SDK 6.15.0.
- Now requires minimum iOS version 12.0.
- Now requires Google Mobile Ads SDK version 11.0 or higher.
- Included
Info.plist
in the frameworks withinMetaAdapter.xcframework
. - Removed the deprecated
willBackgroundApplication
delegate methods from the banner and interstitial renderers. - Replaced the deprecated method
GADMobileAds.sharedInstance.sdkVersion
withGADMobileAds.sharedInstance.versionNumber
.
Built and tested with:
- Google Mobile Ads SDK version 11.2.0.
- Meta Audience Network SDK version 6.15.0.
Version 6.14.0.0
- Verified compatibility with Meta Audience Network SDK 6.14.0.
Built and tested with:
- Google Mobile Ads SDK version 10.9.0.
- Meta Audience Network SDK version 6.14.0.
Version 6.12.0.2
- Removed all bidding checks in the adapter.
- Removed support of the
armv7
architecture. - Now requires minimum iOS version 11.0.
- Now requires Google Mobile Ads SDK version 10.4.0 or higher.
Built and tested with:
- Google Mobile Ads SDK version 10.7.0.
- Meta Audience Network SDK version 6.12.0.
Version 6.12.0.1
- Now requires Google Mobile Ads SDK version 10.0.0 or higher.
Built and tested with:
- Google Mobile Ads SDK version 10.0.0.
- Meta Audience Network SDK version 6.12.0.
Version 6.12.0.0
- Removed waterfall support from adapter.
- Updated the adapter to use the
didRewardUser
API. - Now requires Google Mobile Ads SDK version 9.8.0 or higher.
- Verified compatibility with Meta Audience Network SDK 6.12.0.
Built and tested with:
- Google Mobile Ads SDK version 9.11.0.
- Meta Audience Network SDK version 6.12.0.
Version 6.11.2.0
- Verified compatibility with Meta Audience Network SDK 6.11.2.
Built and tested with:
- Google Mobile Ads SDK version 9.7.0.
- Meta Audience Network SDK version 6.11.2.
Version 6.11.1.0
- Verified compatibility with Meta Audience Network SDK 6.11.1.
- Adapter logs now refer to the adapter as "Meta Audience Network".
Built and tested with:
- Google Mobile Ads SDK version 9.5.0.
- Meta Audience Network SDK version 6.11.1.
Version 6.11.0.0
- Verified compatibility with FAN SDK 6.11.0.
Built and tested with:
- Google Mobile Ads SDK version 9.4.0.
- FAN SDK version 6.11.0.
Version 6.10.0.0
- Verified compatibility with FAN SDK 6.10.0.
- Added support for forwarding click and impression callbacks in bidding ads.
- Added warning messages for waterfall mediation deprecation. See Meta Audience Network's blog for more information.
Built and tested with:
- Google Mobile Ads SDK version 9.3.0.
- FAN SDK version 6.10.0.
Version 6.9.0.1
- Verified compatibility with Google Mobile Ads SDK version 9.0.0.
- Now requires Google Mobile Ads SDK version 9.0.0 or higher.
Built and tested with:
- Google Mobile Ads SDK version 9.0.0.
- FAN SDK version 6.9.0.
Version 6.9.0.0
- Verified compatibility with FAN SDK 6.9.0.
- For Objective-C apps only, you must now add Swift paths to your target's
Build Settings
to prevent compile errors. See the developer documentation for more details.
Built and tested with
- Google Mobile Ads SDK version 8.12.0.
- FAN SDK version 6.9.0.
Version 6.8.0.0
- Verified compatibility with FAN SDK 6.8.0.
- Now requires minimum iOS version 10.0.
Built and tested with
- Google Mobile Ads SDK version 8.12.0.
- FAN SDK version 6.8.0.
Version 6.7.0.0
- Verified compatibility with FAN SDK 6.7.0.
Built and tested with
- Google Mobile Ads SDK version 8.10.0.
- FAN SDK version 6.7.0.
Version 6.6.0.0
- Verified compatibility with FAN SDK 6.6.0.
Built and tested with
- Google Mobile Ads SDK version 8.9.0.
- FAN SDK version 6.6.0.
Version 6.5.1.0
- Verified compatibility with FAN SDK 6.5.1.
Built and tested with
- Google Mobile Ads SDK version 8.6.0.
- FAN SDK version 6.5.1.
Version 6.5.0.0
- Verified compatibility with FAN SDK 6.5.0.
- Relaxed dependency to Google Mobile Ads SDK version 8.0.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 8.5.0.
- FAN SDK version 6.5.0.
Version 6.4.1.0
- Verified compatibility with FAN SDK 6.4.1.
- Now requires Google Mobile Ads SDK version 8.4.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 8.4.0.
- FAN SDK version 6.4.1.
Version 6.3.1.0
- Verified compatibility with FAN SDK 6.3.1.
- Now requires Google Mobile Ads SDK version 8.2.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 8.2.0.
- FAN SDK version 6.3.1.
Version 6.3.0.0
- Verified compatibility with FAN SDK 6.3.0.
- Now requires Google Mobile Ads SDK version 8.1.0 or higher.
- Removing support for the
arm64
architecture for iOS simulators, as Facebook Audience Network SDK does not yet support it.
Built and tested with
- Google Mobile Ads SDK version 8.1.0.
- FAN SDK version 6.3.0.
Version 6.2.1.2
- Added support for the
arm64
architecture for iOS simulators.
Built and tested with
- Google Mobile Ads SDK version 8.0.0.
- FAN SDK version 6.2.1.
Version 6.2.1.1
- Updated the adapter to use the
.xcframework
format. - Now requires Google Mobile Ads SDK version 8.0.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 8.0.0.
- FAN SDK version 6.2.1.
Version 6.2.1.0
- Verified compatibility with FAN SDK 6.2.1.
- Now requires Google Mobile Ads SDK version 7.69.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 7.69.0.
- FAN SDK version 6.2.1.
Version 6.2.0.0
- Verified compatibility with FAN SDK 6.2.0.
- Now requires Google Mobile Ads SDK version 7.67.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 7.67.0.
- FAN SDK version 6.2.0.
Version 6.0.0.0
- Verified compatibility with FAN SDK 6.0.0.
- Now requires Google Mobile Ads SDK version 7.66.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 7.66.0.
- FAN SDK version 6.0.0.
Version 5.10.1.0
- Verified compatibility with FAN SDK 5.10.1.
- Now requires Google Mobile Ads SDK version 7.62.0 or higher.
- Fixed a bug where adapterWillLeaveApplication: was not being called for interstitial ads for waterfall mediation.
Built and tested with
- Google Mobile Ads SDK version 7.62.0.
- FAN SDK version 5.10.1.
Version 5.10.0.0
- Verified compatibility with FAN SDK 5.10.0.
- Now requires Google Mobile Ads SDK version 7.61.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 7.61.0.
- FAN SDK version 5.10.0.
Version 5.9.0.1
- Added support for rewarded interstitial ads.
- Now requires Google Mobile Ads SDK version 7.60.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 7.60.0.
- FAN SDK version 5.9.0.
Version 5.9.0.0
- Verified compatibility with FAN SDK 5.9.0.
- Now requires Google Mobile Ads SDK version 7.59.0 or higher.
Built and tested with
- Google Mobile Ads SDK version 7.59.0.
- FAN SDK version 5.9.0.
Version 5.8.0.2
- Adapter now calls adapterWillPresentScreen: immediately followed by adapterDidDismissScreen: if interstitial ads fail to present.
- Fixed a bug where some banner requests failed with reason "Display format doesn't match".
Built and tested with
- Google Mobile Ads SDK version 7.58.0.
- FAN SDK version 5.8.0.
Version 5.8.0.1
- Fix bug introduced in 5.6.1.0 where
tagForChildDirectedTreatment
was incorrectly mapped to Facebook'ssetMixedAudience
method.
Built and tested with
- Google Mobile Ads SDK version 7.57.0.
- FAN SDK version 5.8.0
Version 5.8.0.0 (Deprecated, use 5.8.0.1 or newer)
- Verified compatibility with FAN SDK 5.8.0.
- Adapter now returns a non-zero
mediaContent
aspect ratio regardless if the media view is rendered or not.
Built and tested with
- Google Mobile Ads SDK version 7.57.0.
- FAN SDK version 5.8.0.
Version 5.7.1.2 (Deprecated, use 5.8.0.1 or newer)
- Added standardized adapter error codes and messages.
Built and tested with
- Google Mobile Ads SDK version 7.56.0.
- FAN SDK version 5.7.1.
Version 5.7.1.1 (Deprecated, use 5.8.0.1 or newer)
- Removed support for the i386 architecture.
Built and tested with
- Google Mobile Ads SDK version 7.56.0.
- FAN SDK version 5.7.1.
Version 5.7.1.0 (Deprecated, use 5.8.0.1 or newer)
- Verified compatibility with FAN SDK 5.7.1.
- Added support for Facebook native banner ads when using bidding.
- Native ads now return a
GADNativeAdImage
for the icon asset.
Built and tested with
- Google Mobile Ads SDK version 7.55.1.
- FAN SDK version 5.7.1.
Version 5.7.0.0 (Deprecated, use 5.8.0.1 or newer)
- Verified compatibility with FAN SDK 5.7.0.
Built and tested with
- Google Mobile Ads SDK version 7.55.1.
- FAN SDK version 5.7.0.
Version 5.6.1.0 (Deprecated, use 5.8.0.1 or newer)
- Verified compatibility with FAN SDK 5.6.1.
Built and tested with
- Google Mobile Ads SDK version 7.53.1.
- FAN SDK version 5.6.1.
Version 5.6.0.0
- Verified compatibility with FAN SDK 5.6.0.
Built and tested with
- Google Mobile Ads SDK version 7.51.0.
- FAN SDK version 5.6.0.
Version 5.5.1.1
- Adapter now returns a non-zero
mediaContent
aspect ratio once the media view is rendered in a view. - Added additional logging for bidding.
Version 5.5.1.0
- Verified compatibility with FAN SDK 5.5.1.
Version 5.5.0.0
- Verified compatibility with FAN SDK 5.5.0.
- Now requires Google Mobile Ads SDK version 7.46.0 or higher.
- Added support for Facebook's native banner ads.
- Added code to properly handle the completion handlers after called.
- Modified the code to follow Google's Objective-C code-style.
Version 5.4.0.0
- Verified compatibility with FAN SDK 5.4.0.
Version 5.3.2.0
- Verified compatibility with FAN SDK 5.3.2.
Version 5.3.0.0
- Changed the mediation service string include adapter version.
- Fixed a bug for native ads where AdOptions wasn't initialized correctly.
Version 5.2.0.2
- Added bidding capability to the adapter for all ad formats.
Version 5.2.0.1
- Updated the adapter to use the new rewarded API.
- Now requires Google Mobile Ads SDK version 7.41.0 or higher.
Version 5.2.0.0
- Verified compatibility with FAN SDK 5.2.0.
- Replaced FBAdChoicesView with FBAdOptionsView.
Version 5.1.1.1
- Added support to populate advertiser name asset for Unified Native Ads.
Version 5.1.1.0
- Verified compatibility with FAN SDK 5.1.1.
Version 5.1.0.0
- Verified compatibility with FAN SDK 5.1.0.
Version 5.0.1.0
- Verified compatibility with FAN SDK 5.0.1.
Version 5.0.0.0
- Verified compatibility with FAN SDK 5.0.0.
Version 4.99.3.0
- Verified compatibility with FAN SDK 4.99.3.
Version 4.99.2.0
- Verified compatibility with FAN SDK 4.99.2.
Version 4.99.1.0
- Verified compatibility with FAN SDK 4.99.1.
Version 4.28.1.2
- Added
adapterDidCompletePlayingRewardBasedVideoAd:
callback to the adapter.
Version 4.28.1.1
- Set mediation service for Facebook adapter.
Version 4.28.1.0
- Verified compatibility with FAN SDK 4.28.1.
- Updated rewarded video delegate method.
Version 4.28.0.0
- Verified compatibility with FAN SDK 4.28.0.
- Added support for Google Unified Native Ads.
Version 4.27.2.0
- Verified compatibility with FAN SDK 4.27.2.
Version 4.27.1.0
- Verified compatibility with FAN SDK 4.27.1.
Version 4.27.0.0
- Verified compatibility with FAN SDK 4.27.0.
Version 4.26.1.0
- Verified compatibility with FAN SDK 4.26.1.
Version 4.26.0.0
- Added support for rewarded video ads.
- Added support for native video ads.
- Verified compatibility with FAN SDK 4.26.0.
Version 4.25.0.0
- Updated the adapter's view tracking for native ads to register individual asset views with the Facebook SDK rather than the entire ad view. This means that background (or "whitespace") clicks on the native ad will no longer result in clickthroughs.
- Verified compatibility with FAN SDK v4.25.0.
Version 4.24.0.0
- Verified compatibility with FAN SDK 4.24.0.
Version 4.23.0.1
- Added support for the
backgroundShown
property on Facebook's AdChoices view via network extras. - Updated the default AdChoices icon behaviour. The adapter lets Facebook set the default behaviour if no extras are provided.
Version 4.23.0.0
- Verified compatibility with FAN SDK 4.23.0.
Version 4.22.1.0
- Verified compatibility with FAN SDK 4.22.1.
- Removed the support for
armv7s
architecture.
Version 4.22.0.0
- Verified compatibility with FAN SDK 4.22.0.
Version 4.21.0.0
- Verified compatibility with FAN SDK 4.21.0.
Version 4.20.2.0
- Verified compatibility with FAN SDK 4.20.2.
Version 4.20.1.0
- Verified compatibility with FAN SDK 4.20.1.
Version 4.20.0.0
- Verified compatibility with FAN SDK 4.20.0.
Version 4.19.0.0
- Verified compatibility with FAN SDK 4.19.0.
Version 4.18.0.0
- Verified compatibility with FAN SDK 4.18.0.
- Fixed a bug for native ads where AdChoices icon was rendering out of bounds.
Version 4.17.0.0
- Changed the version naming system to [FAN SDK version].[adapter patch version].
- Updated the minimum required Google Mobile Ads SDK to v7.12.0.
- Added support for native ads.
Version 1.4.0
- Requires Google Mobile Ads SDK 7.8.0 or higher.
- Requires FAN SDK 4.13.1 or higher.
- Adapter now uses [kFBAdSizeInterstitial] instead of [kFBAdSizeInterstital].
- Enabled bitcode.
Version 1.2.1
- Fixed a bug where interstitial presented and interstitial leaving application callbacks were not properly invoked.
Version 1.2.0
- Sends callbacks when an ad is presented and dismissed.
Version 1.1.0
- Added support for full width x 250 format when request is
for
kGADAdSizeMediumRectangle
.
Version 1.0.1
- Added support for
kGADAdSizeSmartBanner
.
Version 1.0.0
- Initial release.