bool RatingConditionsHaveBeenMet() { //if (settings.Debug) // return true; NSUserDefaults userDefaults = NSUserDefaults.StandardUserDefaults; DateTime dateOfFirstLaunch = DateTime.FromOADate(userDefaults.DoubleForKey(FIRST_USE_DATE)); TimeSpan timeSinceFirstLaunch = DateTime.Now.Subtract(dateOfFirstLaunch); TimeSpan timeUntilRate = new TimeSpan(settings.DaysUntilPrompt, 0, 0, 0); if (timeSinceFirstLaunch < timeUntilRate) { return(false); } // check if the app has been used enough int useCount = userDefaults.IntForKey(USE_COUNT); if (useCount < settings.UsesUntiPrompt) { return(false); } // check if the user has done enough significant events int sigEventCount = userDefaults.IntForKey(SIGNIFICANT_EVENT_COUNT); if (sigEventCount < settings.SigEventsUntilPrompt) { return(false); } // has the user previously declined to rate this version of the app? if (userDefaults.BoolForKey(DECLINED_TO_RATE)) { return(false); } // has the user already rated the app? if (userDefaults.BoolForKey(RATED_CURRENT_VERSION)) { return(false); } // if the user wanted to be reminded later, has enough time passed? DateTime reminderRequestDate = DateTime.FromOADate(userDefaults.DoubleForKey(REMINDER_REQUEST_DATE)); TimeSpan timeSinceReminderRequest = DateTime.Now.Subtract(reminderRequestDate); TimeSpan timeUntilReminder = new TimeSpan(settings.TimeBeforeReminding, 0, 0, 0); if (timeSinceReminderRequest < timeUntilReminder) { return(false); } return(true); }
public override void ViewDidLoad() { base.ViewDidLoad(); _plist = NSUserDefaults.StandardUserDefaults; var startDateEpoch = _plist.DoubleForKey("startDate"); var endDateEpoch = _plist.DoubleForKey("endDate"); if (startDateEpoch > 0.0 && endDateEpoch > 0.0) { _startTime = startDateEpoch.FromUnixTime(); _endTime = endDateEpoch.FromUnixTime(); } else { _startTime = DateTime.Now.AddDays(-7); _endTime = DateTime.Now.AddDays(2); } timeLabel.Text = $"{_startTime.ToShortDateString()}-{_endTime.ToShortDateString()}"; InitializeActivityIndicator(); TableSource.ViewController = this; menuButton.Clicked += (sender, e) => this.RevealViewController().RevealToggleAnimated(true); View.AddGestureRecognizer(this.RevealViewController().PanGestureRecognizer); var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate; ActiveStation = appDelegate.ActiveStation; tableView.Source = TableSource; locationManager.AuthorizationChanged += (sender, args) => { Console.WriteLine("Authorization changed to: {0}", args.Status); }; locationManager.RequestWhenInUseAuthorization(); GetAnnotationOfStation(); if (ActiveStation != null) { WeatherInformation.GetWeatherData(double.Parse(ActiveStation.Latitude), double.Parse(ActiveStation.Longitude), (WeatherData data) => { data.IconName = data.GetWeatherIcon(data.Condition); InvokeOnMainThread(() => { UpdateUIWeatherInformation(data); }); }); // GetWeatherData(double.Parse(ActiveStation.Latitude), double.Parse(ActiveStation.Longitude)); } InitializeDatabase(); }
public object GetValue(Type valueType, string key) { object value = null; if (valueType == typeof(string)) { value = UserDefaults.StringForKey(key); } else if (valueType == typeof(int)) { value = UserDefaults.IntForKey(key); } else if (valueType == typeof(bool)) { value = UserDefaults.BoolForKey(key); } else if (valueType == typeof(float)) { value = UserDefaults.FloatForKey(key); } else if (valueType == typeof(double)) { value = UserDefaults.DoubleForKey(key); } else if (valueType == typeof(long)) { value = (long)((NSNumber)UserDefaults.ValueForKey(new NSString(key))); } else { Log.Error(INCORRECT_VALUE_TYPE_ERROR); } return(value); }
public static double DoubleForKey(this NSUserDefaults defaults, double defaultValue, string key) { if (defaults.ValueForKey(new NSString(key)) == null) { return(defaultValue); } return(defaults.DoubleForKey(key)); }
void LePreferencias() { txtNome.Text = prefs.StringForKey("user"); boolSwitch.SetState(prefs.BoolForKey("habilitado"), true); floatSlider.Value = prefs.FloatForKey("slider"); lblInt.Text = prefs.IntForKey("int").ToString(); intStepper.Value = prefs.IntForKey("int"); dtPicker.Date = NSDate.FromTimeIntervalSince1970(prefs.DoubleForKey("data")); }
static public double GetDoubleSetting(string name, double defValue = 0) { double res = g_prefs.DoubleForKey(name); if (res == 0.0 && defValue != 0.0) { res = defValue; } return(res); }
public long GetLong(string key) { try { return((long)_defaults.DoubleForKey(key)); } catch (Exception e) { Logger.Error($"Error Getting Long UserSetting {key} - {e.Message}", e); } return(0); }
void IncrementSignificantEventCount() { // get the app's version string version = CurrentVersion; // get the version number that we've been tracking NSUserDefaults userDefaults = NSUserDefaults.StandardUserDefaults; string trackingVersion = userDefaults.StringForKey(CURRENT_VERSION); if (string.IsNullOrEmpty(trackingVersion)) { trackingVersion = version; userDefaults.SetString(version, CURRENT_VERSION); } if (settings.Debug) { Debug.WriteLine("APPIRATER Tracking version: {0}", trackingVersion); } if (trackingVersion == version) { // check if the first use date has been set. if not, set it. double timeInterval = userDefaults.DoubleForKey(FIRST_USE_DATE); if (timeInterval == 0) { timeInterval = DateTime.Now.ToOADate(); userDefaults.SetDouble(timeInterval, FIRST_USE_DATE); } // increment the significant event count int sigEventCount = userDefaults.IntForKey(SIGNIFICANT_EVENT_COUNT); sigEventCount++; userDefaults.SetInt(sigEventCount, SIGNIFICANT_EVENT_COUNT); if (settings.Debug) { Debug.WriteLine("APPIRATER Significant event count: {0}", sigEventCount); } } else { Restart(); } userDefaults.Synchronize(); }
public double GetUserId() => userDefaults.DoubleForKey(UserIdKey);
public double GetDouble(string key) { return(_prefs.DoubleForKey(key)); }
/// <inheritdoc /> public double GetDouble(string key, double defaultValue) { return(_standardDefaults.DoubleForKey(defaultValue, key)); }