Пример #1
0
        /// <summary>
        /// Requests a rewarded ad at a <code>decisionPoint</code>.
        /// </summary>
        /// <param name="decisionPoint">the decision point</param>
        /// <param name="parameters">an optional set of real-time parameters</param>
        /// <param name="callback">the callback to handle the result</param>
        public void RequestRewardedAd(string decisionPoint, Params parameters, Action <RewardedAd> callback)
        {
            if (smartads != null)
            {
                Engagement engagement = BuildEngagement(decisionPoint, parameters)
                                        .AddParam("ddnaAdSessionCount", smartads.GetSessionCount(decisionPoint))
                                        .AddParam("ddnaAdDailyCount", smartads.GetDailyCount(decisionPoint));

                if (smartads.GetLastShown(decisionPoint).HasValue)
                {
                    engagement.AddParam("ddnaAdLastShownTime", smartads.GetLastShown(decisionPoint).Value);
                }

                ddna.RequestEngagement(engagement,
                                       (response) =>
                {
                    Logger.LogDebug("Creating a rewarded ad at '" + decisionPoint + "'");
                    callback(RewardedAd.CreateUnchecked(response));
                }, (exception) =>
                {
                    Logger.LogWarning("Creating rewarded ad despite failed Engage request");
                    callback(RewardedAd.CreateUnchecked(engagement));
                });
            }
        }
Пример #2
0
        public void RequestImageMessage(string decisionPoint, Dictionary <string, object> engageParams, IPopup popup, Action <Dictionary <string, object> > callback)
        {
            var engagement = new Engagement(decisionPoint);

            foreach (var key in engageParams.Keys)
            {
                engagement.AddParam(key, engageParams[key]);
            }
            RequestImageMessage(engagement, popup, callback);
        }
Пример #3
0
        public void CreateAValidEngagementWithExtraParameters()
        {
            var engagement = new Engagement("testDecisionPoint");

            engagement.AddParam("A", 1);
            engagement.AddParam("B", "two");
            engagement.AddParam("C", true);

            Assert.AreEqual("testDecisionPoint", engagement.DecisionPoint);
            Assert.AreEqual("engagement", engagement.Flavour);
            CollectionAssert.AreEquivalent(new Dictionary <string, object>()
            {
                { "decisionPoint", "testDecisionPoint" },
                { "flavour", "engagement" },
                { "parameters", new Dictionary <string, object>()
                  {
                      { "A", 1 },
                      { "B", "two" },
                      { "C", true }
                  } }
            }, engagement.AsDictionary());
        }
Пример #4
0
        override internal void RequestSessionConfiguration()
        {
            Logger.LogDebug("Requesting session configuration");

            var firstSession = PlayerPrefs.HasKey(DDNA.PF_KEY_FIRST_SESSION)
                ? DateTime.ParseExact(
                PlayerPrefs.GetString(DDNA.PF_KEY_FIRST_SESSION),
                Settings.EVENT_TIMESTAMP_FORMAT,
                CultureInfo.InvariantCulture)
                : (DateTime?)null;
            var lastSession = PlayerPrefs.HasKey(DDNA.PF_KEY_LAST_SESSION)
                ? DateTime.ParseExact(
                PlayerPrefs.GetString(DDNA.PF_KEY_LAST_SESSION),
                Settings.EVENT_TIMESTAMP_FORMAT,
                CultureInfo.InvariantCulture)
                : (DateTime?)null;

            Engagement engagement = new Engagement("config")
            {
                Flavour = "internal"
            };

            engagement.AddParam("timeSinceFirstSession", firstSession != null
                         ? ((TimeSpan)(DateTime.UtcNow - firstSession)).TotalMilliseconds
                         : 0);
            engagement.AddParam("timeSinceLastSession", lastSession != null
                         ? ((TimeSpan)(DateTime.UtcNow - lastSession)).TotalMilliseconds
                         : 0);


            if (!String.IsNullOrEmpty(ClientInfo.LanguageCode))
            {
                engagement.AddParam("language", ClientInfo.LanguageCode);
            }

            if (!String.IsNullOrEmpty(ClientInfo.CountryCode))
            {
                engagement.AddParam("country", ClientInfo.CountryCode);
            }

            if (!String.IsNullOrEmpty(ClientInfo.OperatingSystemVersion))
            {
                engagement.AddParam("operatingSystemVersion", ClientInfo.OperatingSystemVersion);
            }

            if (!String.IsNullOrEmpty(ClientInfo.Manufacturer))
            {
                engagement.AddParam("deviceManufacturer", ClientInfo.Manufacturer);
            }

            RequestEngagement(engagement, HandleSessionConfigurationCallback);
        }
Пример #5
0
        override internal void RequestSessionConfiguration()
        {
            Logger.LogDebug("Requesting session configuration");

            DateTime?firstSession = RetrieveSessionDate(DDNA.PF_KEY_FIRST_SESSION);
            DateTime?lastSession  = RetrieveSessionDate(DDNA.PF_KEY_LAST_SESSION);

            Engagement engagement = new Engagement("config")
            {
                Flavour = "internal"
            };

            engagement.AddParam("timeSinceFirstSession", firstSession != null
                         ? ((TimeSpan)(DateTime.UtcNow - firstSession)).TotalMilliseconds
                         : 0);
            engagement.AddParam("timeSinceLastSession", lastSession != null
                         ? ((TimeSpan)(DateTime.UtcNow - lastSession)).TotalMilliseconds
                         : 0);


            if (!String.IsNullOrEmpty(ClientInfo.LanguageCode))
            {
                engagement.AddParam("language", ClientInfo.LanguageCode);
            }

            if (!String.IsNullOrEmpty(ClientInfo.CountryCode))
            {
                engagement.AddParam("country", ClientInfo.CountryCode);
            }

            if (!String.IsNullOrEmpty(ClientInfo.OperatingSystemVersion))
            {
                engagement.AddParam("operatingSystemVersion", ClientInfo.OperatingSystemVersion);
            }

            if (!String.IsNullOrEmpty(ClientInfo.Manufacturer))
            {
                engagement.AddParam("deviceManufacturer", ClientInfo.Manufacturer);
            }

            RequestEngagement(engagement, HandleSessionConfigurationCallback);
        }