Beispiel #1
0
        private static void _Init(object sender = null, EventArgs e = null)
        {
            string oldID = iCloudID;

            object token = null;

            if (NSFileManager.InstancesRespondToSelector("ubiquityIdentityToken"))
            {
                token = NSFileManager.DefaultManager().UbiquityIdentityToken();
            }

            if (token == null)
            {
                iCloudID = null;
                _userDefaults.RemoveObject(ID_KEY);
            }
            else
            {
                NSData data = NSKeyedArchiver.ArchivedData(token);
                iCloudID = Convert.ToBase64String(data.ToByteArray());
                _userDefaults.SetObject(iCloudID, ID_KEY);
            }

            Synchronize();

            if (iCloudID != oldID)
            {
                if (_accountChangedHandlers != null)
                {
                    _accountChangedHandlers(null, EventArgs.Empty);
                }
            }
        }
Beispiel #2
0
        public SiriTrackingEvent[] PopTrackableEvents()
        {
            var eventArrays = getTrackableEvents();

            userDefaults.RemoveObject(SiriTrackingEventsKey);
            return(NSArray.FromArrayNative <SiriTrackingEvent>(eventArrays));
        }
 public void DeleteEverything()
 {
     userDefaults.RemoveObject(ApiTokenKey);
     userDefaults.RemoveObject(NeedsSyncKey);
     userDefaults.RemoveObject(UserIdKey);
     userDefaults.Synchronize();
 }
Beispiel #4
0
		public static void Clear()
		{
			plist.RemoveObject("userName");
			plist.RemoveObject("userId");
			plist.RemoveObject("email");
			plist.RemoveObject("CardNumber");
			plist.RemoveObject("GuestId");
		}
Beispiel #5
0
        public static void ResetAllUserDefaults()
        {
            NSUserDefaults userDefaults = NSUserDefaults.StandardUserDefaults;

            userDefaults.RemoveObject(strings.defaultsServerNameHestia);
            userDefaults.RemoveObject(strings.defaultsIpHestia);
            userDefaults.RemoveObject(strings.defaultsPortHestia);
            userDefaults.RemoveObject(strings.defaultsLocalHestia);
            userDefaults.RemoveObject(strings.defaultsAccessTokenHestia);
        }
Beispiel #6
0
        protected override void RemoveNative(IEnumerable <KeyValuePair <string, string> > dels)
        {
            foreach (var item in dels)
            {
                if (this.CanTouch(item.Key))
                {
                    prefs.RemoveObject(item.Key);
                }
            }

            prefs.Synchronize();
        }
        private bool DoRemove(string key)
        {
            if (IsRoaming)
            {
                _store.Remove(key);
            }
            else
            {
                _defaults.RemoveObject(key);
            }

            return(true);
        }
        private void DeleteFromUserDefault(String key)
        {
            var userDefault = new NSUserDefaults();

            userDefault.RemoveObject(key);
            userDefault.Synchronize();
        }
        public override void DeleteData(string dataId)
        {
            NSUserDefaults prefs = NSUserDefaults.StandardUserDefaults;

            prefs.RemoveObject(new NSString(dataId));
            prefs.Synchronize();
        }
        private bool DoRemove(string key)
        {
            if (IsRoaming)
            {
                _store.Remove(key);
            }
            else
            {
                _defaults.RemoveObject(key);
                if (_locality == ApplicationDataLocality.SharedLocal)
                {
                    _defaults.Synchronize();
                }
            }

            return(true);
        }
Beispiel #11
0
        ///// <summary>
        ///// Deletes local database.
        ///// </summary>
        //public void Delete()
        //{
        //    NSUserDefaults.StandardUserDefaults.RemoveObject(_localDbName);
        //    string appDomain = NSBundle.MainBundle.BundleIdentifier;
        //    _userDefaults.RemovePersistentDomain(appDomain);
        //}

        // <summary>
        /// Deletes value by key local database.
        /// </summary>
        public override void Delete(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            _userDefaults.RemoveObject(key);
        }
Beispiel #12
0
        private void RemovePublicationDownloadingProgress()
        {
            if (BookInfo.Name == null)
            {
                return;
            }

            NSUserDefaults userDefault = NSUserDefaults.StandardUserDefaults;

            userDefault.RemoveObject(BookInfo.Name);
            userDefault.Synchronize();
        }
Beispiel #13
0
 /// <inheritdoc />
 public void SetString(string key, string value)
 {
     if (value == null)
     {
         _standardDefaults.RemoveObject(key);
     }
     else
     {
         _standardDefaults.SetString(value, key);
     }
     _standardDefaults.Synchronize();
 }
Beispiel #14
0
 public static void SetStringOrClear(this NSUserDefaults instance, string data, string defaultName)
 {
     if (data.HasValue())
     {
         instance.SetString(data, defaultName);
     }
     else
     {
         instance.RemoveObject(defaultName);
     }
     instance.Synchronize();
 }
        public void SetString()
        {
            // confusing API for .NET developers since the parameters are 'value', 'key'
            // http://stackoverflow.com/q/12415054/220643
            NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults;

            defaults.RemoveObject("spid");
            Assert.Null(defaults.StringForKey("spid"), "StringForKey-1");
            defaults.SetString("coucou", "spid");
            defaults.Synchronize();
            Assert.That(defaults.StringForKey("spid"), Is.EqualTo("coucou"), "StringForKey-2");
        }
Beispiel #16
0
 public static void SetSerializedObject <T> (this NSUserDefaults instance, T data, string defaultName) where T : class
 {
     if (data != null)
     {
         instance.SetString(data.Serialize(), defaultName);
     }
     else
     {
         instance.RemoveObject(defaultName);
     }
     instance.Synchronize();
 }
Beispiel #17
0
 /// <summary>
 /// Logout the user and clear nsdefaults values
 /// </summary>
 public static void UserLogout()
 {
     try
     {
         _user.RemoveObject("USER_ID");
         _user.RemoveObject("USER_TYPE");
         _user.RemoveObject("USER_NAME");
         _user.RemoveObject("SURNAME");
         _user.RemoveObject("EMAIL");
         _user.RemoveObject("MOBILE");
         _user.RemoveObject("API_TOKEN");
         _user.RemoveObject("HELPLINE");
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
        public void Ctor_UserName()
        {
            // initWithUser:
            using (var ud = new NSUserDefaults("username")) {
                Assert.That(ud.RetainCount, Is.EqualTo((nint)1), "RetainCount");
                ud.SetString("value", "key");
                ud.Synchronize();
            }

            using (var ud = new NSUserDefaults("username", NSUserDefaultsType.UserName)) {
                Assert.That(ud.RetainCount, Is.EqualTo((nint)1), "RetainCount");
                Assert.That(ud ["key"].ToString(), Is.EqualTo("value"), "[key]-1");
                ud.RemoveObject("key");
                ud.Synchronize();
                Assert.Null(ud ["key"], "[key]-2");
            }
        }
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            var defs = new NSUserDefaults("group.com.xamarin.todaysharing", NSUserDefaultsType.SuiteName);

            if (defs.ValueForKey(new NSString("key")) != null)
            {
                defs.RemoveObject("key");
                View.BackgroundColor = UIColor.DarkGray;
            }
            else
            {
                defs.SetValueForKey(new NSString("value"), new NSString("key"));
                View.BackgroundColor = UIColor.Green;
            }
            defs.Synchronize();
        }
Beispiel #20
0
        public void StoreUbiquityIdentityToken()
        {
            NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults;
            var            token    = NSFileManager.DefaultManager.UbiquityIdentityToken;

            if (token != null)
            {
                // the account has changed
                NSData ubiquityIdentityTokenArchive = NSKeyedArchiver.ArchivedDataWithRootObject(token);
                defaults [StoredUbiquityIdentityTokenKey] = ubiquityIdentityTokenArchive;
            }
            else
            {
                // the is no signed-in account
                defaults.RemoveObject(StoredUbiquityIdentityTokenKey);
            }

            defaults.Synchronize();
        }
 public void Set(string key, object value)
 {
     if (value == null)
     {
         Defaults.RemoveObject(key);
     }
     else if (value is int)
     {
         Defaults.SetInt((int)value, key);
     }
     else if (value is bool)
     {
         Defaults.SetBool((bool)value, key);
     }
     else if (value is string)
     {
         Defaults.SetString((string)value, key);
     }
     Defaults.Synchronize();
 }
Beispiel #22
0
        public bool DeleteValue(string key)
        {
            bool result = false;

            System.Diagnostics.Debug.WriteLine(">>> DeleteValue, key = " + key);

            try
            {
                localSettings.RemoveObject(key);
                localSettings.Synchronize();
                result = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(">>> DeleteValue failed, exception:" + ex.ToString());
                result = false;
            }

            System.Diagnostics.Debug.WriteLine(">>> result = " + result.ToString());
            return(result);
        }
Beispiel #23
0
        void UpdateDownloadProgress(int bytesDownloaded, long downloadSize)
        {
            float curProgress = (float)(bytesDownloaded / 100.0);

            ProgressBar.DoubleValue = curProgress;

            if ((bytesDownloaded - bytesPreDownloaded) > 2)
            {
                bytesPreDownloaded = bytesDownloaded;

                NSUserDefaults userDefault = NSUserDefaults.StandardUserDefaults;
                userDefault.SetInt(bytesDownloaded, BookInfo.Name);
                userDefault.Synchronize();
            }

            if (bytesDownloaded == 100)
            {
                NSUserDefaults userDefault = NSUserDefaults.StandardUserDefaults;
                userDefault.RemoveObject(BookInfo.Name);
                userDefault.Synchronize();
            }
        }
Beispiel #24
0
 public override void RemoveValue(string key)
 {
     defaults.RemoveObject(Prefix + key);
     defaults.Synchronize();
 }
Beispiel #25
0
 public void Remove(string key)
 {
     nsUserDefaults.RemoveObject(key);
 }
 public void Clear(string key)
 {
     Defaults.RemoveObject(key);
     Defaults.Synchronize();
 }
Beispiel #27
0
 public void Remove(string nameSpace, string key)
 {
     userDefaults = GetUserDefaults(nameSpace);
     userDefaults.RemoveObject(key);
 }
Beispiel #28
0
 protected override void Remove(string key)
 {
     _userDefaults.RemoveObject(key);
 }
Beispiel #29
0
 protected override void doRemoveValue(string key)
 {
     userDefaults.RemoveObject(key);
     userDefaults.Synchronize();
 }