firebase-realtime-database

How to read / query data from one userID Firebase Android

随声附和 提交于 2019-12-25 08:16:20
问题 I want to retrieve data for a given user ID, which I am storing as a value in the database under each user. My database structure looks like below: user: { UserID: { uniqueId: { Name: "" Email: "" userId: "" } UserID: { uniqueId: { Name: "" Email: "" userId: "" } } I tried this but it doesn't seem to work as it doesn't display anything on the app: FirebaseUser user = mAuth.getCurrentUser(); df.child("UsersTable").orderByChild("userid").equalTo(user.getUid())).addChildEventListener even when I

Firebase ,Swift: `runTransactionBlock()` returns null

孤街浪徒 提交于 2019-12-25 08:12:52
问题 Every time i run runTransactionBlock it Gives me null , Although there is a node at that location:- FIRMutableData (top-most transaction) (null) at the line :- print(totalPost) func updateTotalNoOfPost(){ let prntRef = FIRDatabase.database().reference().child("TotalPosts") prntRef.observeSingleEventOfType(.Value, withBlock: {(totalSnap) in if totalSnap.exists(){ prntRef.child("noOfTotalPost").runTransactionBlock({ (totalPost: FIRMutableData) -> FIRTransactionResult in print(FIRAuth.auth()!

How to run ObverveEventType in Main Thread?

删除回忆录丶 提交于 2019-12-25 08:09:31
问题 In Swift, I am using an observerEventType to retrieve snapshot data from Firebase, and return it in a function. But it appears that the data isn't being saved from the snapshot. func checkAmount() -> Int { var amount = -1 dispatch_async(dispatch_get_main_queue(), { () -> Void in self.rootRef.child("users/").child(NSUserDefaults.standardUserDefaults().stringForKey("id")!).observeEventType(FIRDataEventType.Value, withBlock: { (snapshot) in Amount = (snapshot.value!.objectForKey("CoinAmount") as

Type 'String' has no compatible call signatures

家住魔仙堡 提交于 2019-12-25 08:09:10
问题 I'm trying to do a multi-path update using Firebase and AngularFire2. However, I'm getting the error above when I use this: let fb = firebase.database().ref(); let key = fb.child('/path').push().key(); Any ideas of how I can get the key after pushing something using AngularFire2? 回答1: As the push method now returns an Observable, the proper way to get the generated $key (using AF2) is doing the following: let fb = this.af.database.list('/path'); fb.push('item').then(res => console.log(res.key

Getting images from Firebase JSON

你。 提交于 2019-12-25 08:08:31
问题 I was wondering if it were possible to fetch an image from the Firebase Database? I know that I can use the storage but for my particular situation it needs to be altered a lot and would be a lot easier if I could enter in the information into the JSON tree and fetch it that way. So in short, my question is can I use the URL from the storage section of Firebase and copy and paste that into a child in the JSON tree and retrieve it as I would any other number or string in the database? Every

Red lines in Android Studio with Firebase

筅森魡賤 提交于 2019-12-25 08:04:05
问题 I am trying to connect Android Studio with Firebase and I have some red lines and I don't know why. I am following instruction from this tutorial : https://www.youtube.com/watch?v=tOn5HsQPhUY Could someone please tell me if I am doing something wrong and what? Here is a picture of this 回答1: the Problem is that these commands are from an older firebase Version. I recommend to take a look at the docs here:https://firebase.google.com/docs/database/android/start/ Try this code : private

Firebase getChildrenCount() is counting deleted data

青春壹個敷衍的年華 提交于 2019-12-25 07:59:19
问题 I have a parent node "posts" and i need to get the number of children under this parent. I delete the whole "posts" node itself. Re-create "posts" with 1 children inside of it. using .getChildrenCount() of the snapshot from databaseRef.children("posts") .getChildrenCount() return 12 (suppose to be 1 at this point of time) Repeat step 1 - 4. This time the .getChildrenCount() return 13. This above trial shows that the deleted children is still affecting the count. Perhaps there is an internal

Firebase Value Event Listener

放肆的年华 提交于 2019-12-25 07:46:26
问题 I want to read the values from Firebase Database and show in a ListView. But something gone wrong. It's not giving correct values. Here is the code: Java final FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference reference = database.getReference("Stats").child(ders); reference.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { stats.put(dataSnapshot.getKey(), dataSnapshot.getValue().toString());

How to receive latitude and longitude data stored from Firebase and put it in a marker

北战南征 提交于 2019-12-25 07:45:37
问题 I'm making an app with firebase and google maps But I'm implementing this: In the AddActivity activity, you set the latitude and longitude by clicking on a certain part of the map by placing a marker When you press the "send" button these data are sent to the firebase And I would like to rescue the data of that marker that was sent as the title, And that it is placed in the map of the MainActivity with the latitude and longitude that is in the firebase This is how my database is organized I

Are Firebase Object Keys Guessable?

心不动则不痛 提交于 2019-12-25 07:44:59
问题 Say I have data like so: users{ $authId: { name:"", propertiesById:{ uniqueId1:true, uniqueId2:true } } }, properties:{ uniqueId1:{ key:val }, uniqueId2:{ key:val } } Assuming that I have the proper rules in place for users to be able to only read/write their own user object, how do I go about reading my properties safely? I know that in rules, I can go to root, find the user object and ensure that the property that I'm trying to read exists in the propertiesById, but that seems like it would