public override void Resume(StateExitValue results) { ShowUI(); if (results != null) { if (results.sourceState == typeof(WaitForTask)) { WaitForTask.Results taskResults = results.data as WaitForTask.Results; if (taskResults.task.IsFaulted) { manager.SwapState(new ManageAccount()); manager.PushState(new BasicDialog(StringConstants.DeleteAccountFail + taskResults.task.Exception.ToString())); } else { // Delete the user's profile data: string path = CommonData.DBUserTablePath + userId; FirebaseDatabase database = FirebaseDatabase.GetInstance(CommonData.app); // Delete all maps associated with this user: database.GetReference(path).SetValueAsync(null); foreach (MapListEntry map in CommonData.currentUser.data.maps) { path = CommonData.DBMapTablePath + map.mapId; database.GetReference(path).SetValueAsync(null); } manager.SwapState(new ChooseSignInMenu()); manager.PushState(new BasicDialog(StringConstants.DeleteAccountSuccess)); } } } }
public void SetUserData(FirebaseUser user) { var uid = user.Uid; var name = user.DisplayName; var email = user.Email; var emailVerified = user.IsEmailVerified; var photoUrl = user.PhotoUrl; authAccount = new Account { Uid = uid, Name = name, Email = email, EmailVerified = emailVerified }; dataRef = firData.GetReference($"users/{uid}"); IDictionary <string, Java.Lang.Object> userData = new Dictionary <string, Java.Lang.Object> { { "name", name }, { "email", email } }; dataRef.UpdateChildren(userData); if (watchDir == null) { dataRef.AddChildEventListener(new AcctListener()); watchDir = dataRef.Child("watchItems"); watchDir.AddChildEventListener(new WatchListener()); checkDir = dataRef.Child("checkIns"); checkDir.AddListenerForSingleValueEvent(new CheckinListener()); } }
void LogWorkout() { if (selectedDay == null) { string today = DateTime.Now.ToString("d/M/yyyy"); selectedDay = today; } string day = selectedDay; string workout = calendarWorkoutTextBox.Text; string reps = calendarRepTextBox.Text; //Creating HashMap to store user information to Firebase HashMap workoutInfo = new HashMap(); workoutInfo.Put("date", day); workoutInfo.Put("workout", workout); workoutInfo.Put("reps", reps); //sets user's id to be the unique id in database DatabaseReference userReference = database.GetReference("workouts").Push(); userReference.SetValue(workoutInfo); Snackbar.Make(calendarCoordinatorLayout, "Workout was logged successfully", Snackbar.LengthShort).Show(); calendarWorkoutTextBox.Text = ""; calendarRepTextBox.Text = ""; }
// public void GetUsers(){ // Firebase.Database.FirebaseDatabase dbInstance = Firebase.Database.FirebaseDatabase.DefaultInstance; // _database.GetReference(userID).GetValueAsync().ContinueWith(task => { // if (task.IsFaulted) { // // Handle the error... // } // else if (task.IsCompleted) { // DataSnapshot snapshot = task.Result; // foreach ( DataSnapshot user in snapshot.Children){ // IDictionary dictUser = (IDictionary)user.Value; // Debug.Log ("bro please" + dictUser["activePet"]); // } // } // }); // } // public void SaveAndRetrieveData() //from the database (server)... // { // //store the data to the server... // reference.Child("My Car Collections").Child("Sports Car").SetValueAsync("Ferrari"); // print("data saved"); // //Retrieve the data and convert it to string... // FirebaseDatabase.DefaultInstance.GetReference("My Car Collections").GetValueAsync().ContinueWith(task => // { // DataSnapshot snapshot = task.Result; // string ss = snapshot.Child("Sports Car").Value.ToString(); // print(ss); // print("data retrieved"); // }); // } public static string GetPetType(string playerID) { string petUpdate = ""; // while(petUpdate == "Poopy") { _database.GetReference(playerID).Child("activePet").GetValueAsync().ContinueWithOnMainThread(task => { if (task.IsCanceled) { Debug.Log("Could Not Retrieve Active Pet"); return(""); } if (task.IsFaulted) { Debug.LogError("Could Not Retrieve Active Pet: " + task.Exception); return(""); } DataSnapshot snapshot = task.Result; petUpdate = snapshot.Value.ToString(); Debug.Log("snapshot" + petUpdate); string updatedPet = PetTypeValue(playerID, petUpdate); // this doesn't work Debug.Log(playerID); Debug.Log("COME ONE" + petUpdate); // return updatedPet; return(petUpdate); }); // return petUpdate; // } return(petUpdate); }
private void getUserSetting() { string _ref = Shared.MySettingRef("1000"); Debug.Log("get user setting ref=" + _ref); mDatabase.GetReference(_ref).GetValueAsync().ContinueWith(task => { if (task.IsCompleted) { DataSnapshot myData = task.Result; if (myData.Exists) { Debug.Log("results:" + task.Result.GetRawJsonValue()); Setting mySetting = (Setting)myData.GetValue(true); Debug.Log("toString:" + mySetting.ToString()); } else { Debug.Log("Empty data"); initDefaultSetting(_ref); } } else { Debug.Log("get my setting error"); } }); }
public void GetMessage() { var userId = authService.GetUserId(); databaseReference = database.GetReference("messages/" + userId); databaseReference.AddValueEventListener(new ValueEventListener()); }
void Start() { logged_key = PlayerPrefs.GetString("UID"); roomId = PlayerPrefs.GetString("Room"); FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://zeld-e907d.firebaseio.com/"); reference = FirebaseDatabase.DefaultInstance.RootReference; //escritura dbInstance = FirebaseDatabase.DefaultInstance; //lectura room_players = new List <PlayerClass>(); capacity = 0; ready = false; ready_players = 0; errorMessage = ""; fname = ""; floses = ""; fwins = ""; fnemesis = ""; fprefg = ""; ffavu = ""; SetupDisplay(); dbInstance.GetReference("rooms").Child(roomId).Child("messages").ChildAdded += HandleMessageAdded; dbInstance.GetReference("rooms").Child(roomId).Child("players").ChildAdded += HandlePLayerAdded; dbInstance.GetReference("rooms").Child(roomId).Child("players").ChildRemoved += HandlePlayerRemoved; dbInstance.GetReference("rooms").Child(roomId).Child("players").ChildChanged += HandlePlayerEdited; sendButton.onClick.AddListener(() => SenderChat(chatInput.text)); leaveButton.onClick.AddListener(() => LeavePress()); readyButton.onClick.AddListener(() => ReadyPress()); startButton.onClick.AddListener(() => StartGame()); backProfileButton.onClick.AddListener(() => HideProfileCanvas()); }
public void CreateRequest() { newTripRef = database.GetReference("rideRequest").Push(); HashMap location = new HashMap(); location.Put("latitude", newTrip.PickupLat); location.Put("longitude", newTrip.PickupLng); HashMap destination = new HashMap(); destination.Put("latitude", newTrip.DestinationLat); destination.Put("longitude", newTrip.DestinationLng); HashMap myTrip = new HashMap(); newTrip.RideID = newTripRef.Key; myTrip.Put("location", location); myTrip.Put("destination", destination); myTrip.Put("destination_address", newTrip.DestinationAddress); myTrip.Put("pickup_address", newTrip.PickupAddress); myTrip.Put("rider_id", AppDataHelper.GetCurrentUser().Uid); myTrip.Put("payment_method", newTrip.Paymentmethod); myTrip.Put("create_at", newTrip.Timestamp.ToString()); myTrip.Put("driver_id", "waiting"); myTrip.Put("rider_name", AppDataHelper.GetFullName()); myTrip.Put("rider_phone", AppDataHelper.GetPhone()); newTripRef.AddValueEventListener(this); newTripRef.SetValue(myTrip); }
public async void GetUserData() { await dbInstance.GetReference("users").Child(logged_key).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; IDictionary dictUser = (IDictionary)snapshot.Value; password = dictUser["password"].ToString(); email = dictUser["email"].ToString(); wins = dictUser["wins"].ToString(); loses = dictUser["loses"].ToString(); nemesis = dictUser["nemesis"].ToString(); fav_game = dictUser["pref_game"].ToString(); fav_unit = dictUser["fav_unit"].ToString(); } }); idLabel.text = "Id: " + logged_key; userValue.text = PlayerPrefs.GetString("UserName"); emailValue.text = email; passValue.text = password; winsLabel.text = "Wins: " + wins; losesLabel.text = "Loses: " + loses; prefGLabel.text = "Prefered Game: " + fav_game; FavULabel.text = "Favorite initial Unit: " + fav_unit; SetNemesis(); }
private void OnDestroy() { if (_database != null) { _database.GetReference(Latitude).ValueChanged -= OnLatitudeChanged; _database.GetReference(Longitude).ValueChanged -= OnLongitudeChanged; } }
private async void QueueUp(object sender, DialogClickEventArgs e) { await get_Queue_Size(); DatabaseReference reference = database.GetReference("queues"); reference.Child(cur_restaurant.uid).Child(auth.CurrentUser.Uid).Child("name").SetValue(customer_name); reference.Child(cur_restaurant.uid).Child(auth.CurrentUser.Uid).Child("party_size").SetValue(party_size.Text); reference.Child(cur_restaurant.uid).Child(auth.CurrentUser.Uid).Child("queue_position").SetValue(cur_queue_size + 1); Toast.MakeText(this, "Your Party of " + party_size.Text + " was Succesfully Queued! Your Position in Queue is: " + (cur_queue_size + 1), ToastLength.Long).Show(); }
private void Start() { _startingPosition = transform.position; _events = ServiceLocator.Resolve <Events>(); _events.Register <FirebaseInitializedEvent>(@event => { _database = FirebaseDatabase.DefaultInstance; _database.GetReference(Latitude).ValueChanged += OnLatitudeChanged; _database.GetReference(Longitude).ValueChanged += OnLongitudeChanged; }); }
public void UpdateLocation(Android.Locations.Location mylocation) { string driverId = AppDataHelper.GetCurrentUser().Uid; if (_availablityRef != null) { DatabaseReference locationref = _database.GetReference("driversAvailable/" + driverId + "/location"); HashMap locationMap = new HashMap(); locationMap.Put("latitude", mylocation.Latitude); locationMap.Put("longitude", mylocation.Longitude); locationref.SetValue(locationMap); } }
public static void SavePlayer(string playerName, string json) { _database.GetReference(playerName).SetRawJsonValueAsync(json); //_database.ref("users").Child(playerName).SetRawJsonValueAsync(json); Debug.Log("save ran"); }
void InitializeDatabase() { var app = FirebaseApp.InitializeApp(this); if (app == null) { var options = new FirebaseOptions.Builder() .SetApplicationId("uber-clone-a1c9b") .SetApiKey("AIzaSyA_iDmRc4MUWwvUuPxlus7NyywRSzah0IA") .SetDatabaseUrl("https://uber-clone-a1c9b.firebaseio.com") .SetStorageBucket("uber-clone-a1c9b.appspot.com") .Build(); app = FirebaseApp.InitializeApp(this, options); database = FirebaseDatabase.GetInstance(app); } else { database = FirebaseDatabase.GetInstance(app); } DatabaseReference dbref = database.GetReference("UserSupport"); dbref.SetValue("Ticket1"); Toast.MakeText(this, "Completed", ToastLength.Short).Show(); }
private void OptionMenuDialog(int pos) { var optionMenu = LayoutInflater.Inflate(Resource.Layout.menu_dialog_2, null, false); var btnShare = optionMenu.FindViewById <Button>(Resource.Id.btnShare); var btnWish = optionMenu.FindViewById <Button>(Resource.Id.btnWishlist); var alert = new Android.App.AlertDialog.Builder(this).Create(); alert.SetView(optionMenu); alert.Window.EnterTransition = new Slide(GravityFlags.Bottom); alert.Window.RequestFeature(WindowFeatures.NoTitle); alert.Show(); btnShare.Click += (o, s) => { alert.Dismiss(); ShareBottomDialog(); }; btnWish.Click += (o, s) => { alert.Dismiss(); var product = mAdapter.Product[pos].Product; var id = mAdapter.Product[pos].ProductID; var categoryID = mAdapter.Product[pos].CategoryID; var subcategoryID = mAdapter.Product[pos].SubCategoryID; db = FirebaseDatabase.Instance; var _ref = db.GetReference("Wishlists"); _ref.Child(UserID).Child(id).RemoveValue(); mAdapter.OnItemDismiss(pos); var text = Resources.GetString(Resource.String.snkbr_rem_wishlist); Snackbar.Make(FindViewById(Android.Resource.Id.Content), product + " " + text, Snackbar.LengthShort).Show(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.layout2); FirebaseAuth mAuth = FirebaseAuth.Instance; FirebaseUser user = mAuth.CurrentUser; if (user == null) { var result = mAuth.SignInAnonymously(); } FirebaseDatabase database = FirebaseDatabase.Instance; dbRef = database.GetReference("mygallery"); FirebaseStorage storage = FirebaseStorage.Instance; //create child reference StorageReference storageRef = storage.Reference; imagesRef = storageRef.Child("images"); Button btn = FindViewById <Button>(Resource.Id.createdb); btn.Click += Btn_Click; }
public void CountWatched() { FirebaseDatabase db = FirebaseDatabase.Instance; DatabaseReference myRef = db.GetReference("SubCategories/" + SubCategory); myRef.RunTransaction(this); }
void Initializedatabase() { var app = FirebaseApp.InitializeApp(this); if (app == null) { var option = new FirebaseOptions.Builder() .SetApplicationId("gndisystem-faf8d") .SetApiKey("AIzaSyClyXwKkJLudsnvwcdkybFGNbXxKZlvCTs") .SetDatabaseUrl("https://gndisystem-faf8d.firebaseio.com") .SetStorageBucket("gndisystem-faf8d.appspot.com") .Build(); app = FirebaseApp.InitializeApp(this, option); database = FirebaseDatabase.GetInstance(app); } else { database = FirebaseDatabase.GetInstance(app); } database = FirebaseDatabase.GetInstance(app); DatabaseReference dbref = database.GetReference("UserSupport"); dbref.SetValue("Ticket2"); Toast.MakeText(this, "Completed", ToastLength.Short).Show(); }
private void PostMessage() { myref = database.GetReference("user"); myref.SetValue(edtChat.Text);//, FirebaseAuth.Instance.CurrentUser.Email); // var items = await firebaseClient.Child("chats").PostAsync(new MessageContent(FirebaseAuth.Instance.CurrentUser.Email, edtChat.Text)); edtChat.Text = ""; }
public async Task <string> SendDialogRequest(string contactAddressP) { string userlogin = contactAddressP.Replace(".", ","); string mylogin = AccountsController.mainAccP.emailP.Replace(".", ","); string dialogName = "Dialog " + userlogin + "+" + mylogin; List <MessageFlags> flags = new List <MessageFlags>(); flags.Add(MessageFlags.Request); List <AccessFlags> acess = new List <AccessFlags>(); acess.Add(AccessFlags.None); if (app == null) { initFireBaseAuth(); } FirebaseDatabase databaseInstance = FirebaseDatabase.GetInstance(app); DatabaseReference userNode = databaseInstance.GetReference(dialogName); FirebaseClient client = new Firebase.Database.FirebaseClient("https://easymessage-1fa08.firebaseio.com/chats/"); var messages3 = await client.Child(dialogName).PostAsync(JsonConvert.SerializeObject( new Message(contactAddressP, AccountsController.mainAccP.emailP, "Пользователь " + AccountsController.mainAccP.emailP + " хочет добавить вас в список контактов", flags, acess))); /*string json = "{'JSON': { \"" + dialogName + "\" : { \"contentP\" : \"Пользователь " + AccountsController.mainAccP.emailP + " " + * "хочет добавить вас в список контактов\", \"receiverP\" : \"" + contactAddressP +"\", \"senderP\" : \"" + * AccountsController.mainAccP.emailP + "\", \"timeP\" : \"" + DateTime.Now.ToString() + "\"}}}";*/ return(dialogName); }
void Initializedatabase() { var app = FirebaseApp.InitializeApp(this); if (app == null) { var options = new FirebaseOptions.Builder() .SetApplicationId("clon-de-uber") .SetApiKey("AIzaSyDqI-di4CM_LTsvyI4meED2aFmrpu-TRFw") .SetDatabaseUrl("https://clon-de-uber-default-rtdb.firebaseio.com") .SetStorageBucket("clon-de-uber.appspot.com") .Build(); app = FirebaseApp.InitializeApp(this, options); database = FirebaseDatabase.GetInstance(app); } else { database = FirebaseDatabase.GetInstance(app); } DatabaseReference dbref = database.GetReference("userSupport"); dbref.SetValue("Ticket1"); Toast.MakeText(this, "Prueba", ToastLength.Short).Show(); }
async Task <DataSnapshot> GetDatabaseAssets(FirebaseDatabase database) { bool done = false; DataSnapshot sc = null; database.GetReference("Assets/Furniture").GetValueAsync().ContinueWith(task => { if (task.IsCompleted) { sc = task.Result; } else { Debug.Log("Could not get assets"); } done = true; }); while (!done) { await Task.Yield(); } return(sc); }
public void Create() { FirebaseDatabase database = AppDataHelper.GetDatabase(); DatabaseReference findDriverRef = database.GetReference("driversAvailable"); findDriverRef.AddListenerForSingleValueEvent(this); }
public void UpdateListLaderBoardBackground() => StartCoroutine(GetAllScoresUsersDesktop()); //StartCoroutine(GetFirstTenUsersMobile()); /** * Only use this when export to Mobile in other way use GetFirstTenUsersDesktop(); * */ private IEnumerator GetFirstTenUsersMobile() { usersList.Clear(); //Instance to get users instance = FirebaseDatabase.DefaultInstance; //Get References to add users dataReference.Child("UsersScore"); //Query 10 people whit the better score instance.GetReference("UsersScore").OrderByChild("score").LimitToLast(10).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { Debug.LogError("Error to get users"); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; foreach (DataSnapshot user in snapshot.Children) { usersList.Add(new UserScore(user.Child("name").Value.ToString(), Convert.ToInt32(user.Child("score").Value), user.Child("time").Value.ToString())); } finish = true; } }); yield return(null); }
void Initializedatabase() { var app = FirebaseApp.InitializeApp(this); if (app == null) { var options = new FirebaseOptions.Builder() .SetApplicationId("uber-clone-43c35") .SetApiKey("AIzaSyAGgpqc9yzcdiCj3GJ-DWXl3xqdY2RB3tA") .SetDatabaseUrl("https://uber-clone-43c35.firebaseio.com") .SetStorageBucket("uber-clone-43c35.appspot.com") .Build(); app = FirebaseApp.InitializeApp(this, options); database = FirebaseDatabase.GetInstance(app); } else { database = FirebaseDatabase.GetInstance(app); } DatabaseReference dbref = database.GetReference("UserSupport"); dbref.SetValue("Ticket1"); Toast.MakeText(this, "Completed", ToastLength.Short).Show(); }
void InitializeDatabase() { var app = FirebaseApp.InitializeApp(this); if (app == null) { var options = new FirebaseOptions.Builder() .SetApplicationId("uber-clone-e56f3") .SetApiKey("AIzaSyAqDADj1AQUgSLpge9ugZZnV21EZUj81WM") .SetDatabaseUrl("https://uber-clone-e56f3-default-rtdb.firebaseio.com/") .SetStorageBucket("uber-clone-e56f3.appspot.com") .Build(); app = FirebaseApp.InitializeApp(this, options); database = FirebaseDatabase.GetInstance(app); } else { database = FirebaseDatabase.GetInstance(app); } DatabaseReference dbref = database.GetReference("UserSupport"); dbref.SetValue("Ticket1"); Toast.MakeText(this, "Completed", ToastLength.Short).Show(); }
void InitializeDatabase() { var app = FirebaseApp.InitializeApp(this); if (app == null) { var options = new FirebaseOptions.Builder() .SetApplicationId("taxi-9a19d") .SetApiKey("AIzaSyDZ6afI8brW-dYiyECqFDLTjP20YI8Ass0") .SetDatabaseUrl("https://taxi-9a19d.firebaseio.com") .SetStorageBucket("taxi-9a19d.appspot.com") .Build(); app = FirebaseApp.InitializeApp(this, options); database = FirebaseDatabase.GetInstance(app); } else { database = FirebaseDatabase.GetInstance(app); } DatabaseReference dbref = database.GetReference("UserSupport"); dbref.SetValue("Ticket1"); Toast.MakeText(this, "completed", ToastLength.Short).Show(); }
public void Create(string ride_id) { FirebaseDatabase database = AppDataHelper.GetDatabase(); DatabaseReference rideDetailsRef = database.GetReference("rideRequest/" + ride_id); rideDetailsRef.AddListenerForSingleValueEvent(this); }
private async void SaveOnDB(string json) { // Save user in Database try { await _database.GetReference("users").Child(_firebaseUser.UserId).SetRawJsonValueAsync(json); Debug.LogFormat("User data saved (DB): {0} ({1})", _firebaseUser.DisplayName, _firebaseUser.UserId); PopupManager.Instance.PrintMessage("User saved in DB: " + FirebaseManager.Instance.User.DisplayName); } catch (AggregateException ex) { Log.ColorError("SetRawJsonValueAsync encountered an error: " + ex.Message + " Data: " + ex.Data.Values, this); PopupManager.Instance.PrintMessage("Saving in DB user error: " + ex.Message); } }