private void RequestInterstitial()
    {
#if UNITY_ANDROID
        string adUnitId = "ca-app-pub-7413680112188055/9660693727";
#elif UNITY_IPHONE
        string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
        string adUnitId = "unexpected_platform";
#endif

        // Initialize an InterstitialAd.
        interstitial = new InterstitialAd(adUnitId);


        //interstitial.OnAdLoaded += HandleOnAdLoaded;
        // Called when an ad request failed to load.
        // interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;        
        // Called when the user returned from the app after an ad click.
        //interstitial.OnAdClosed += HandleOnAdClosed;
        // Called when the ad click caused the user to leave the application.
        //interstitial.OnAdLeavingApplication += HandleOnAdLeavingApplication;
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the interstitial with the request.
        interstitial.LoadAd(request);


        rewardBasedVideo = RewardBasedVideoAd.Instance;
    }
    void Start()
    {
        // Get singleton reward based video ad reference.
        rewardBasedVideo = RewardBasedVideoAd.Instance;

        // RewardBasedVideoAd is a singleton, so handlers should only be registered once.
        rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
        rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
        rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
        rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
        rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
        rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
        rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
    }
Exemplo n.º 3
0
 private void LoadRewardVideoAdmob()
 {
     this.rewardVideo = RewardBasedVideoAd.Instance;
     if (this.rewardVideo != null)
     {
         rv = "rewardVideo inited";
     }
     this.rewardVideo.OnAdClosed += (delegate(System.Object sender, EventArgs args) {
         rv = "Reward video new load";
         this.rewardVideo.LoadAd(new AdRequest.Builder().Build(), admob.rewardVideo);
     });
     this.rewardVideo.OnAdLoaded += (delegate(System.Object sender, EventArgs args) {
         rv = "Reward video Loaded";
     });
     this.rewardVideo.OnAdFailedToLoad += (delegate(System.Object sender, AdFailedToLoadEventArgs args) {
         rv = "Reward video fail to load";
         this.rewardVideo.LoadAd(new AdRequest.Builder().Build(), admob.rewardVideo);
     });
     this.rewardVideo.LoadAd(new AdRequest.Builder().Build(), admob.rewardVideo);
 }
Exemplo n.º 4
-1
	// Use this for initialization
	void Start () 
	{
		#if ADMOB_IMPLEMENTED

		#region REWARDED VIDEO
		//if user filled these fields, we should preload video into memory
		if(!string.IsNullOrEmpty(rewardedVideoAndroid) || !string.IsNullOrEmpty(rewardedVideoIOS))
		{
			rewardBasedVideo = RewardBasedVideoAd.Instance;


			CreateRewardedVideoRequest();

			// Ad event fired when the rewarded video ad
			// has been received.
			rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
			// has failed to load.
			rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
			// is opened.
			rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
			// has started playing.
			rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
			// has rewarded the user.
			rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
			// is closed.
			rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
			// is leaving the application.
			rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
		}
		#endregion

		#region INTERSTITIAL
		//if user filled these fields, we should preload video into memory
		if(!string.IsNullOrEmpty(interstitialAndroid) || !string.IsNullOrEmpty(interstitialAndroid))
		{
			CreateInterstitialRequest();

			// Called when an ad request has successfully loaded.
			interstitial.OnAdLoaded += HandleOnInterstitialLoaded;
			// Called when an ad request failed to load.
			interstitial.OnAdFailedToLoad += HandleOnInterstitialFailedToLoad;
			// Called when an ad is clicked.
			interstitial.OnAdOpening += HandleOnInterstitialOpened;
			// Called when the user returned from the app after an ad click.
			interstitial.OnAdClosed += HandleOnInterstitialClosed;
			// Called when the ad click caused the user to leave the application.
			interstitial.OnAdLeavingApplication += HandleOnInterstitialLeavingApplication;
		}

		#endregion

		#endif
	}