原生广告
Native ads let you monetize your app in a way that’s consistent with its existing design. The AppLovin MAX Flutter plugin gives you access to an ad’s individual assets. This allows you to design the ad layout to be consistent with the look and feel of your app. The SDK automatically handles image caching and metrics tracking. You can focus on how, when, and where to display ads.
该插件暂时仅支持手动集成,您可以手动将原生广告资源加载到自定义视图中。 手动集成大致分三个步骤:
- 声明 Flutter UI 组件。
- 刷新原生广告。
- 销毁原生广告。
要使用手动 API,在 Create New Ad Unit 界面中选择 Manual 模板:
声明 Flutter UI 组件
MaxNativeAdView
是保存原生广告组件的容器,挂载后会自动为您提供的 adUnitId
属性加载原生广告。
该插件提供了多种组件,能渲染原生广告的各类资源。
您可以设置这些组件的样式,方法与应用中其他组件一样。
根据 AppLovin 的政策,您的广告必须包含隐私信息图标。
此图标需链接至重要隐私声明。
您可以使用 MaxNativeOptionsView
组件对其进行绑定。
下表中列出了渲染原生广告资源的各种组件:
组件 | 类型 |
---|---|
MaxNativeAdAdvertiserView | Text |
MaxNativeAdBodyView | Text |
MaxNativeAdCallToActionView | ElevatedButton |
MaxNativeAdIconView | Container |
MaxNativeAdMediaView | Container |
MaxNativeAdOptionsView | Container |
MaxNativeAdStarRatingView | Container |
MaxNativeAdTitleView | Text |
下方示例代码中,示例原生广告使用了所有这些原生广告组件。 AppLovin 并不保证某个广告平台会返回特定资源。 要查看完整运行示例,请访问 AppLovin-MAX-Flutter GitHub 项目中的示例应用。
Container( margin: const EdgeInsets.all(8.0), height: 300, child: MaxNativeAdView( adUnitId: widget.adUnitId, controller: _nativeAdViewController, listener: NativeAdListener(onAdLoadedCallback: (ad) { logStatus('Native ad loaded from ${ad.networkName}'); setState(() { _mediaViewAspectRatio = ad.nativeAd?.Mediacontentaspectratio ?? _kMediaViewAspectRatio; }); }, onAdLoadFailedCallback: (adUnitId, error) { logStatus('Native ad failed to load with error code ${error.code} and message: ${error.message}'); }, onAdClickedCallback: (ad) { logStatus('Native ad clicked'); }, onAdRevenuePaidCallback: (ad) { logStatus('Native ad revenue paid: ${ad.revenue}'); }), child: Container( color: const Color(0xffefefef), padding: const EdgeInsets.all(8.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( padding: const EdgeInsets.all(4.0), child: const MaxNativeAdIconView( width: 48, height: 48, ), ), Flexible( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ MaxNativeAdTitleView( style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), maxLines: 1, overflow: TextOverflow.visible, ), MaxNativeAdAdvertiserView( style: TextStyle(fontWeight: FontWeight.normal, fontSize: 10), maxLines: 1, overflow: TextOverflow.fade, ), MaxNativeAdStarRatingView( size: 10, ), ], ), ), const MaxNativeAdOptionsView( width: 20, height: 20, ), ], ), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Flexible( child: MaxNativeAdBodyView( style: TextStyle(fontWeight: FontWeight.normal, fontSize: 14), maxLines: 3, overflow: TextOverflow.ellipsis, ), ), ], ), const SizedBox(height: 8), Expanded( child: AspectRatio( aspectRatio: _mediaViewAspectRatio, child: const MaxNativeAdMediaView(), ), ), const SizedBox( width: double.infinity, child: MaxNativeAdCallToActionView( style: ButtonStyle( backgroundColor: MaterialStatePropertyAll(Color(0xff2d545e)), textStyle: MaterialStatePropertyAll(TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), ), ), ), ], ), ), ),),
广告重新加载
挂载 MaxNativeAdView
时,AppLovin Flutter plugin 会自动加载第一个原生广告。
挂载完毕后,您可以调用 MaxNativeAdViewController
的 load()
方法,加载下一则广告。
final MaxNativeAdViewController _nativeAdViewController = MaxNativeAdViewController();_nativeAdViewController.loadAd();
资源规模
AppLovin 建议您根据应用整体外观和风格情况,添加尽可能多的原生元素,包括标题、媒体视图和图标等。 为用户提供更多信息,有助于他们决定是否点击广告。
对于 AppLovin Exchange 广告需求,标题、描述和 CTA 所允许的最大字符数如下:
资源 | 最大字符数 |
---|---|
标题 | 50 个字符 |
描述 | 150 个字符。可以在第 149 个字符后添加省略号 (... )作为第 150 个字符。 |
CTA | 15 个字符 |
对于 SDK 聚合的广告平台,最大字符数由广告平台设置。
如何获取媒体内容长宽比
您可以从 adInfo
中调取用于 MediaView 的媒体内容长宽比。
这是 onAdLoaded()
回传的一个参数:
ad.nativeAd?mediaContentAspectRatio
受支持的适配器版本
广告平台 | 适配器版本 |
---|---|
BidMachine | Android 1.9.10.5 / iOS 1.9.5.0.2 |
Criteo | Android 4.8.1.1 / iOS 4.5.0.6 |
Google Ad Manager | Android 22.1.0.1 / iOS 10.3.0.2 |
Google 竞价和 Google AdMob | Android 22.1.0.1 / iOS 10.3.0.2 |
InMobi | Android 10.1.2.1 / iOS 10.1.1.1 |
LINE | Android 2022.2.16.3 / iOS 2.4.20220630.1 |
Meta Audience Network | Android 6.12.0.1 / iOS 6.12.0.1 |
Mintegral | Android 16.2.61.2 / iOS 7.2.6.0.1 |
Moloco | Android 3.5.0.0 / iOS 3.6.0.0 |
Pangle | Android 4.8.0.8.2 / iOS 4.7.0.8.2 |
Smaato | Android 21.8.5.1 / iOS 21.7.8.1 |
VK Ad Network | Android 5.16.0.1 / iOS 5.16.0.1 |
Yandex | 仅限 Android 5.3.0.1 |
星级评分
您可以访问并渲染所推广应用的星级评分。 在可用情况下,该值是 [0.0, 5.0] 范围内的浮点数。
AppLovin MAX Flutter plugin 会自动渲染 MaxNativeAdStarRatingView
组件中的星级。
如果平台未提供星级评分信息,那么 AppLovin MAX Flutter plugin 就会将星级评级留空。您需要自行进行对应的布局调整。
您可以从 ad.nativeAd?starRating
中调取星级评分,用于当前的广告。