Пример #1
0
    // 보상형 광고
    private void RequestRewardedAd()
    {
        string adUnitId = isTest ? AD.TEST_REWARD : AD.REWARDAD;

        this.RewardAd = new RewardedAd(adUnitId);

        // Called when an ad request has successfully loaded.
        this.RewardAd.OnAdLoaded += HandleRewardedAdLoaded;
        // Called when an ad request failed to load.
        this.RewardAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
        // Called when an ad is shown.
        this.RewardAd.OnAdOpening += HandleRewardedAdOpening;
        // Called when an ad request failed to show.
        this.RewardAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
        // Called when the user should be rewarded for interacting with the ad.
        this.RewardAd.OnUserEarnedReward += HandleUserEarnedReward;
        // Called when the ad is closed.
        this.RewardAd.OnAdClosed += HandleRewardedAdClosed;

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the rewarded ad with the request.
        this.RewardAd.LoadAd(request);

        AdRequest request2 = new AdRequest.Builder().Build();

        RewardedInterstitialAd.LoadAd(adUnitId, request2, adLoadCallback);
    }
Пример #2
0
    /*
     * public void HandleOnAdClosed(object sender, EventArgs args)
     * {
     *  MonoBehaviour.print("HandleAdClosed event received");
     *  interstitial.Destroy();
     * }
     * public void HandleOnAdOpened(object sender, EventArgs args)
     * {
     *  MonoBehaviour.print("HandleAdOpened event received");
     * }
     */

    //보상형 전면 광고
    private void adLoadCallback(RewardedInterstitialAd ad, string error)
    {
        if (error == null)
        {
            rewardedInterstitialAd = ad;
            rewardedInterstitialAd.OnAdFailedToPresentFullScreenContent += HandleAdFailedToPresent;
        }
    }
Пример #3
0
    public void InitAdmobRewardedInterstitialAd()
    {
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the rewarded ad with the request.
        RewardedInterstitialAd.LoadAd(AdmobRewardInterstitialID, request, AdLoadCallback);
    }
Пример #4
0
    private void adLoadCallback(RewardedInterstitialAd ad, string error)
    {
        if (error == null)
        {
            RewardInterAd = ad;

            RewardInterAd.OnAdFailedToPresentFullScreenContent += HandleAdFailedToPresent;
            RewardInterAd.OnAdDidPresentFullScreenContent      += HandleAdDidPresent;
            RewardInterAd.OnAdDidDismissFullScreenContent      += HandleAdDidDismiss;
            RewardInterAd.OnPaidEvent += HandlePaidEvent;
        }
    }
    private IEnumerator CoAwaitForAdDisplay()
    {
        AdRequest request = new AdRequest.Builder().Build();

        RewardedInterstitialAd.LoadAd(componentTypeStringAdmob, request, AdLoadCallback);

        //while (rewardedInterstitial.)
        //yield return null;
        yield return(new WaitForSeconds(2));

        ShowRewardedInterstitialAd();
    }
    public void RequestAndLoadRewardedInterstitialAd()
    {
        statusText.text = "Requesting Rewarded Interstitial Ad.";
        // These ad units are configured to always serve test ads.
    #if UNITY_EDITOR
        string adUnitId = "unused";
    #elif UNITY_ANDROID
        string adUnitId = "ca-app-pub-3940256099942544/5354046379";
    #elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-3940256099942544/6978759866";
    #else
        string adUnitId = "unexpected_platform";
    #endif

        // Create an interstitial.
        RewardedInterstitialAd.LoadAd(adUnitId, CreateAdRequest(), (rewardedInterstitialAd, error) =>
        {
            if (error != null)
            {
                MobileAdsEventExecutor.ExecuteInUpdate(() => {
                    statusText.text = "RewardedInterstitialAd load failed, error: " + error;
                });
                return;
            }

            this.rewardedInterstitialAd = rewardedInterstitialAd;
            MobileAdsEventExecutor.ExecuteInUpdate(() => {
                statusText.text = "RewardedInterstitialAd loaded";
            });
            // Register for ad events.
            this.rewardedInterstitialAd.OnAdDidPresentFullScreenContent += (sender, args) =>
            {
                MobileAdsEventExecutor.ExecuteInUpdate(() => {
                    statusText.text = "Rewarded Interstitial presented.";
                });
            };
            this.rewardedInterstitialAd.OnAdDidDismissFullScreenContent += (sender, args) =>
            {
                MobileAdsEventExecutor.ExecuteInUpdate(() => {
                    statusText.text = "Rewarded Interstitial dismissed.";
                });
                this.rewardedInterstitialAd = null;
            };
            this.rewardedInterstitialAd.OnAdFailedToPresentFullScreenContent += (sender, args) =>
            {
                MobileAdsEventExecutor.ExecuteInUpdate(() => {
                    statusText.text = "Rewarded Interstitial failed to present.";
                });
                this.rewardedInterstitialAd = null;
            };
        });
    }
Пример #7
0
            public override void OnRewardedInterstitialAdLoaded(RewardedInterstitialAd ad)
            {
                try
                {
                    base.OnRewardedInterstitialAdLoaded(ad);
                    Rad = ad;
                    Rad?.Show(Context, new MyUserEarnedRewardListener(Rad));

                    Rad.SetFullScreenContentCallback(new MyFullScreenContentCallback(Rad));
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }
            }
    private void AdLoadCallback(RewardedInterstitialAd ad, string error)
    {
        if (error == null)
        {
            rewardedInterstitial = ad;

            rewardedInterstitial.OnAdFailedToPresentFullScreenContent += HandleAdFailedToPresent;
            rewardedInterstitial.OnAdDidPresentFullScreenContent      += HandleAdDidPresent;
            rewardedInterstitial.OnAdDidDismissFullScreenContent      += HandleAdDidDismiss;
            rewardedInterstitial.OnPaidEvent += HandlePaidEvent;

            Debug.Log("Rewarded interstitial finalizado");

            //onAdLoadedCallback.Invoke();
        }
    }
Пример #9
0
            public void ShowAd(Activity context)
            {
                try
                {
                    Context = context;

                    AdRequest adRequest = new AdRequest.Builder().Build();

                    // Use an activity context to get the rewarded video instance.
                    RewardedInterstitialAd.Load(context, AppSettings.AdRewardedInterstitialKey, adRequest, this);
                }
                catch (Exception exception)
                {
                    Methods.DisplayReportResultTrack(exception);
                }
            }
Пример #10
0
    // Use this for initialization 앱 ID
    void Start()
    {
        if (PlayerPrefs.GetInt("outtimecut", 0) == 4 && PlayerPrefs.GetInt("scene", 0) == 0)
        {
            cutTime_btn.interactable = false;
        }
        color = new Color(1f, 1f, 1f);

#if UNITY_ANDROID
        string appId = "ca-app-pub-9179569099191885~8249233951"; //테스트용ca-app-pub-3940256099942544~3347511713
#elif UNITY_IPHONE
        string appId = "ca-app-pub-3940256099942544~1458002511";
#else
        string appId = "unexpected_platform";
#endif
        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(appId);

        //this.RequestBanner();


        this.rewardBasedVideo = RewardBasedVideoAd.Instance;

        // Called when the user should be rewarded for watching a video.
        rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
        // Called when the ad is closed.
        rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;

        this.RequestRewardedVideo();
        this.RequestInterstitial();

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the rewarded ad with the request.
        RewardedInterstitialAd.LoadAd("ca-app-pub-9179569099191885/6551741269", request, adLoadCallback);
    }
Пример #11
0
 public MyFullScreenContentCallback(RewardedInterstitialAd rad)
 {
     Rad = rad;
 }
Пример #12
0
 public MyUserEarnedRewardListener(RewardedInterstitialAd rad)
 {
     Rad = rad;
 }