/// <summary> /// Function to toggle Asynchronous location, when off /// </summary> /// <param name="sender">Sender Object</param> /// <param name="e">Toggled Event Arguments</param> /// async void OnToggledAsync(object sender, ToggledEventArgs e) { IBackgroundLocationService backgroundLocationService = App.IoCContainer.GetInstance <IBackgroundLocationService>(); if (e.Value == true) { //BackgroundLocaitonService.Tracking = true; //backgroundLocationService.Start_Tracking(); } else { //BackgroundLocaitonService.Tracking = false; //backgroundLocationService.Stop_Tracking(); //await DisplayAlert("Attention", "Disabled", "OK"); } }
/// <summary> /// Enabels and disables location tracking /// </summary> async void SfSwitch_StateChanged(System.Object sender, Syncfusion.XForms.Buttons.SwitchStateChangedEventArgs e) { IBackgroundLocationService back = App.IoCContainer.GetInstance <IBackgroundLocationService>(); if (e.NewValue == true) { //BackgroundLocaitonService.Tracking = true; back.Start_Tracking(); CrossSecureStorage.Current.SetValue("Location", "true"); CrossToastPopUp.Current.ShowToastMessage("Location Tracking Enabled"); } else { //BackgroundLocaitonService.Tracking = false; back.Stop_Tracking(); //await DisplayAlert("Attention", "Disabled", "OK"); CrossToastPopUp.Current.ShowToastMessage("Location Tracking Disabled"); CrossSecureStorage.Current.SetValue("Location", "false"); } }
private void LoadPersistentValues() { if (Current.Properties.ContainsKey("Tracking")) { IBackgroundLocationService backgroundLocationService = IoCContainer.GetInstance <IBackgroundLocationService>(); var value = (bool)Current.Properties["Tracking"]; BackgroundLocationService.Tracking = value; if (value) { backgroundLocationService.Start_Tracking(); } } if (Current.Properties.ContainsKey("CarrierStatus")) { // Use Carrier status User.carrierStatus = Current.Properties["CarrierStatus"].ToString() == "Positive"; } else { User.carrierStatus = false; } }