public static Task <Dictionary <string, Object> > read(string path)
        {
            path = WebUtility.UrlEncode(path);
            return(Task <Dictionary <string, Object> > .Factory.StartNew(() =>
            {
                try
                {
                    if (FireAuth.isTokenExpired())
                    {
                        FireAuth.RenewAuthToken(Settings.RefreshToken).RunSynchronously();
                    }

                    var reference = firebase.Child(path);
                    var authReference = QueryExtensions.WithAuth(reference, FireAuth.auth.FirebaseToken);
                    var result = authReference.OnceSingleAsync <Dictionary <string, Object> >().Result;
                    return result;
                }
                catch (Exception e)
                {
                    Console.WriteLine("FireDatabase.cs:read(): ERROR: " + e.GetBaseException());
                    Console.WriteLine(path);
                    return new Dictionary <string, Object>();
                }
            }));
        }
示例#2
0
        public InitPage()
        {
            InitializeComponent();
            UIInstance.nav = Navigation;
            FireDatabase.initDatabase();
            Instances.Init();
            var assembly = typeof(FireCore).GetTypeInfo().Assembly;

            Stream stream = assembly.GetManifestResourceStream("DroverXamarin.iOS.animation.html");
            string text   = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                text += reader.ReadToEnd();
            }
            //HtmlWebViewSource source = new HtmlWebViewSource();
            //source.Html = text;
            //splash_screen.Source = source;
            //DependencyService.Get<IListenForRideProposal>().Listen();
            //FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Password_10");
            FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Bwooorkm1");
            //FireAuth.LoginWithEmailAndPassword("*****@*****.**", "Password_10");
            //var test = assembly.GetManifestResourceStream("DroverXamarin.iOS.animation.html");
            //Console.WriteLine("Stream: "+test+" isNull? "+(test==null).ToString()+" assembly: "+assembly);
            //foreach (var res in assembly.GetManifestResourceNames())
            //	Console.WriteLine("found resource: " + res);
        }
        public SignUpPage()
        {
            InitializeComponent();

            // Adds a back button
            var backButtonGesture = new TapGestureRecognizer();

            backButtonGesture.Tapped += (s, e) =>
            {
                Navigation.PopModalAsync();
            };
            back_arrow_button.GestureRecognizers.Add(backButtonGesture);

            // Sanity checks so that the user only enters proper information
            var signUpButton = new TapGestureRecognizer();

            signUpButton.Tapped += (s, e) =>
            {
                string phone_string = Regex.Replace(phone.Text, @"[^0-9]", "");
                if (String.IsNullOrEmpty(first_name.Text))
                {
                    DisplayAlert("First Name Required", "Please enter a first name ", "OK");
                }
                if (String.IsNullOrEmpty(last_name.Text))
                {
                    DisplayAlert("Last Name Required", "Please enter a last name ", "OK");
                }
                if (String.IsNullOrEmpty(phone.Text))
                {
                    DisplayAlert("Phone Number Required", "Please enter a valid phone number", "OK");
                }
                if (phone.Text.Trim('-').Length < 10)
                {
                    DisplayAlert("Phone Number Required", "Please enter a valid phone number", "OK");
                }
                if (String.IsNullOrEmpty(email_entry.Text))
                {
                    DisplayAlert("Blank E-Mail Field", "E-Mail field was left empty.", "OK");
                }
                if (String.IsNullOrEmpty(password.Text))
                {
                    DisplayAlert("Blank Password Field", "Password field 1 was left empty.", "OK");
                }
                else if (String.IsNullOrEmpty(password_again.Text))
                {
                    DisplayAlert("Blank Password Field", "Password field 2 was left empty.", "OK");
                }
                else if (password.Text.Equals(password_again.Text))
                {
                    FireAuth.SignUpWithEmailAndPassword(email_entry.Text, password_again.Text, first_name.Text, last_name.Text, (long)Int64.Parse(phone_string));
                    //Navigation.PushModalAsync(new MainPage());
                }
                else
                {
                    DisplayAlert("Passwords Do Not Match!", "Your passwords do not match.", "OK");
                }
            };
            sign_in_button.GestureRecognizers.Add(signUpButton);
        }
 public Task <string> GET_BRAINTREE_TOKEN()
 {
     return(Task.Factory.StartNew(() =>
     {
         string message = "GET_BRAINTREE_CLIENT_TOKEN:" + FireAuth.getFirebaseToken() + "!";
         return sendMessageForResponse(message).Result;
     }));
 }
        public async void signOutButtonClicked(object sender, EventArgs e)
        {
            var response = await DisplayAlert("Sign Out", "Are you sure you want to sign out?", "Yes", "No");

            if (response)
            {
                FireAuth.SignOut();
                await Navigation.PushModalAsync(new LaunchPage());
            }
        }
 public static Task GET_DROVER(double lat, double lng)
 {
     return(Task.Factory.StartNew(() =>
     {
         Socket s = new Socket(SocketType.Stream, ProtocolType.Tcp);
         s.Connect(remoteEP);
         string message = "GET_DROVER:" + lat + "," + lng + "," + FireAuth.getFirebaseToken() + "!";
         s.Send(getBytes(message));
         s.Shutdown(SocketShutdown.Both);
         s.Close();
     }));
 }
 public static Task REQUEST_DRIVER_MODE()
 {
     return(Task.Factory.StartNew(() =>
     {
         Socket s = new Socket(SocketType.Stream, ProtocolType.Tcp);
         s.Connect(remoteEP);
         string message = "REQUEST_DRIVER_MODE:" + FireAuth.getFirebaseToken() + "!";
         s.Send(getBytes(message));
         s.Shutdown(SocketShutdown.Both);
         s.Close();
     }));
 }
 public static Task CONFIRM_DROP_OFF(string rideID)
 {
     return(Task.Factory.StartNew(() =>
     {
         Socket s = new Socket(SocketType.Stream, ProtocolType.Tcp);
         s.Connect(remoteEP);
         string message = "CONFIRM_DROP_OFF:" + rideID + "," + FireAuth.getFirebaseToken() + "!";
         s.Send(getBytes(message));
         s.Shutdown(SocketShutdown.Both);
         s.Close();
     }));
 }
 public static Task PROPOSAL_RESPONSE(bool respo)
 {
     return(Task.Factory.StartNew(() =>
     {
         int resp = respo ? 1 : 0;
         Socket s = new Socket(SocketType.Stream, ProtocolType.Tcp);
         s.Connect(remoteEP);
         string message = "PROPOSAL_RESPONSE:" + resp + "," + FireAuth.getFirebaseToken() + "!";
         s.Send(getBytes(message));
         s.Shutdown(SocketShutdown.Both);
         s.Close();
     }));
 }
        public SignInPage()
        {
            InitializeComponent();

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                FireAuth.LoginWithEmailAndPassword(email_field.Text, password_field.Text);
                //Navigation.PushModalAsync(new MainPage());
            };
            sign_in_button.GestureRecognizers.Add(tapGestureRecognizer);

            var backButtonGesture = new TapGestureRecognizer();

            backButtonGesture.Tapped += (s, e) =>
            {
                Navigation.PopModalAsync();
            };
            back_arrow_button.GestureRecognizers.Add(backButtonGesture);
        }
        public SignUpPage()
        {
            InitializeComponent();
            var backButtonGesture = new TapGestureRecognizer();

            backButtonGesture.Tapped += (s, e) =>
            {
                Navigation.PopModalAsync();
            };
            back_arrow_button.GestureRecognizers.Add(backButtonGesture);

            var signUpButton = new TapGestureRecognizer();

            signUpButton.Tapped += (s, e) =>
            {
                if (String.IsNullOrEmpty(email_entry.Text))
                {
                    DisplayAlert("Blank E-Mail Field", "E-Mail field was left empty.", "OK");
                }
                if (String.IsNullOrEmpty(password.Text))
                {
                    DisplayAlert("Blank Password Field", "Password field 1 was left empty.", "OK");
                }
                else if (String.IsNullOrEmpty(password_again.Text))
                {
                    DisplayAlert("Blank Password Field", "Password field 2 was left empty.", "OK");
                }
                else if (password.Text.Equals(password_again.Text))
                {
                    FireAuth.SignUpWithEmailAndPassword(email_entry.Text, password_again.Text);
                    //Navigation.PushModalAsync(new MainPage());
                }
                else
                {
                    DisplayAlert("Passwords Do Not Match!", "Your passwords do not match.", "OK");
                }
            };
            sign_in_button.GestureRecognizers.Add(signUpButton);
        }
 public static Task write(string path, object value)
 {
     path = WebUtility.UrlEncode(path);
     return(Task.Factory.StartNew(async() =>
     {
         try
         {
             if (FireAuth.isTokenExpired())
             {
                 Console.WriteLine("TOKEN WAS EXPIRED WHEN WRITING");
                 FireAuth.RenewAuthToken(Settings.RefreshToken).RunSynchronously();
             }
             var query = firebase.Child(path);
             await QueryExtensions.WithAuth(query, FireAuth.auth.FirebaseToken).PutAsync(value);
             //.PutAsync(value);
         }
         catch (Exception e)
         {
             Console.WriteLine("FireDatabase.cs:write(): ERROR: " + e.GetBaseException());
             Console.WriteLine("ERROR ON: " + path);
         }
     }));
 }
示例#13
0
        public SignInPage()
        {
            InitializeComponent();


            // Creates a sign in button for when the user is done entering his or her information
            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) =>
            {
                FireAuth.LoginWithEmailAndPassword(email_field.Text, password_field.Text);
                //Navigation.PushModalAsync(new MainPage());
            };
            sign_in_button.GestureRecognizers.Add(tapGestureRecognizer);

            // Adds a back button
            var backButtonGesture = new TapGestureRecognizer();

            backButtonGesture.Tapped += (s, e) =>
            {
                Navigation.PopModalAsync();
            };
            back_arrow_button.GestureRecognizers.Add(backButtonGesture);
        }