예제 #1
0
 // Enables the developer mode,
 // in which the number of times that the app fetches data from Remote
 // Configuration is not limited, and traffic control is still performed over the cloud.
 public void SetDeveloperMode()
 {
     config       = AGConnectConfig.getInstance();
     develporMode = !develporMode;
     config.setDeveloperMode(develporMode);
     TestTip.Inst.ShowText($"set developer mode to {develporMode}");
 }
예제 #2
0
 //getInstance() Obtains an instance of AGConnectConfig.
 public void GetInstance()
 {
     if (agc == null)
     {
         agc = AGConnectConfig.GetInstance();
     }
     Debug.Log($"[{TAG}]: GetInstance() {agc}");
 }
예제 #3
0
        public void SetXmlValue()
        {
            // get instatance of AGConnectConfig
            config = AGConnectConfig.getInstance();
            // get config resId of xml file
            int configId = AndroidUtil.GetId(new Context(), "xml", "remote_config");

            // Sets a default value for a parameter.
            config.applyDefault(configId);
            showAllValues();
        }
예제 #4
0
        // get all configs, print key and the source of a key.
        private void GetAllValueWithSource()
        {
            config = AGConnectConfig.getInstance();
            Map map      = config.getMergedAll();
            var keySet   = map.keySet();
            var keyArray = keySet.toArray();

            foreach (var key in keyArray)
            {
                TestTip.Inst.ShowText($"{key}: {config.getSource(key)}");
            }
        }
예제 #5
0
        // get all configs, print key and value pair
        private void showAllValues()
        {
            config = AGConnectConfig.getInstance();
            Map map      = config.getMergedAll();
            var keySet   = map.keySet();
            var keyArray = keySet.toArray();

            foreach (var key in keyArray)
            {
                TestTip.Inst.ShowText($"{key}: {map.getOrDefault(key, "default")}");
            }
        }
예제 #6
0
        public void SetMapValue()
        {
            config = AGConnectConfig.getInstance();
            HashMap map = new HashMap();

            map.put("test2", "true");
            map.put("test3", 222);
            map.put("test4", 666.456);
            map.put("test5", "fromMap");
            // Sets a default value for a parameter.
            config.applyDefault(map.toType <Map>());
            showAllValues();
        }
예제 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            FetchApplyButton         = FindViewById <Button>(Resource.Id.FetchApply);
            FetchSaveButton          = FindViewById <Button>(Resource.Id.FetchSave);
            ClearButton              = FindViewById <Button>(Resource.Id.Clear);
            DeveloperMode            = FindViewById <Switch>(Resource.Id.DeveloperMode);
            ResultLog                = (TextView)FindViewById(Resource.Id.log_info);
            ResultLog.MovementMethod = ScrollingMovementMethod.Instance;

            //Set User attributes defined in AGConnect Console
            instance = HiAnalytics.GetInstance(this);
            instance.SetUserProfile("favorite_color", "Black");
            instance.SetUserProfile("favorite_food", "banana");

            AGCRemoteConfig = AGConnectConfig.Instance;

            if (AGCRemoteConfig != null)
            {
                Log.Info("RC", "AGConnectConfig instance cratead successfully.");
            }

            FetchApplyButton.Click += delegate { FetchApply(); };
            FetchSaveButton.Click  += delegate { LoadLastFetchedConfig(); };
            ClearButton.Click      += delegate {
                AGCRemoteConfig.ClearAll();
                Logger("All Values Cleared", TAG);
                ApplyDefualtByMap();
                ShowAllValues();
            };

            DeveloperMode.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
            {
                AGCRemoteConfig.SetDeveloperMode(e.IsChecked);
                if (e.IsChecked)
                {
                    Toast.MakeText(this, "DeveloperMode Enabled", ToastLength.Long).Show();
                }
                else
                {
                    Toast.MakeText(this, "DeveloperMode Disabled", ToastLength.Long).Show();
                }
            };

            ApplyDefualtByFile();
            ShowAllValues();
            GetToken();
        }
예제 #8
0
 // Fetches latest parameter values from the cloud at a custom interval.
 // If the method is called within an interval, cached data is returned.
 public void GetCloudSettingsFiveMins()
 {
     config = AGConnectConfig.getInstance();
     config.fetch(300).addOnSuccessListener(new HmsSuccessListener <ConfigValues>((ConfigValues configValues) =>
     {
         config.apply(configValues);
         TestTip.Inst.ShowText("activity success");
     }))
     .addOnFailureListener(new HmsFailureListener((Exception e) =>
     {
         TestTip.Inst.ShowText("activity failure " + e.toString());
     }));
     showAllValues();
 }
예제 #9
0
        // apply the config value laste fetched
        public void GetCloudSettingsWorkNextTime()
        {
            config = AGConnectConfig.getInstance();
            ConfigValues configValues = config.loadLastFetched();

            config.apply(configValues);
            config.fetch().addOnSuccessListener(new HmsSuccessListener <ConfigValues>((ConfigValues o) =>
            {
                TestTip.Inst.ShowText("activity success");
            }))
            .addOnFailureListener(new HmsFailureListener((Exception e) =>
            {
                TestTip.Inst.ShowText("activity failure " + e.toString());
            }));
            showAllValues();
        }
예제 #10
0
        // fetch cloud setting, add success listener and failure listener
        public void GetCloudSettings()
        {
            config = AGConnectConfig.getInstance();
            config.fetch().addOnSuccessListener(new HmsSuccessListener <ConfigValues>((ConfigValues configValues) =>
            {
                // Applies parameter values
                config.apply(configValues);
                TestTip.Inst.ShowText("activity success");
                // Checks whether the ConfigValues object contains a requested key.
                TestTip.Inst.ShowText($"configValues contains {configValues.containKey("CloudBool")}");
                // Returns the value of type for a key.
                TestTip.Inst.ShowText($"configValues as string {configValues.getValueAsString("CloudString")}");
                TestTip.Inst.ShowText($"configValues as byte first byte {configValues.getValueAsByteArray("CloudByte")[0]}");
                TestTip.Inst.ShowText($"configValues as long {configValues.getValueAsLong("CloudLong").longValue()}");
                TestTip.Inst.ShowText($"configValues as double {configValues.getValueAsDouble("CloudDouble").doubleValue()}");
                TestTip.Inst.ShowText($"configValues as bool {configValues.getValueAsBoolean("CloudBool").booleanValue()}");

                showAllValues();
            }))
            .addOnFailureListener(new HmsFailureListener((Exception e) =>
            {
                TestTip.Inst.ShowText("activity failure " + e.toString());
            }));
        }
예제 #11
0
 // Clears all cached data,
 // including the data fetched from Remote Configuration and the default values passed.
 public void ClearCache()
 {
     config = AGConnectConfig.getInstance();
     config.clearAll();
     TestTip.Inst.ShowText("Cache is cleared.");
 }