广告单元

关注

开始之前

在将广告单元集成到您的应用之前,您必须:

现在,当您将AdTiming SDK部署到Android或iOS平台时,它就会包含在您的Unity应用程序中。现在您可以实施广告单元了。AdTiming Unity插件提供两种不同的广告格式-视频广告和非页内广告。您可以选择最适合您的用户体验需求的一种。

 

激励视频集成Unity Plugin

具有较强交互能力的奖励视频广告已成为移动广告行业的主流形式。手机游戏开发商越来越依赖内置广告而不是IAP来获利。

AdTiming Rewarded Video广告单元提供引人入胜的广告体验,以有价值的虚拟内容奖励您的用户,以换取完整的视图。这个由用户启动的广告单元非常适合游戏应用,并可以改善您的应用体验。本部分介绍如何初始化,加载和显示奖励视频广告。

步骤 1. 设置奖励视频广告监听器

AdTiming SDK会触发多个事件,以通知您Rewarded Video Ad活动。要显示奖励视频广告,您首先需要实现AdTimingRewardedVideoListener()接口,并将其实例作为参数传递给setRewardedVideoListener()。然后,在每种广告事件回调方法中,您都会获得相应的广告展示位置的状态。

注意事项:

  1. 在加载广告之前实现它,否则将不会触发回调。
  2. 在您的应用中仅使用一个 Listener,多次设置它会导致最后一个监听器覆盖之前的监听器。
AdTiming.Agent.setRewardedVideoListener(new AdTimingRewardedVideoListener());
class AdTimingRewardedVideoListener : AdtRewardedVideoListener
{
/// Invoked when rewarded video is available.
public void OnRewardedVideoAvailabilityChanged(bool available)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAvailabilityChanged"+available);
}
/// Sent immediately when a rewarded video starts to play.
public void OnRewardedVideoAdStarted(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdStarted:" + scene);
}
/// Sent immediately when a rewarded video has been showed.
public void OnRewardedVideoAdShowed(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdShowed:" + scene);
}
/// Sent after a rewarded video has failed to play..
public void OnRewardedVideoAdShowFailed(string scene, string adTimingError)
{
Debug.LogError("UnityApp RewardedVideo OnRewardedVideoAdShowFailed:" + scene);
}
/// Sent after a rewarded video has been clicked.
public void OnRewardedVideoAdClicked(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdClicked:" + scene);
}
/// Sent after a rewarded video has been closed.
public void OnRewardedVideoAdClosed(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdClosed:" + scene);
}
/// Sent immediately when a rewarded video has been completed.
public void OnRewardedVideoAdEnded(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdEnded:" + scene);
}
/// Sent after a user has been granted a reward.
public void OnRewardedVideoAdRewarded(string scene)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAdRewarded:" + scene);
}
}

 

步骤 2. 检查广告的可用性

奖励广告成功加载后,将通过OnRewardedVideoAvailabilityChanged回调通知您何时可以显示广告,该通知将通知您广告资源的可用性。 

public void OnRewardedVideoAvailabilityChanged(bool available)
{
Debug.Log("UnityApp RewardedVideo OnRewardedVideoAvailabilityChanged"+available);
}

检查广告是否可用的另一种方法是直接调用isRewardedVideoReady函数。

 

AdTiming.Agent.isRewardedVideoReady();

 

步骤 3. 展示激励视频广告

强烈建议您在投放奖励视频之前,通过调用isReady方法来检查广告的可用性  

if (AdTiming.Agent.isRewardedVideoReady())
{
AdTiming.Agent.showRewardedVideo("Your Video SceneName");
}

 

插屏广告集成Unity Plugin

AdTiming Interstitial是全屏广告单元,通常在应用程序的生命周期内的自然过渡点投放。同时支持静态和视频非页内广告。

步骤 1.设置InterstitialAd Listener

AdTiming SDK会触发多个事件来通知您非页内广告活动。要显示非页内广告,您首先需要实现AdTimingInterstitialAdListener()接口,并将其实例作为参数传递给setInterstitialListener()。然后,在每种广告事件回调方法中,您都会获得相应的广告展示位置的状态。

注意事项:

  1. 加载广告之前实现步骤1否则将不会触发回调。
  2. 在您的应用中仅使用一个 Listener,多次设置它会导致最后一个监听器覆盖之前的监听器。
AdTiming.Agent.setInterstitialListener(new AdTimingInterstitialListener());
class AdTimingInterstitialListener : AdtInterstitialAdListener
{
/// Invoked when interstitial video is available.
public void OnInterstitialAdAvailabilityChanged(bool available)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdAvailabilityChanged: "+available);
}
/// Invoked when interstitial video has been showed.
public void OnInterstitialAdShowed(string scene)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdShowed:" + scene);
}
/// Sent after a interstitial video has failed to play.
public void OnInterstitialAdShowFailed(string scene, string error)
{
Debug.LogError("UnityApp Interstitial OnInterstitialAdShowFailed:" + scene);
}
/// Sent after a interstitial video has been closed.
public void OnInterstitialAdClosed(string scene)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdClosed:" + scene);
}
/// Sent after a interstitial video has been clicked.
public void OnInterstitialAdClicked(string scene)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdClicked:" + scene);
}
}

 

步骤 2. 检查广告的可用性

插页式广告成功加载后,将通过OnInterstitialAdAvailabilityChanged回调通知您何时可以显示广告,该通知将通知您广告资源的可用性。

public void OnInterstitialAdAvailabilityChanged(bool available)
{
Debug.Log("UnityApp Interstitial OnInterstitialAdAvailabilityChanged"+available);
}

检查广告是否可用的另一种方法是直接调用isInterstitialReady函数。

AdTiming.Agent.isInterstitialReady();

 

步骤 3. 展示插屏广告

强烈建议您在投放插页式广告之前,通过调用isReady方法来检查广告的可用性  

if (AdTiming.Agent.isInterstitialReady())
{
AdTiming.Agent.showInterstitial(
"Your Video SceneName");
}

提示:

启用本地日志记录:(仅用于本地调试,在上线之前将其删除。)

AndroidLogTag: AdTimingAPI

AdTiming.Agent.debug(true);
这篇文章有帮助吗?
2 人中有 2 人觉得有帮助

评论

0 条评论

文章评论已关闭。