Adobe AIR 的插页式广告集成
使用 LevelPlay SDK(包括事件监听器和广告放置/位置配置)将插页式广告服务集成到 Adobe AIR 应用程序中。
阅读时间6 分钟最后更新于 2 天前
完成几个简单步骤即可开始使用 Interstitial Ad Unit:
- 实现监听器
- 加载插页式广告
- 检查广告可用性
- 显示插页式广告
先决条件
确保已正确集成 ironSource Adobe AIR 插件。此处概述了集成。
步骤 1.实现 Interstitial 监听器
ironSource Adobe AIR 插件会触发多个事件来通知您 Interstitial Activity。要接收这些事件,必须实现 Interstitial EventListener:
IronSource.instance.addEventListener( "EventName", functionToCall );
- EventName = 包含要监听的事件的字符串。
- functionToCall = 触发事件时要调用的函数。
ironSource Adobe AIR 插件将通知您的监听器以下列出的所有可能事件:
IronSource.instance.addEventListener("levelPlayInterstitialAdReady", levelPlayInterstitialAdReady);IronSource.instance.addEventListener("levelPlayInterstitialAdLoadFailed", levelPlayInterstitialAdLoadFailed);IronSource.instance.addEventListener("levelPlayInterstitialAdOpened", levelPlayInterstitialAdOpened);IronSource.instance.addEventListener("levelPlayInterstitialAdShowSucceeded", levelPlayInterstitialAdShowSucceeded);IronSource.instance.addEventListener("levelPlayInterstitialAdShowFailed", levelPlayInterstitialAdShowFailed);IronSource.instance.addEventListener("levelPlayInterstitialAdClicked", levelPlayInterstitialAdClicked);IronSource.instance.addEventListener("levelPlayInterstitialAdClosed", levelPlayInterstitialAdClosed);
插件将通知监听器以下列出的所有可能事件:
private function levelPlayInterstitialAdClosed(event:Event):void { //level Play Interstitial Ad Closed}private function levelPlayInterstitialAdClicked(event:Event):void { //level Play Interstitial Ad Clicked}private function levelPlayInterstitialAdShowFailed(event:Event):void { //level Play Interstitial Ad Show Failed}private function levelPlayInterstitialAdShowSucceeded(event:Event):void { //on Ad Show level Play Interstitial Ad Show Succeeded}private function levelPlayInterstitialAdOpened(event:Event):void { //on Ad level Play Interstitial Ad Opened}private function levelPlayInterstitialAdLoadFailed(event:Event):void { //level Play Interstitial Ad Load Failed}private function levelPlayInterstitialAdReady(event:Event):void { //level Play Interstitial Ad Ready}
-
onAdlevelPlayInterstitialAdOpenedOpened 事件传达广告格式已占据 app 屏幕,但不表示广告已成功送达您的终端用户。
-
onAdShowlevelPlayInterstitialAdShowSucceeded 事件将来自 IronSource 或任何其他广告网络的插页式广告成功送达您的终端用户。
-
Ironsource 提供了一种报错代码机制,可帮助您了解在集成或实际生产过程中可能运行的错误。按如下方式从 DataEvent 对象中提取报错数据:var errorCode:String;var errorDescription:String; if(event.data){ var error:Object = JSON.parse(event.data); errorDescription = error.error_description; errorCode = error.error_code;}请参阅此处关于 ironSource 报错代码的完整描述。
步骤 2.加载 Interstitial Ad
我们建议您在计划向用户展示 Interstitial Ad 之前稍后申请,因为加载过程可能需要时间。要请求插页式广告,请调用以下方法:
IronSource.instance.loadInterstitial();
步骤 3.检查广告可用性
调用 loadInterstitial 后,系统会在广告加载并准备好向用户展示时通知您。levelPlayInterstitialAdReady 事件将通知您广告可用性。
private function levelPlayInterstitialAdReady(event:Event):void {}
如果插页式广告不可用,您将收到 levelPlayInterstitialAdLoadFailed 事件:
private function levelPlayInterstitialAdLoadFailed(event:Event):void {}
步骤 4.显示 Interstitial
在有可用的插页后,可以通过调用以下方法向用户展示此广告:
IronSource.instance.showInterstitial();
使用 ironSource Ad Placements,您可以自定义和优化 Interstitial 体验。此工具允许您在不同位置(例如,app 发布或关卡之间)向用户展示插页式广告服务。您可以使用以下函数来定义要展示广告的确切放置/位置。
IronSource.instance.showInterstitial(YOUR_PLACEMENT_NAME);
除了 ironSource Ad Placements,现在还可以为所选广告位配置上限和节奏设置。限制和调整进度可通过限制定义时间范围内的广告服务量来改善 app 中的用户体验。
您现在可以在应用程序中投放插页式广告服务。
后续步骤
请遵循我们的集成指南来实现其他广告单位: