コード例 #1
0
        public void FlushEvents()
        {
            string qaEventsStringJson = null;

            lock (qaLogEventQueued) {
                if (qaLogEventQueued.Count > 0)
                {
                    qaEventsStringJson = SwrveUnityMiniJSON.Json.Serialize(this.qaLogEventQueued);
                    SwrveLog.LogInfo("Swrve: will flush the QA queue, total of " + qaLogEventQueued.Count + "events");
                    qaLogEventQueued.Clear();
                }
            }
            MakeRequest(qaEventsStringJson);
        }
コード例 #2
0
        private void MakeRequest(string qaEventsStringJson)
        {
            if (qaEventsStringJson == null)
            {
                return;
            }

            byte[] qaPostEncodedData = null;
            qaPostEncodedData = PostBodyBuilder.BuildQaEvent(apiKey, appId, userId, this.deviceUUID, appVersion, SwrveHelper.GetMilliseconds(), qaEventsStringJson);

            Dictionary <string, string> requestHeaders = new Dictionary <string, string> {
                { @"Content-Type", @"application/json; charset=utf-8" }
            };

            if (qaPostEncodedData != null)
            {
                container.StartCoroutine(restClient.Post(endPoint, qaPostEncodedData, requestHeaders, RestListener));
                SwrveLog.LogInfo("Swrve: SwrveQa Json Event sent:" + qaEventsStringJson);
            }
        }
コード例 #3
0
        public static void Update(Dictionary <string, object> qaUserDictionary)
        {
            if (qaUserDictionary == null)
            {
                SwrveQaUser.Instance.loggingEnabled = false;
                SwrveQaUser.Instance.resetDevice    = false;
            }
            else
            {
                if (qaUserDictionary.ContainsKey("logging"))
                {
                    SwrveQaUser.Instance.loggingEnabled = (bool)qaUserDictionary["logging"];

                    if (SwrveQaUser.Instance.loggingEnabled)
                    {
                        SwrveLog.LogInfo("Swrve: user just updated as QaUser!");
                    }
                }
                if (qaUserDictionary.ContainsKey("reset_device_state"))
                {
                    SwrveQaUser.Instance.resetDevice = (bool)qaUserDictionary["reset_device_state"];
                }
            }
        }
コード例 #4
0
 public static void LogInfo(object message)
 {
     SwrveLog.LogInfo(message, "activity");
 }
コード例 #5
0
    private void InitialisePushADM(MonoBehaviour container)
    {
        try {
            bool registered = false;
            this.admDeviceToken = storage.Load(AdmDeviceTokenSave);

            //Only execute this once
            if (!androidADMPluginInitialized)
            {
                androidADMPluginInitialized = true;

                string pluginPackageName = SwrveAndroidADMPushPluginPackageName;

                string jniPluginClassName = pluginPackageName.Replace(".", "/");
                if (AndroidJNI.FindClass(jniPluginClassName).ToInt32() == 0)
                {
                    SwrveLog.LogError("Could not find class: " + jniPluginClassName +
                                      " Are you using the correct SwrveSDKPushSupport plugin given the swrve config.AndroidPushProvider setting?");

                    //Force crash by calling another JNI call without clearing exceptions.
                    //This is to enforce proper integration
                    AndroidJNI.FindClass(jniPluginClassName);
                    return;
                }

                androidADMPlugin = new AndroidJavaClass(pluginPackageName);
                if (androidADMPlugin == null)
                {
                    SwrveLog.LogError("Found class, but unable to construct AndroidJavaClass: " + jniPluginClassName);
                    return;
                }

                // Check that the plugin version is correct
                int pluginVersion = androidADMPlugin.CallStatic <int>(GetVersionName);
                if (pluginVersion != AdmPushPluginVersion)
                {
                    // Plugin with changes to the public API not supported
                    androidADMPlugin = null;
                    throw new Exception("The version of the Swrve Android Push plugin" + pluginPackageName + "is different. This Swrve SDK needs version " + pluginVersion);
                }
                else
                {
                    androidADMPluginInitializedSuccessfully = true;
                    SwrveLog.LogInfo("Android Push Plugin initialised successfully: " + jniPluginClassName);
                }
            }

            if (androidADMPluginInitializedSuccessfully)
            {
                registered = androidADMPlugin.CallStatic <bool>(
                    InitialiseAdmName, container.name, config.AndroidPushNotificationIconId, config.AndroidPushNotificationMaterialIconId,
                    config.AndroidPushNotificationLargeIconId, config.AndroidPushNotificationAccentColorHex);
            }

            if (!registered)
            {
                SwrveLog.LogError("Could not communicate with the Swrve Android ADM Push plugin.");
            }
        } catch (Exception exp) {
            SwrveLog.LogError("Could not initalise push: " + exp.ToString());
        }
    }