Example #1
0
        public void GetNativeEventSuccess(string eventSuccessData)
        {
            if (IsEditor())
            {
                return;
            }

            if (AdTrace.eventSuccessDelegate == null)
            {
                Debug.Log("AdTrace: Event success delegate was not set.");
                return;
            }

            var eventSuccess = new AdTraceEventSuccess(eventSuccessData);

            AdTrace.eventSuccessDelegate(eventSuccess);
        }
            // Method must be lowercase to match Android method signature.
            public void onFinishedEventTrackingSucceeded(AndroidJavaObject eventSuccessData)
            {
                if (callback == null)
                {
                    return;
                }
                if (eventSuccessData == null)
                {
                    return;
                }

                AdTraceEventSuccess adtraceEventSuccess = new AdTraceEventSuccess();

                adtraceEventSuccess.Adid = eventSuccessData.Get <string>(AdTraceUtils.KeyAdid) == "" ?
                                           null : eventSuccessData.Get <string>(AdTraceUtils.KeyAdid);
                adtraceEventSuccess.Message = eventSuccessData.Get <string>(AdTraceUtils.KeyMessage) == "" ?
                                              null : eventSuccessData.Get <string>(AdTraceUtils.KeyMessage);
                adtraceEventSuccess.Timestamp = eventSuccessData.Get <string>(AdTraceUtils.KeyTimestamp) == "" ?
                                                null : eventSuccessData.Get <string>(AdTraceUtils.KeyTimestamp);
                adtraceEventSuccess.EventToken = eventSuccessData.Get <string>(AdTraceUtils.KeyEventToken) == "" ?
                                                 null : eventSuccessData.Get <string>(AdTraceUtils.KeyEventToken);
                adtraceEventSuccess.CallbackId = eventSuccessData.Get <string>(AdTraceUtils.KeyCallbackId) == "" ?
                                                 null : eventSuccessData.Get <string>(AdTraceUtils.KeyCallbackId);

                try
                {
                    AndroidJavaObject ajoJsonResponse    = eventSuccessData.Get <AndroidJavaObject>(AdTraceUtils.KeyJsonResponse);
                    string            jsonResponseString = ajoJsonResponse.Call <string>("toString");
                    adtraceEventSuccess.BuildJsonResponseFromString(jsonResponseString);
                }
                catch (Exception)
                {
                    // JSON response reading failed.
                    // Native Android SDK should send empty JSON object if none available as of v4.12.5.
                    // Native Android SDK added special logic to send Unity friendly values as of v4.15.0.
                }

                callback(adtraceEventSuccess);
            }