public void GetUserName() { FirebaseFirestore db = FirebaseFirestore.DefaultInstance; DocumentReference docRef = db.Collection("users").Document(userUID); docRef.GetSnapshotAsync().ContinueWithOnMainThread(task1 => { DocumentSnapshot snapshot = task1.Result; if (snapshot.Exists) { Debug.Log(string.Format("Document data for {0} document:", snapshot.Id)); Dictionary <string, object> user1 = snapshot.ToDictionary(); userName = user1["FirstName"].ToString(); totalCoins = int.Parse(user1["TotalCoins"].ToString()); Debug.Log("userName is " + userName); Debug.Log("remeberMe.isOn value is " + remeberMe.isOn); if (remeberMe.isOn) { Debug.Log("in remember me if condition"); RememberMe(); } signin = true; } }); }
// Start is called before the first frame update void Start() { jugador = FindObjectOfType <puntuacionFinal>(); score = jugador.puntos; puntosJugador.GetComponent <TextMeshProUGUI>().text = $" {score} puntos"; textRepe.SetActive(false); db = FirebaseFirestore.GetInstance(FirebaseApp.Create()); CollectionReference jugadoresRef = db.Collection("jugadores"); Query query = jugadoresRef.OrderByDescending("puntos").Limit(5); ListenerRegistration listener = query.Listen(snapshot => { string top5 = "TOP 5 \n\n"; var cont = 1; foreach (DocumentSnapshot documentSnapshot in snapshot.Documents) { Dictionary <string, object> jugador = documentSnapshot.ToDictionary(); top5 += $"{cont}-{documentSnapshot.Id}..........{jugador["puntos"]}\n"; cont += 1; nicks.Add(documentSnapshot.Id.ToString()); } marcador.GetComponent <TextMeshProUGUI>().text = top5; }); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); // Assigns values to the form controls allItemsPrice = 0.0M; total = view.FindViewById <TextView>(Resource.Id.totalCost); cart = view.FindViewById <LinearLayout>(Resource.Id.shopping_cart); btnPurchase = view.FindViewById <Button>(Resource.Id.btnPurchase); delete = view.FindViewById <ImageView>(Resource.Id.delete); orderedList = view.FindViewById <RecyclerView>(Resource.Id.rcvOrders); db = FirebaseFirestore.GetInstance(FirestoreUtils.App); auth = FirestoreUtils.Auth; btnPurchase.Click += BtnPurchase_Click; userOrders = new List <Order>(); orderFilter = db.Collection("Orders").WhereEqualTo("Uid", auth.CurrentUser.Uid); FetchData(); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); clientLogged = await _storageService.GetClientDataLocal(); // Create your application here SetContentView(Resource.Layout.pets); if (clientLogged.MedicSubscribed == null) { Toast.MakeText(this, "Abonati-va la un medic mai intai!", ToastLength.Long).Show(); StartActivity(typeof(MainActivity)); return; } _firestoreDb = _userService.GetDatabase(this); animalListView = FindViewById <ListView>(Resource.Id.lstView_Pets); progress = new ProgressDialog(this); progress.Indeterminate = false; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Asteptati..."); progress.SetCancelable(false); progress.Show(); FetchData(); }
public async Task <string> AddTransaction(string category, string money) { try { FirebaseFirestore database; string uid = FirebaseAuth.Instance.CurrentUser.Uid; var app = FirebaseApp.Instance; database = FirebaseFirestore.GetInstance(app); string date = DateTime.Today.ToString("dd/MM/yyyy"); string type = "Earnings"; HashMap map = new HashMap(); map.Put("tipologia", type); map.Put("cifra", money); map.Put("categoria", category); map.Put("data", date); map.Put("createdAt", Timestamp.Now()); //servirà per ordinare i documenti quando si estraggono DocumentReference docRef = database.Collection("utenti").Document(uid).Collection("transazioni").Document(); var task = await docRef.Set(map); return("ok"); } catch (Exception e) { //Debug.WriteLine($"Error:{e}"); return("error"); } }
public static FirebaseFirestore GetFirestore() { var app = FirebaseApp.InitializeApp(Application.Context); FirebaseFirestore database; if (app == null) { var options = new FirebaseOptions.Builder() .SetProjectId("facepostapp-8f75f") .SetApplicationId("facepostapp-8f75f") .SetApiKey("AIzaSyDX3nL4ZWT0CljwJxpbzpELlFGpi3Agq3w") .SetDatabaseUrl("https://facepostapp-8f75f.firebaseio.com") .SetStorageBucket("facepostapp-8f75f.appspot.com") .Build(); app = FirebaseApp.InitializeApp(Application.Context, options); database = FirebaseFirestore.GetInstance(app); } else { database = FirebaseFirestore.GetInstance(app); } return(database); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); // Assigns the control objects to their XAML counterparts orderQuantity = 1; quantity = view.FindViewById <TextView>(Resource.Id.orderQuantity); itemInfo = view.FindViewById <TextView>(Resource.Id.description); itemPrice = view.FindViewById <TextView>(Resource.Id.price); foodChoice = view.FindViewById <Spinner>(Resource.Id.allItems); rootView = view.FindViewById <LinearLayout>(Resource.Id.rootView); increaseQuantity = view.FindViewById <Button>(Resource.Id.quantityIncrease); decreaseQuantity = view.FindViewById <Button>(Resource.Id.quantityDecrease); addToCart = view.FindViewById <Button>(Resource.Id.add_to_cart); db = FirebaseFirestore.GetInstance(FirestoreUtils.App); // Setting up event listeners foodChoice.ItemSelected += FoodChoice_ItemSelected; increaseQuantity.Click += IncreaseQuantity_Click; decreaseQuantity.Click += DecreaseQuantity_Click; addToCart.Click += AddToCart_Click; CollectionReference cr = db.Collection("Items"); cr.Get().AddOnSuccessListener(this); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); //Init method which initialzed windows forms maps -E60 T0.45 Xamarin.FormsMaps.Init(this, savedInstanceState); //Init method which request the activity -E62 T7.23 Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState); string dbName = "travel_db.sqlite"; string folderpath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string fullpath = Path.Combine(folderpath, dbName); //This instances needs to be called only onces as this creates database in Firestore. -E:Ufinix Firestore T:17.40 database = GetDataBase(); //saveMtd(); LoadApplication(new App(fullpath)); }
public async Task <string> SignUp(string email, string password, string name, string lastName) { try { var user = await FirebaseAuth.Instance.CreateUserWithEmailAndPasswordAsync(email, password); var token = await user.User.GetIdTokenAsync(false); //per salvare dati nella collection users if (token.Token != null) { FirebaseFirestore database; string uid = FirebaseAuth.Instance.CurrentUser.Uid; var app = FirebaseApp.Instance; database = FirebaseFirestore.GetInstance(app); HashMap map = new HashMap(); map.Put("email", email); map.Put("nome", name); map.Put("cognome", lastName); DocumentReference docRef = database.Collection("utenti").Document(uid); await docRef.Set(map); } return(token.Token); } catch (Exception e) { return(null); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //get Database _firestoreDb = _userService.GetDatabase(this); clientLogged = await _storageService.GetClientDataLocal(); await GetConsultCategory(); animalSelected = JsonConvert.DeserializeObject <Animal>(Intent.GetStringExtra("Animal")); SetContentView(Resource.Layout.pet_appointments_main); _scheduler = FindViewById <SfSchedule>(Resource.Id.appointments_scheduler); progress = new ProgressDialog(this); progress.Indeterminate = false; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Se afiseaza calendarul..."); progress.SetCancelable(false); progress.Show(); FetchAppointmentsWeek(); var scheduleHours = GetMedicScheduleHours(); _scheduler.ScheduleView = ScheduleView.WeekView; WeekViewSettings settings = new WeekViewSettings(); settings.WeekLabelSettings.TimeFormat = "hh:mm"; settings.StartHour = scheduleHours[0]; settings.EndHour = scheduleHours[1]; // set medic working hours interval _scheduler.WeekViewSettings = settings; _scheduler.CellTapped += Scheduler_CellTapped; }
/** * Function that * 1. Hashes the downloaded map data * 2. Checks to see if the map has a current high score * * */ public void CheckForHighScore() { FirebaseFirestore db = FirebaseFirestore.DefaultInstance; CollectionReference colRef = db.Collection("Maps"); // Get hash value for map data SHA256Managed hash = new SHA256Managed(); byte[] result = hash.ComputeHash(heightData); string hashValue = ""; foreach (byte b in result) { hashValue += b.ToString("x2"); } map_hash_value = hashValue; //query the db to see if the map exists Firebase.Firestore.Query query = colRef.WhereEqualTo("hash", hashValue); query.GetSnapshotAsync().ContinueWithOnMainThread((querySnapshotTask) => { foreach (DocumentSnapshot docSnap in querySnapshotTask.Result.Documents) { Dictionary <string, object> mapObj = docSnap.ToDictionary(); var mapScore = mapObj["score"]; double mapScoreD; double.TryParse(mapScore.ToString(), out mapScoreD); mapHighScore = mapScoreD; } }); }
public async Task <ObservableCollection <Transaction> > GetSomeTransactions(string category) { try { ObservableCollection <Transaction> ListTransactions = new ObservableCollection <Transaction>(); FirebaseFirestore db; string uid = FirebaseAuth.Instance.CurrentUser.Uid; var app = FirebaseApp.Instance; db = FirebaseFirestore.GetInstance(app); //prendo solo i documenti con il campo categoria uguale alla categoria selezionata Query allTransactionsQuery = db.Collection("utenti").Document(uid). Collection("transazioni").WhereEqualTo("categoria", category).OrderBy("createdAt", Query.Direction.Ascending); //vettore lista documenti QuerySnapshot allTransactionsQuerySnapshot = (QuerySnapshot)await allTransactionsQuery.Get(); //vettore lista delle informazioni (dati) di ogni documento foreach (DocumentSnapshot documentSnapshot in allTransactionsQuerySnapshot.Documents) { ListTransactions.Add(new Transaction() { Type = documentSnapshot.GetString("tipologia"), Category = documentSnapshot.GetString("categoria"), Money = (float)Math.Round(float.Parse(documentSnapshot.GetString("cifra"), provider), 2), Date = documentSnapshot.GetString("data") }); } return(ListTransactions); } catch (Exception e) { //Debug.WriteLine($"Error:{e}"); return(ListTransactions); } }
public static FirebaseAuth GetFirebaseAuth() { var app = FirebaseApp.InitializeApp(Application.Context); FirebaseFirestore database; FirebaseAuth mAuth; if (app == null) { var options = new FirebaseOptions.Builder() .SetProjectId("expense-tracker-app-a176f") .SetApplicationId("expense-tracker-app-a176f") .SetApiKey("AIzaSyD0HaWxjzluyG97Dcxf9C5d9MUHWmQaYgQ") .SetDatabaseUrl("https://expense-tracker-app-a176f.firebaseio.com") .SetStorageBucket("expense-tracker-app-a176f.appspot.com") .Build(); app = FirebaseApp.InitializeApp(Application.Context, options); database = FirebaseFirestore.GetInstance(app); FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder().SetTimestampsInSnapshotsEnabled(true).Build(); database.FirestoreSettings = settings; mAuth = FirebaseAuth.Instance; } else { database = FirebaseFirestore.GetInstance(app); FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder().SetTimestampsInSnapshotsEnabled(true).Build(); database.FirestoreSettings = settings; mAuth = FirebaseAuth.Instance; } return(mAuth); }
public async Task <ObservableCollection <Transaction> > GetTransactions() { ObservableCollection <Transaction> ListTransactions = new ObservableCollection <Transaction>(); FirebaseFirestore db; string uid = FirebaseAuth.Instance.CurrentUser.Uid; var app = FirebaseApp.Instance; db = FirebaseFirestore.GetInstance(app); Query allTransactionsQuery = db.Collection("utenti").Document(uid). Collection("transazioni").OrderBy("createdAt", Query.Direction.Ascending); //vettore lista documenti QuerySnapshot allTransactionsQuerySnapshot = (QuerySnapshot)await allTransactionsQuery.Get(); //vettore lista delle informazioni (dati) di ogni documento foreach (DocumentSnapshot documentSnapshot in allTransactionsQuerySnapshot.Documents) { ListTransactions.Add(new Transaction() { Type = documentSnapshot.GetString("tipologia"), Category = documentSnapshot.GetString("categoria"), Money = (float)Math.Round(float.Parse(documentSnapshot.GetString("cifra"), provider), 2), Date = documentSnapshot.GetString("data") }); } return(ListTransactions); }
public async Task <string> TotalSum() { float sum = 0; FirebaseFirestore db; string uid = FirebaseAuth.Instance.CurrentUser.Uid; var app = FirebaseApp.Instance; db = FirebaseFirestore.GetInstance(app); Query allTransactionsQuery = db.Collection("utenti").Document(uid). Collection("transazioni"); //lista documenti QuerySnapshot allTransactionsQuerySnapshot = (QuerySnapshot)await allTransactionsQuery.Get(); //lista delle informazioni (dati) di ogni documento foreach (DocumentSnapshot documentSnapshot in allTransactionsQuerySnapshot.Documents) { if (String.Equals(documentSnapshot.GetString("tipologia"), "Earnings")) { sum += (float)Math.Round(float.Parse(documentSnapshot.GetString("cifra"), provider), 2); } else if (String.Equals(documentSnapshot.GetString("tipologia"), "Outflows")) { sum -= (float)Math.Round(float.Parse(documentSnapshot.GetString("cifra"), provider), 2); } } string sumString; if (sum >= 0) { sumString = "+" + sum.ToString(); } else { sumString = sum.ToString(); } return(sumString); }
//This will return an instance of our firestore database public static FirebaseFirestore GetFirestore() { FirebaseFirestore database; //Initialize firestore var app = FirebaseApp.InitializeApp(Application.Context); //to check if the firebase has been initialized if (app == null) { //create firbase options //we are going to use the builder to force the firebase to initialize var options = new FirebaseOptions.Builder() .SetProjectId("bookface-f0b7d") .SetApplicationId("bookface-f0b7d") .SetApiKey("AIzaSyBVPmz1ACSUFGfqUuJYCtuqn5qm0rqMQOg") .SetDatabaseUrl("https://bookface-f0b7d.firebaseio.com") .SetStorageBucket("bookface-f0b7d.appspot.com") .Build(); //this will initialize our database app = FirebaseApp.InitializeApp(Application.Context, options); database = FirebaseFirestore.GetInstance(app); } else { //if the database was automatically initialized database = FirebaseFirestore.GetInstance(app); } return(database); }
void Start() { FirebaseFirestore db = FirebaseFirestore.DefaultInstance; CollectionReference usersRef = db.Collection("InteriorDataCollection"); usersRef.GetSnapshotAsync().ContinueWithOnMainThread(task => { QuerySnapshot snapshot = task.Result; foreach (DocumentSnapshot document in snapshot.Documents) { Debug.Log(String.Format("User: {0}", document.Id)); Dictionary <string, object> documentDictionary = document.ToDictionary(); InteriorData interiorData = new InteriorData(); interiorData.id = int.Parse(documentDictionary["id"].ToString()); string[] prices = documentDictionary["price"].ToString().Split('/'); interiorData.price = float.Parse(prices[0]); interiorData.priceUnit = prices[1]; interiorData.purchaseType = documentDictionary["purchaseType"].ToString(); interiorData.unlockStage = int.Parse(documentDictionary["unlockStage"].ToString()); } Debug.Log("Read all data from the users collection."); }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); recyclerView = (RecyclerView)FindViewById(Resource.Id.myRecyclerView); searchButton = (ImageView)FindViewById(Resource.Id.searchButton); searchText = (EditText)FindViewById(Resource.Id.searchText); phones = DataHelper.SeedData(); db = DataHelper.GetDatabsase(); var a = db.Collection("phones").Document("AIppzUUfprOLuMXga7PC").Get().AddOnSuccessListener(this); SetupRecycleView(); //FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.addNewPhone); //fab.Click += FabOnClick; }
// Start is called before the first frame update void Start() { db = FirebaseFirestore.DefaultInstance; Grab(); Grab2(); }
public static FirebaseFirestore GetDatabsase() { var app = FirebaseApp.InitializeApp(Application.Context); app = null; if (app == null) { var option = new FirebaseOptions.Builder() .SetProjectId("phonexamarinforms") .SetApplicationId("phonexamarinforms") .SetApiKey("AIzaSyDRdUy_dlmFzDeM1mbJ6ORFWSP2OWQfeGU") .SetDatabaseUrl("https://phonexamarinforms.firebaseio.com") .SetStorageBucket("phonexamarinforms.appspot.com") .Build(); app = FirebaseApp.InitializeApp(Application.Context, option, "phone_db"); //var settings = new FirebaseFirestoreSettings.Builder().SetTimestampsInSnapshotsEnabled(true).Build(); var firestore = FirebaseFirestore.GetInstance(app); //firestore.FirestoreSettings = settings; return(firestore); } return(FirebaseFirestore.GetInstance(app)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); database = GetDataase(); BuildScreen(); }
public static FirestoreWrapper GetFirestore(FirebaseFirestore firestore) { if (firestore == FirebaseFirestore.Instance) { return(Firestore); } return(_firestores.GetOrAdd(firestore, key => new Lazy <FirestoreWrapper>(() => new FirestoreWrapper(key))).Value); }
//https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/graphics-and-animation protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.AddMeetingLayout); database = MyStuff.database; admin = MyStuff.GetAdmin(); GetGroups(); }
protected override void OnCreate(Bundle savedInstanceState) { sp = this.GetSharedPreferences("details", FileCreationMode.Private); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainPageLayout); admin1 = MyStuff.GetAdmin(); database = MyStuff.database; GetDates(); }
public void Firestore_DefaultInstanceShouldBeStable() { FirebaseFirestore db1 = FirebaseFirestore.DefaultInstance; FirebaseFirestore db2 = FirebaseFirestore.DefaultInstance; Assert.That(db1, Is.SameAs(db2)); Assert.That(db1, Is.SameAs(db1.Collection("a").WhereEqualTo("x", 1).Firestore)); Assert.That(db2, Is.SameAs(db2.Document("a/b").Firestore)); }
public void CreateUserDocument() // Creates firebase document with UID in "AllUsers" collection. { Debug.Log("in create user doc"); FirebaseFirestore db = FirebaseFirestore.DefaultInstance; Debug.Log("in create user doc after firebase db initialization"); DocumentReference docRef = db.Collection("users").Document(SignUp2.registeredUserID); Dictionary <string, object> user = new Dictionary <string, object> { { "FirstName", firstName.text }, { "LastName", lastName.text }, { "Email", email.text }, { "pincode", pincode.text }, { "Day", dayDropdown.options[dayDropdown.value].text }, { "Month", monthDropDown.options[monthDropDown.value].text }, { "Year", yearDropDown.options[yearDropDown.value].text }, { "Address1", address1.text }, { "Address2", address2.text }, { "City", city.text }, { "Mobile", "+91" + mobile.text }, { "Gender", male.allowSwitchOff }, { "Role", "Patient" }, { "UserID", SignUp2.registeredUserID }, { "TotalCoins", 0 } // {"AddNotification",false }, // {"RequestedTherapistUID","null" }, // {"IsRoutineSessionSet", false }, // {"TherapistUID","null" } }; docRef.SetAsync(user).ContinueWithOnMainThread(task => { Debug.Log("Paitent Added"); }); Debug.Log("Patient UID reg is " + SignUp2.registeredUserID); FirebaseFirestore db2 = FirebaseFirestore.DefaultInstance; DocumentReference docRef2 = db2.Collection("users").Document(SignUp2.registeredUserID).Collection("armable").Document("overallProgress"); Dictionary <string, object> user1 = new Dictionary <string, object> { { "totalGameSessionsPlayed", 0 }, { "totalGameDistanceMoved", 0 }, { "totalTimePlayed", 0 }, { "totalRepetitions", 0 }, { "currentSessionNmbr", 0 }, }; docRef2.SetAsync(user1).ContinueWithOnMainThread(task => { Debug.Log("Overall progress document for armable is initialised"); }); register = true; }
protected override void OnCreate(Bundle savedInstanceState) { sp = this.GetSharedPreferences("details", FileCreationMode.Private); base.OnCreate(savedInstanceState); Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.RegisterLayout); database = MyStuff.database; GetEmails(); TryToGetPermissions(); }
public void InitFirebase() { var FirestoreIstance = FirebaseFirestore.GetInstance(MainActivity.MyFirebaseApp); //var FirestoreIstance = FirebaseFirestore.Instance; if (FirestoreIstance != null) { //DO SOMETHING } }
private void InitializeFirebase() { Debug.Log("Setting up Firebase Auth"); //Set the authentication instance object auth = FirebaseAuth.DefaultInstance; firestore = FirebaseFirestore.DefaultInstance; database = FirebaseDatabase.DefaultInstance.RootReference; DatabaseAPI.InitializeDatabase(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); ConnectViews(); database = GetDataBase(); FetchData(); SetuprecyclerView(); }