firebase-realtime-database

Trying to display users information in a recyclerview - Firebase

痴心易碎 提交于 2019-12-24 04:54:10
问题 My app is using Firebase. The user can register and login. In the main activity, there is a menu option called All Users . All I want for now is to display the registered users in a recyclerview. Of course this means that I will have to query the database using mUsersDatabase = FirebaseDatabase.getInstance().getReference().child("Users"); If I put a breakpoint in this line, I can read the users. That's no problem. Next, I use this page to implement the FirebaseRecyclerAdapter The full code is

How to check for data in a child, in a child in Firebase

假如想象 提交于 2019-12-24 04:34:30
问题 The title maybe looks wrong, but its what I am trying to figure out how to do this. My data structure looks like this: I want to look if there are users presented in every channel. This will work to check if there are channels: channelRef.observeSingleEvent(of: .value, with: { (snapshot) -> Void in for channelSnap in snapshot.children { let channelData = (channelSnap as! FIRDataSnapshot).value as! Dictionary<String, AnyObject> if let name = channelData["name"] as! String!, name.characters

Firebase RTD, atomic “move” … delete and add from two “tables”?

☆樱花仙子☆ 提交于 2019-12-24 04:34:05
问题 In Firebase Realtime Database, it's a pretty common transactional thing that you have "table" A - think of it as "pending" "table" B - think of it as "results" Some state happens, and you need to "move" an item from A to B. So, I certainly mean this would likely be a cloud function doing this. Obviously, this operation has to be atomic and you have to be guarded against racetrack effects and so on. So, for item 123456, you have to do three things read A/123456/ delete A/123456/ write the

Saving a Dictionary of key-values in Firebase using Swift

大城市里の小女人 提交于 2019-12-24 03:41:36
问题 This question is a follow up from: Post Array to firebase Database in Swift I am trying to save some ingredients into a recipe and later be able to retrieve the entire recipe with the ingredients inside it. After looking at the question above and this blog post https://firebase.googleblog.com/2014/04/best-practices-arrays-in-firebase.html. I was able to re-structure my database This is my Ingredient Dictionary: { "IngredientDict": { "-KkbWdomTYdpgEDLjC9w": "Eggs", "-KkbWvaa5DT1PY7q7jIs":

Firebase onDataChange not called when offline

拟墨画扇 提交于 2019-12-24 03:00:53
问题 I am having a very weird situation regarding Firebase ValueEventListener. When the phone is connected to the internet, it works fine. But when it is offline, it is not calling onDataChange. This piece of code works great even when it is offline. mDatabase = FirebaseDatabase.getInstance() .getReference() .child(Database.PLACES) .child(((BaseActivity) getActivity()).getUserId()); Timber.d("TRYING TO GET PLACES"); mDatabase.addValueEventListener(new ValueEventListener() { @Override public void

How to filter by orderByChild containing a string in Firebase query-based rules

浪子不回头ぞ 提交于 2019-12-24 02:56:08
问题 I want to get all the users that are friends of the logged user. This is my data structure. { "users": { "UID1":{ "name":"Pepito", "friends":{ "UID2":true, "UID4":true, } } ... } } I am getting the users with this code Firebase.database.reference().child("users") .orderByChild("friends/" + Firebase.user.uid).equalTo(true) And the rules should be { "rules": { "users" : { ".read" : "query.orderByChild.contains('friends/')", "$uid" : { ".write": "auth.uid == $uid", } } } } But the rules not

loading chats from firebase Swift

久未见 提交于 2019-12-24 02:39:18
问题 I am doing a chat messenger currently and I am able to retrieve all the messages I sent to another user but not able to retrieve whatever they sent. The codes i used to load my messages is func loadMsg() { let toId = user!.id! let fromId = Auth.auth().currentUser!.uid let ref = Database.database().reference().child("privateMessages").child(fromId).child(toId) ref.observe(.value) { (snapshot) in if let snapshot = snapshot.children.allObjects as? [DataSnapshot] { self.messages.removeAll() for

firebase multi-location updates user authentication and database

点点圈 提交于 2019-12-24 02:23:55
问题 I have a Form to signup new User with email, password, full name and phone number. I can use firebase.auth().createUserWithEmailAndPassword to create new user if successfully. Then I use firebase.database().ref('users/..').set(..) to save fullname and phone number to firebase database. But If the saving processing to database occur error (By rule write:false for example), I STILL have an user Identifier created in User Authentication. So an user exist without phone number and full number. How

send notification when new child is added to Firebase database

我们两清 提交于 2019-12-24 02:22:19
问题 I am using Firebase database in my app, and I need to send a notification to the Admin when a new order is added to the database "new child added to the database". I found something called Firebase cloud messaging but I don't know how to use it. Any help, please? 回答1: The Firebase Cloud Messaging is used to send push notification to a devices or a group of devices.The thing that you want to achive can be implemented by using Cloud Functions for more details HERE Codelab You need to specify a

Firebase query with wrong data doesn't give any call back [duplicate]

孤者浪人 提交于 2019-12-24 01:58:14
问题 This question already has an answer here : how to know if firebase ChildEventListener found child ? [android] (1 answer) Closed 3 years ago . I have created a table in firebase and saved couple of data and want to query specific data by specifying inputs like where condition in Sqlite : Query queryRef = ref.orderByChild("name").equalTo(username); queryRef.addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChild) { // i