public void Intestinal_Ad_Create()
    {
        InterstitialAd l_interAd = AdmobManager.PrepareInterstitialAd("Interstitial_1");

        l_interAd.AdUnitId = "ca-app-pub-6065714673957825/2806333668";
        l_interAd.Create();
    }
Exemplo n.º 2
0
    void DrawInterstitialAdvs()
    {
        m_rect.x += m_rect.width + 30.0f;
        m_rect.y  = 40;

        m_rect.width  = Screen.width * 0.25f;
        m_rect.height = Screen.height * 0.15f;

        if (GUI.Button(m_rect, "Create Interstitial Ad"))
        {
            InterstitialAd l_interAd = AdmobManager.PrepareInterstitialAd("Interstitial_1");
            //OR
            //InterstitialAd l_interAd = AdmobManager.Prepare<InterstitialAd>("Interstitial_1");
            l_interAd.AdUnitId = "ca-app-pub-4192487455949741/8306159319";
            l_interAd.Create();
        }

        m_rect.y = m_rect.y + m_rect.height;
        if (GUI.Button(m_rect, "Load Interstitial Ad"))
        {
            InterstitialAd l_interAd = AdmobManager.Get <InterstitialAd>("Interstitial_1");
            l_interAd.Load();
        }
        m_rect.y = m_rect.y + m_rect.height;

        if (GUI.Button(m_rect, "Show Interstitial Ad"))
        {
            InterstitialAd l_interAd = AdmobManager.Get <InterstitialAd>("Interstitial_1");
            l_interAd.Show();
        }
    }
    void OnGUI()
    {
        GUI.skin.textField.wordWrap = true;
        GUI.skin.button.fontSize    = 32;

        int xOffset = 0;
        int yOffset = 0;

        int buttonWidth  = 350;
        int buttonHeight = 100;


        if (GUI.Button(new Rect(yOffset += 10, xOffset += 10, buttonWidth, buttonHeight), "Param Engage"))
        {
            Debug.Log("do engage stuff");

            var engagement = new Engagement("startMission")
                             .AddParam("missionID", "tutorial1");

            DDNA.Instance.RequestEngagement(engagement, (System.Collections.Generic.Dictionary <string, object> response) => {
                Debug.Log("engagement");
                foreach (System.Collections.Generic.KeyValuePair <string, object> temp in response)
                {
                    Debug.Log(temp.Key);
                }


                Debug.Log(response.Values.ToString());

                System.Collections.Generic.Dictionary <string, object> parameters = (System.Collections.Generic.Dictionary <string, object>)response["parameters"];
                if (parameters.ContainsKey("isTutorial"))
                {
                    Debug.Log("the parameter: ");
                    if (System.Convert.ToBoolean(parameters["isTutorial"]))
                    {
                        cam.backgroundColor = Color.green;
                    }
                    else
                    {
                        cam.backgroundColor = Color.red;
                    }
                    Debug.Log(parameters["isTutorial"].ToString());
                }
                else
                {
                    Debug.Log("Key not found");
                }
            });
        }
        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Image Engage"))
        {
            var engagement = new Engagement("openMenu");

            DDNA.Instance.RequestEngagement(engagement, (response) => {
                ImageMessage imageMessage = ImageMessage.Create(response);

                // Check is we got an engagement with a valid image message.
                if (imageMessage != null)
                {
                    // Download the image message resources.
                    Debug.Log("Image received");
                    imageMessage.FetchResources();
                    imageMessage.OnDidReceiveResources += () => {
                        Debug.Log("Image Message loaded resources.");
                        imageMessage.Show();
                    };
                }
                else
                {
                    Debug.Log("No image message returned");
                }
            }, (exception) => {
                Debug.Log("Engage reported an error: " + exception.Message);
            });
        }

        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Clear stored data"))
        {
            Debug.Log("User pressed clear all persistent data button");

            DDNA.Instance.ClearPersistentData();
        }

        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Record event"))
        {
            Debug.Log("Record event");

            // Build a game event with a couple of event parameters
            GameEvent optionsEvent = new GameEvent("options")
                                     .AddParam("option", "Music")
                                     .AddParam("Number", (int)1123456789)
                                     .AddParam("action", "Disabled");

            // Record the event
            DDNA.Instance.RecordEvent(optionsEvent);
        }

        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Restart SDK"))
        {
            Debug.Log("User restarts DeltaDNA SDK");
            DDNA.Instance.StopSDK();
            DDNA.Instance.StartSDK(ENVIRONMENT_KEY, COLLECT_URL, ENGAGE_URL);
        }

        if (GUI.Button(new Rect(yOffset = (buttonWidth + 20), xOffset = 10, buttonWidth, buttonHeight), "Start SmartAds"))
        {
            // Register for smartAds
            DDNASmartAds.Instance.RegisterForAds();
        }

        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Show interstitial"))
        {
            var interstitialAd = InterstitialAd.Create();
            if (interstitialAd != null)
            {
                interstitialAd.Show();
            }
        }

        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Show rewarded"))
        {
            var rewardedAd = RewardedAd.Create();
            if (rewardedAd != null)
            {
                rewardedAd.Show();
            }
        }
        if (GUI.Button(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), "Reg for notif."))
        {
            Debug.Log("(re-)register for notifications");

            //Register for ios notifications
            DDNA.Instance.IosNotifications.RegisterForPushNotifications();

            //register for android notifications
            DDNA.Instance.AndroidNotifications.RegisterForPushNotifications();
        }

        GUI.Label(new Rect(yOffset, xOffset += (buttonHeight + 10), buttonWidth, buttonHeight), feedbackText);
    }