/// <summary> /// Listen to OtherCards database for new shared cards /// </summary> public async void initialize() { string userID = await AcrDialogUtilities.promptInput("Input User ID"); if (userID == "") { return; } // FirebaseDatabase - get cards shared with userID FirebaseDatabase database = FirebaseDatabase.Instance; DatabaseReference dr_userCardListItem = database.GetReference("Users").Child(userID).Child("OthersCards"); Query sharedCardsQuery = dr_userCardListItem.LimitToFirst(100); sharedCardsQuery.AddChildEventListener(new FirebaseChildListener(this)); }
public async void uploadCard(Card card) { // TODO HARDCODED USER ID string userID = await AcrDialogUtilities.promptInput("Input User ID"); string sendToUserID = await AcrDialogUtilities.promptInput("Input Share to User ID"); if (userID == "" || sendToUserID == "") { return; } // FirebaseDatabase - Update userID with card FirebaseDatabase database = FirebaseDatabase.Instance; DatabaseReference dr_curUser = database.GetReference("Users").Child(userID); DatabaseReference dr_curUserCards = dr_curUser.Child("MyCards"); DatabaseReference dr_curCard = dr_curUserCards.Push(); // Unique card ID generated dr_curCard.Child("Name").SetValue(card.name); dr_curCard.Child("UploadFinished").SetValue(false); dr_curCard.Child("MediaNames").SetValue(stringifyCardMediaNames(card)); // FirebaseDatabase - Update sendToUserID with card DatabaseReference dr_userCardListItem = database.GetReference("Users").Child(sendToUserID).Child("OthersCards").Push(); dr_userCardListItem.Child("FromUserID").SetValue(userID); dr_userCardListItem.Child("CardID").SetValue(dr_curCard.Key); dr_userCardListItem.Child("MediaNames").SetValue(stringifyCardMediaNames(card)); dr_userCardListItem.Child("Name").SetValue(card.name); // FirebaseStorage - Store card FirebaseStorage storage = FirebaseStorage.Instance; StorageReference sr_cud = storage.GetReference("Users").Child(userID); StorageReference sr_curCard = sr_cud.Child(dr_curCard.Key); // Use unique card ID StorageReference sr_cardMedias = sr_curCard.Child("Media"); uploadCardMedia(sr_cardMedias, card); // Mark upload finished dr_curCard.Child("UploadFinished").SetValue(true); }