Create() public static method

public static Create ( ) : InterstitialAd
return InterstitialAd
Example #1
0
        public void OnInterstitialWithEngageBtn_Clicked()
        {
            var engagement = new Engagement("showInterstitial");

            DDNA.Instance.RequestEngagement(engagement, response => {
                var interstitialAd = InterstitialAd.Create(response);

                if (interstitialAd != null)   // Engagement didn't prevent ad from showing
                {
                    interstitialAd.OnInterstitialAdOpened += () => {
                        Debug.Log("Interstitial Ad opened its ad.");
                    };

                    interstitialAd.OnInterstitialAdFailedToOpen += (reason) => {
                        Debug.Log("Interstitial Ad failed to open its ad: " + reason);
                    };

                    interstitialAd.OnInterstitialAdClosed += () => {
                        Debug.Log("Interstitial Ad closed its ad.");
                    };

                    interstitialAd.Show();
                }
                else
                {
                    Debug.Log("Engage disabled the interstitial ad from showing.");
                }
            }, exception => {
                Debug.Log("Engage encountered an error: " + exception.Message);
            });
        }
Example #2
0
        public void OnInterstitialBtn_Clicked()
        {
            var interstitialAd = InterstitialAd.Create();

            if (interstitialAd != null)
            {
                interstitialAd.Show();
            }
        }
        void OnGUI()
        {
            if (GUI.Button(new Rect(10, 20, 200, 80), "Interstitial"))
            {
                var interstitialAd = InterstitialAd.Create();
                if (interstitialAd != null)
                {
                    interstitialAd.Show();
                }
            }

            if (GUI.Button(new Rect(10, 120, 200, 80), "Interstitial with Engage"))
            {
                var engagement = new Engagement("showInterstitial");

                DDNA.Instance.RequestEngagement(engagement, response =>
                {
                    var interstitialAd = InterstitialAd.Create(response);

                    if (interstitialAd != null)     // Engagement didn't prevent ad from showing

                    {
                        interstitialAd.OnInterstitialAdOpened += () => {
                            Debug.Log("Interstitial Ad opened its ad.");
                        };

                        interstitialAd.OnInterstitialAdFailedToOpen += (reason) => {
                            Debug.Log("Interstitial Ad failed to open its ad: " + reason);
                        };

                        interstitialAd.OnInterstitialAdClosed += () => {
                            Debug.Log("Interstitial Ad closed its ad.");
                        };

                        interstitialAd.Show();
                    }
                    else
                    {
                        Debug.Log("Engage disabled the interstitial ad from showing.");
                    }
                }, exception => {
                    Debug.Log("Engage encountered an error: " + exception.Message);
                });
            }

            if (GUI.Button(new Rect(10, 320, 200, 80), "Rewarded Ad"))
            {
                var rewardedAd = RewardedAd.Create();
                if (rewardedAd != null)
                {
                    rewardedAd.Show();
                }
            }

            if (GUI.Button(new Rect(10, 420, 200, 80), "Rewarded with Engage"))
            {
                var engagement = new Engagement("showRewarded");

                DDNA.Instance.RequestEngagement(engagement, response => {
                    var rewardedAd = RewardedAd.Create(response);

                    if (rewardedAd != null)
                    {
                        rewardedAd.OnRewardedAdOpened += () => {
                            Debug.Log("Rewarded Ad opened its ad.");
                        };
                        rewardedAd.OnRewardedAdFailedToOpen += (reason) => {
                            Debug.Log("Rewarded Ad failed to open its ad: " + reason);
                        };
                        rewardedAd.OnRewardedAdClosed += (reward) => {
                            Debug.Log("Rewarded Ad closed its ad with reward: " + (reward ? "YES" : "NO"));
                        };

                        rewardedAd.Show();
                    }
                    else
                    {
                        Debug.Log("Engage disabled the rewarded ad from showing.");
                    }
                }, exception => {
                    Debug.Log("Engage encountered an error: " + exception.Message);
                });
            }

            if (GUI.Button(new Rect(10, 620, 200, 80), "Rewarded or Image"))
            {
                var engagement = new Engagement("showRewardOrImage");
                engagement.AddParam("clickCount", ++clickCount);

                DDNA.Instance.RequestEngagement(engagement, response => {
                    // Since ads must be specifically disabled, try to build image message
                    // first.  If that fails, then see if the ad had been disabled.

                    var imageMessage = ImageMessage.Create(response);
                    var rewardedAd   = RewardedAd.Create(response);

                    if (imageMessage != null)
                    {
                        Debug.Log("Got an image message.");
                        imageMessage.OnDidReceiveResources += () => {
                            imageMessage.Show();
                        };
                        imageMessage.FetchResources();
                    }
                    else if (rewardedAd != null)
                    {
                        rewardedAd.Show();
                    }
                    else
                    {
                        Debug.Log("Engage didn't return an image and prevented the ad from showing.");
                    }
                }, exception => {
                    Debug.Log("Engage encountered an error: " + exception.Message);
                });
            }

            if (GUI.Button(new Rect(10, 820, 200, 80), "New Session"))
            {
                DDNA.Instance.NewSession();
            }
        }