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);
                });
            }
        }
        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler)
        {
            //Console.WriteLine("RECIEVED NOTIFICATION!");
            //FireDatabase.write("test", Time.CurrentTimeMillis().ToString());
            Console.WriteLine("Recieved a notification!");
            Console.WriteLine("test");
            var aps   = (NSDictionary)userInfo["aps"];
            var alert = aps["alert"];

            Console.WriteLine(alert.ToString());
            if (alert.ToString().Equals("No Drivers are in your area!"))
            {
                if (!backgrounded)
                {
                    if (MainPage.instance != null)
                    {
                        MainPage.instance.resetGUI();
                    }
                    showNotification(alert.ToString());
                }
                Settings.AppState = "DEFAULT";
            }
            else if (alert.ToString().Equals("You changed your Drop off Location!"))
            {
                var test = userInfo["verbose"];
                Instances.DropOffLocation = new DroverLocation(test.ToString(), Double.Parse(userInfo["lat"].ToString()), Double.Parse(userInfo["lng"].ToString()));
            }
            else if (alert.ToString().Equals("Rider changed their Drop off Location!"))
            {
                var test = userInfo["verbose"];
                Instances.DropOffLocation = new DroverLocation(test.ToString(), Double.Parse(userInfo["lat"].ToString()), Double.Parse(userInfo["lng"].ToString()));
            }
            else if (alert.ToString().Equals("SEARCHING FOR RIDE!"))
            {
                Settings.AppState = "SEARCHING";
            }
            else if (alert.ToString().Equals("No drivers accepted your request"))
            {
                if (!backgrounded)
                {
                    if (MainPage.instance != null)
                    {
                        MainPage.instance.resetGUI();
                    }
                    showNotification(alert.ToString());
                }
                Settings.AppState = "DEFAULT";
            }
            else if (alert.ToString().Equals("Your Drover is on the way!"))
            {
                if (!backgrounded)
                {
                    if (MainPage.instance != null)
                    {
                        var    dict   = FireDatabase.read("users/" + FireAuth.auth.User.LocalId).Result;
                        string rideID = dict["is_in_ride"].ToString();
                        Settings.LastRideID = rideID;
                        MainPage.instance.enterRiderGUI();
                    }
                    showNotification(alert.ToString());
                }
                Settings.AppState = "WAITING";
                Settings.InRide   = true;
            }
            else if (alert.ToString().Equals("You are being Requested!"))
            {
                if (!backgrounded)
                {
                    if (MainPage.instance != null)
                    {
                        //proposeRide();
                        //MainPage.instance.enterRiderGUI();
                    }
                    proposeRide();
                }
                Settings.AppState = "REQUESTED";
            }
            else if (alert.ToString().Equals("You have accepted a ride request."))
            {
                if (!backgrounded)
                {
                    MainPage.instance.enterDriverGui();
                }
                Settings.AppState = "DRIVING";
                var    dict   = FireDatabase.read("users/" + FireAuth.auth.User.LocalId).Result;
                string rideID = dict["is_driving"].ToString();
                Settings.LastRideID = rideID;
            }
            //base.DidReceiveRemoteNotification(application, userInfo, completionHandler);
            else if (alert.ToString().Equals("The ride is over!"))
            {
                Settings.InRide = false;
            }
        }