// Все 'adUnitId' и 'appId' указаны верно.
using UnityEngine;
using System;
using System.Collections;
using GoogleMobileAds.Api;
public class GoogleAdsController : MonoBehaviour {
private RewardBasedVideoAd rewardBasedVideo;
public void Show(){
if(rewardBasedVideo.IsLoaded()) {
rewardBasedVideo.Show();
}
}
public void Start(){
string appId = "---";
MobileAds.Initialize(appId);
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
this.RequestRewardBasedVideo();
}
private void RequestRewardBasedVideo(){
string adUnitId = "---";
AdRequest request = new AdRequest.Builder().Build();
this.rewardBasedVideo.LoadAd(request, adUnitId);
}
public void HandleRewardBasedVideoLoaded(object sender, EventArgs args){
Debug.Log("HandleRewardBasedVideoLoaded event received");
}
public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args){
Debug.Log("HandleRewardBasedVideoFailedToLoad event received with message: " + args.Message);
}
public void HandleRewardBasedVideoOpened(object sender, EventArgs args){
Debug.Log("HandleRewardBasedVideoOpened event received");
}
public void HandleRewardBasedVideoStarted(object sender, EventArgs args){
Debug.Log("HandleRewardBasedVideoStarted event received");
}
public void HandleRewardBasedVideoClosed(object sender, EventArgs args){
Debug.Log("HandleRewardBasedVideoClosed event received");
}
public void HandleRewardBasedVideoRewarded(object sender, Reward args){
string type = args.Type;
double amount = args.Amount;
Debug.Log("HandleRewardBasedVideoRewarded event received for " + amount.ToString() + " " + type);
}
public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args){
Debug.Log("HandleRewardBasedVideoLeftApplication event received");
}
}
Show()
, в логе пишет Dummy ShowRewardBasedVideoAd
и ничего не происходит, рекламы нет. Что делать?testId
, но не понял где это взять.