//This will keep going in the background and the foreground
 public void PrintLocation(object sender, LocationUpdatedEventArgs e)
 {
     /*
      * CLLocation location = e.Location;
      * Console.WriteLine("Altitude: " + location.Altitude + " meters");
      * Console.WriteLine("Longitude: " + location.Coordinate.Longitude);
      * Console.WriteLine("Latitude: " + location.Coordinate.Latitude);
      * Console.WriteLine("Course: " + location.Course);
      * Console.WriteLine("Speed: " + location.Speed);
      */
 }
Esempio n. 2
0
        public static void HandleLocationChanged(object sender, LocationUpdatedEventArgs e)
        {
            // Handle foreground updates
            CLLocation location = e.Location;

            Console.WriteLine("locatiion: " + location.Coordinate.ToString());
            //LblAltitude.Text = location.Altitude + " meters";
            //LblLongitude.Text = location.Coordinate.Longitude.ToString();
            //LblLatitude.Text = location.Coordinate.Latitude.ToString();
            //LblCourse.Text = location.Course.ToString();
            //LblSpeed.Text = location.Speed.ToString();

            Console.WriteLine("foreground updated");
        }
        public void locupdated(object sender, LocationUpdatedEventArgs e)
        {
            if (IOSRegisterDriverMode.shouldPushLocation)
            {
                Task.Factory.StartNew(() =>
                {
                    var userDB = FireDatabase.read("users/" + FireAuth.auth.User.LocalId).Result;
                    //Dictionary<string, Object> children = new Dictionary<string, Object>();
                    if (userDB.ContainsKey("stage_1_driving"))
                    {
                        string stageID = userDB["stage_1_driving"].ToString();
                        Dictionary <string, Object> tracker = new Dictionary <string, Object>();
                        tracker.Add("lat", e.Location.Coordinate.Latitude);
                        tracker.Add("lng", e.Location.Coordinate.Longitude);
                        tracker.Add("time", Time.CurrentTimeMillis());
                        FireDatabase.write("stage_1_ids/" + stageID + "/tracker/" + Time.CurrentTimeMillis(), tracker);
                    }

                    if (userDB.ContainsKey("is_driving"))
                    {
                        string rideID = userDB["is_driving"].ToString();
                        Dictionary <string, Object> tracker = new Dictionary <string, Object>();
                        tracker.Add("lat", e.Location.Coordinate.Latitude);
                        tracker.Add("lng", e.Location.Coordinate.Longitude);
                        tracker.Add("time", Time.CurrentTimeMillis());
                        FireDatabase.write("rides/" + rideID + "/tracker/" + Time.CurrentTimeMillis(), tracker);
                        FireDatabase.write("rides/" + rideID + "/latest_tracker", tracker);
                    }

                    Dictionary <string, Object> location = new Dictionary <string, Object>();
                    location.Add("lat", e.Location.Coordinate.Latitude);
                    location.Add("lng", e.Location.Coordinate.Longitude);
                    FireDatabase.write("cities/" + FireDatabase.currentCity + "/driver_locations/" + FireAuth.auth.User.LocalId, location);
                    if (!IOSRegisterDriverMode.shouldPushLocation)
                    {
                        FireDatabase.write("cities/" + FireDatabase.currentCity + "/driver_locations/" + FireAuth.auth.User.LocalId, null);
                    }
                    //FireDatabase.write("", children);
                });
            }
        }