示例#1
0
 public void Start_TrackingTest()
 {
     MessagingCenter.Subscribe <StartBackgroundLocationTracking>(this, "StartBackgroundLocationTracking", message =>
     {
         Assert.IsTrue(BackgroundLocationService.isTracking());
     });
     BackgroundLocationService.Start_Tracking();
 }
        /// <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");
            }
        }
示例#3
0
        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;
            }
        }