激励广告视频系统APP开发

   2023-12-19 370

  广告事件


  要进一步自定义您的广告行为,您可以在广告生命周期内加入许多事件,如加载、打开、关闭等等。您可以通过为相应的EventHandler注册代理来监听这些事件。其中*重要的事件是OnAdRewarded,当用户因观看视频而应获得奖励时会调用该事件。您还可以实现其他广告事件,如下所示。


 图片_20220707110945.jpg


  using GoogleMobileAds.Api;


  ...


  public class GoogleMobileAdsDemoscript:MonoBehaviour


  {


  private RewardbasedVideoAd rewardbasedVideo;


  ...


  public void Start()


  {


  //Get singleton reward based video ad reference.


  this.rewardbasedVideo=RewardbasedVideoAd.Instance;


  //Called when an ad request has successfully loaded.


  rewardbasedVideo.OnAdLoaded+=HandleRewardbasedVideoLoaded;


  //Called when an ad request failed to load.


  rewardbasedVideo.OnAdFailedToLoad+=HandleRewardbasedVideoFailedToLoad;


  //Called when an ad is shown.


  rewardbasedVideo.OnAdOpening+=HandleRewardbasedVideoOpened;


  //Called when the ad starts to play.


  rewardbasedVideo.OnAdStarted+=HandleRewardbasedVideoStarted;


  //Called when the user should be rewarded for watching a video.


  rewardbasedVideo.OnAdRewarded+=HandleRewardbasedVideoRewarded;


  //Called when the ad is closed.


  rewardbasedVideo.OnAdClosed+=HandleRewardbasedVideoClosed;


  //Called when the ad click caused the user to leave the application.


  rewardbasedVideo.OnAdLeavingApplication+=HandleRewardbasedVideoLeftApplication;


  uestRewardbasedVideo();


  }


  private void RequestRewardbasedVideo()


  {


  #if UNITY_ANDROID


  string adUnitId="ca-app-pub-544/";


  #elif UNITY_IPHONE


  string adUnitId="ca-app-pub-544/";


  #else


  string adUnitId="unexpected_platform";


  #endif


  //Create an empty ad request.


  AdRequest request=new AdRe().Build();


  //Load the rewarded video ad with the request.


  this.rewardbasedVideo.LoadAd(request,adUnitId);


  }


  public void HandleRewardbasedVideoLoaded(object sender,EventArgs args)


  {


  MonoBehaviour.print("HandleRewardbasedVideoLoaded event received");


  }


  public void HandleRewardbasedVideoFailedToLoad(object sender,AdFailedToLoadEventArgs args)


  {


  MonoBehaviour.print(


  "HandleRewardbasedVideoFailedToLoad event received with message:"


  +args.Message);


  }


  public void HandleRewardbasedVideoOpened(object sender,EventArgs args)


  {


  MonoBehaviour.print("HandleRewardbasedVideoOpened event received");


  }


  public void HandleRewardbasedVideoStarted(object sender,EventArgs args)


  {


  MonoBehaviour.print("HandleRewardbasedVideoStarted event received");


  }


  public void HandleRewardbasedVideoClosed(object sender,EventArgs args)


  {


  MonoBehaviour.print("HandleRewardbasedVideoClosed event received");


  }


  public void HandleRewardbasedVideoRewarded(object sender,Reward args)


  {


  string type=args.Type;


  double amount=args.Amount;


  MonoBehaviour.print(


  "HandleRewardbasedVideoRewarded event received for"


  +amount.ToString()+""+type);


  }


  public void HandleRewardbasedVideoLeftApplication(object sender,EventArgs args)


  {


  MonoBehaviour.print("HandleRewardbasedVideoLeftApplication event received");


  }


  }


核心提示:激励广告视频系统开发,激励广告视频系统软件
 
标签: 商务服务,软件开发,APP开发
反对 0举报 0 收藏 0 打赏 0评论 0
 
同类新闻
  • 联系人:陈总监
  • 地址:广州市天河区中山大道东路
  • 手机:13828487919
我们的产品