跳转到内容

高级设置

广告位

您可以为每个广告单元设置广告位名称 (例如 “Rewarded VideoLevels”、“INTER_levelEnd” 或 “RewardedVideoCoinStore”)。 这可以帮助您汇总不同广告位类别的统计数据。 下面的片段展示了如何为不同的广告格式设置广告位名称。

横幅和 MREC

AppLovinMAX.createBanner(«ad-unit-ID», «position»);
AppLovinMAX.setBannerPlacement(«ad-unit-ID», «placement»);

插屏广告

import { InterstitialAd } from 'react-native-applovin-max';
InterstitialAd.showAd(«ad-unit-ID», «placement»);

激励广告

import { RewardedAd } from 'react-native-applovin-max';
RewardedAd.showAd(«ad-unit-ID», «placement»);

静音

您可以在启动应用时将某些 SDK 平台的音频设为关闭。 通过 AppLovin SDK 支持该功能的平台包括 Google 竞价和 Google AdMob、AppLovin、DT Exchange、Google Ad Manager、LINE、Mintegral、腾讯和 Verve。 对于其他平台,请咨询平台客户团队,了解此功能是否可用以及使用方法。

下面的代码片段展示了如何在支持静音的平台中设置静音:

AppLovinMAX.setMuted(true);

启用详细日志

通过以下方式启用详细日志:

AppLovinMAX.setVerboseLogging(true);

要验证是否已成功启用详细日志,请查看 AppLovin SDK 日志初始化部分中是否有 Verbose Logging On: true行。

AppLovin SDK
Version: 11.4.2
Verbose Logging On: true

AppLovin SDK 的日志标签为 “/AppLovinSdk: [AppLovinSdk]”。

Creative ID 和平台名称

您可以调取各个聚合平台已展示广告的 Creative ID 和平台名称。 请参阅 the Creative Debugger documentation 了解更多信息。

DSP 名称

您可以通过广告的 dspName 属性调取 AppLovin Exchange 投放的 MAX 广告的 DSP 名称

InterstitialAd.addAdLoadedEventListener((adInfo: AdInfo) = {
console.log("AppLovin Exchange DSP Name: " + adInfo.dspName);
}

展示层级用户收入 API

You can access impression-level user revenue data on the client side. You can use this data to compare different sources and campaigns. You can also access this data by using the MAX User Revenue API.

您可以针对所有受支持的平台与 Adjust 等移动监测合作伙伴分享展示层级广告收入数据。

您可以在所有广告生命周期回传中调取收入金额。 以下示例展示了如何在 “ad revenue paid” 回传中执行此操作:

InterstitialAd.addAdRevenuePaidListener((adInfo: AdRevenueInfo) => {…});
RewardedAd.addAdRevenuePaidListener((adInfo: AdRevenueInfo) => {…});
BannerAd.addAdRevenuePaidListener((adInfo: AdRevenueInfo) => {…});
MRecAd.addAdRevenuePaidListener((adInfo: AdRevenueInfo) => {…});
AppOpenAd.addAdRevenuePaidListener((adInfo: AdRevenueInfo) => {…});
InterstitialAd.addAdRevenuePaidListener((adInfo: AdRevenueInfo) => {
const revenue = adInfo.revenue;
// Miscellaneous data
const countryCode = adInfo.countryCode; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
const networkName = adInfo.networkName; // Display name of the network that showed the ad
const adUnitId = adInfo.adUnitId; // The MAX Ad Unit ID
const placement = adInfo.placement; // The placement this ad's postbacks are tied to
const networkPlacement = adInfo.networkPlacement; // The placement ID from the network that showed the ad
});

选择性初始化

You can initialize the SDK with specific ad units. If you do so, the SDK only initializes those networks that you have configured for the ad units you specify. (If you do not specify any ad units, the SDK assumes the current session needs all of your ad units. If so, it initializes all networks that you have configured for them.) The following example shows how you implement this feature:

AppLovinMAX.setInitializationAdUnitIds([ "«ad-unit-ID-1»", "«ad-unit-ID-2»" ]);
AppLovinMAX.initialize(«SDK-key»).then((conf: Configuration) => { ... });

Waterfall Information API

Waterfall Information API 可向您展示广告的当前瀑布流 (已加载或加载失败的广告)。 API 会返回瀑布流中每则广告的广告加载状态、延迟、配置信息和聚合平台信息。 如果瀑布流中的广告加载失败,API 会提供错误信息。

This API is is not supported in React Native plugin versions 9.x.

AdLoadState 值

解释
0未尝试加载广告
1广告已加载
2广告加载失败

示例

InterstitialAd.addAdLoadedEventListener((adInfo: AdInfo) => {
console.log('Waterfall Name: ' + adInfo.waterfall.name + ' and Test Name: ' + adInfo.waterfall.testName);
console.log('Waterfall latency was: ' + adInfo.waterfall.latencyMillis + ' milliseconds');
adInfo.waterfall.networkResponses.forEach((networkResponse: AdNetworkResponseInfo) => {
console.log('Network name:' + networkResponse.mediatedNetwork.name +
' adapterClassName:'+ networkResponse.mediatedNetwork.adapterClassName +
' sdkVersion:' + networkResponse.mediatedNetwork.sdkVersion +
' adapterVersion:' + networkResponse.adapterVersion);
console.log('...adLoadState:' + networkResponse.adLoadState);
console.log('...latency:' + networkResponse.latencyMillis);
});
});
InterstitialAd.addAdLoadFailedEventListener((errorInfo: AdLoadFailedInfo) => {
console.log('Waterfall Name: ' + errorInfo.waterfall.name + ' and Test Name: ' + errorInfo.waterfall.testName);
console.log('Waterfall latency was: ' + errorInfo.waterfall.latencyMillis + ' milliseconds');
errorInfo.waterfall.networkResponses.forEach((networkResponse: AdNetworkResponseInfo) => {
console.log('Network name:' + networkResponse.mediatedNetwork.name +
' adapterClassName:'+ networkResponse.mediatedNetwork.adapterClassName +
' sdkVersion:' + networkResponse.sdkVersion +
' adapterVersion:' + networkResponse.adapterVersion);
console.log('...latency:' + networkResponse.latencyMillis);
console.log('...error code:' + networkResponse.error.code + ' message:' + networkResponse.error.message);
});
});

输出

Waterfall Name: Default Waterfall and Test Name: Control
Waterfall latency was: 2793 milliseconds
Network adapterClassName:com.applovin.mediation.adapters.UnityAdsMediationAdapter name:Unity Ads sdkVersion:4.2.1.0 adapterVersion:4.2.1
...adLoadState:2
...latency:25
...credentials placement_id:BN_0_9
...error code:-5212 message:WebView Error
Network adapterClassName:com.applovin.mediation.adapters.LineMediationAdapter name:LINE Ads sdkVersion:2.4.20211029 adapterVersion:2021.10.29.2
...adLoadState:2
...latency:275
...credentials placement_id:872167
...error code:-5205 message:Ad Not Ready
Network adapterClassName:com.applovin.mediation.adapters.ByteDanceMediationAdapter name:Pangle sdkVersion:4.3.0.9 adapterVersion:4.3.0.9
...adLoadState:1
...latency:337
...credentials placement_id:980034018