firebase-realtime-database

Data not posted on firebase database

泄露秘密 提交于 2019-12-25 14:15:08
问题 I am trying to save new data in firebase under a node President . i have already set some rules on that node. "President":{ "$userId":{ ".write": "auth != null && $userId === auth.uid", ".read": " auth.uid != null" } }, In my app FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); FirebaseUser mFirebaseUser = mFirebaseAuth.getCurrentUser(); FirebaseDatabase mDatabase = FirebaseDatabase.getInstance(); if(mFirebaseUser == null){ }else{ String mUserId = mFirebaseUser.getUid();

A method to store date and time in Android using Firebase?

荒凉一梦 提交于 2019-12-25 12:09:37
问题 I'm new to Android Studio and new to the Firebase database as well. I have created an app but I don't know how to store date and time. Can you help me guys? Here below is my code: public class TimeBookActivity extends AppCompatActivity implements View.OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener { private FirebaseAuth auth; private DatabaseReference databaseReference; Button bnt_picDate_picDate; TextView textView3; int time, day, month, year, hour,

A method to store date and time in Android using Firebase?

白昼怎懂夜的黑 提交于 2019-12-25 12:05:09
问题 I'm new to Android Studio and new to the Firebase database as well. I have created an app but I don't know how to store date and time. Can you help me guys? Here below is my code: public class TimeBookActivity extends AppCompatActivity implements View.OnClickListener, DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener { private FirebaseAuth auth; private DatabaseReference databaseReference; Button bnt_picDate_picDate; TextView textView3; int time, day, month, year, hour,

Checking for child causes poor scalability?

孤街浪徒 提交于 2019-12-25 11:51:03
问题 This isn't a question that nessacarily has a 'solution', but I was wondering if this code would cause memory issues when scaled much larger. ref.child("Teams").observeSingleEvent(of: .value, with: { (snapshot) in if snapshot.hasChild(self.teamName.text!){ //Sets the a single team's values } else { //Displays a missing team alert let alert = UIAlertController(title: "Error" , message: "Team does not exist", preferredStyle: .alert) let actio1n = UIAlertAction(title: "Ok" , style: .cancel ,

OnCompleteListener is not called for .setValue in RealtimeDatabase

可紊 提交于 2019-12-25 11:26:09
问题 I am currently trying to save data to a Firebase Realtime-Database. I just simply want to save data with databaseReference.child("someChild").setValue(someObject); Thread.sleep(1000); and this just works fine. The Object appears in the console, and everything works. But I wondered if there was a smoother implementation, so I tried to use OnCompleteListener and worked out the following code: final AtomicBoolean done = new AtomicBoolean(false); databaseReference.child("someChild") .setValue

Append Firebase chat messages

时光毁灭记忆、已成空白 提交于 2019-12-25 09:43:02
问题 I am creating a chat app and I have a list of all the messages sent between two users in a table view cell. For example, I have four texts in total between the two users and so I have four cells. However, I would like to group the cells so that I only have one cell, because I the loggedInUser is only communicating with one person. No matter what I do, the messages will not append. func loadData(){ if (FIRAuth.auth()?.currentUser) != nil{ FIRDatabase.database().reference().child("messages")

How can I give access to certain objects in Firebase database based on id

谁说胖子不能爱 提交于 2019-12-25 09:41:09
问题 I have this data structure: The red arrows points at animal IDs, and the blue arrow points at user IDs. Every user have one or many animals. I have tried different methods for showing only the animals that have id that is stored in the current user node. Example: If I have UID = 48onHXIxgDP465j5WW16oo7psNm2 (the first one in "users") I want to show the data from: "dog2" and "dog3". Now iIhave the following code that gets snapshot from the "animals" node in the database, and then gets data

Firebase Rules to read Specific Leaf / Child Node from Parent Nodes

会有一股神秘感。 提交于 2019-12-25 09:37:10
问题 My firebase database looks like this "students" : { "firebase_key_1" : { "Name" : "blah blah", "Address" : "blah blah", "Roll No" : "blah blah", "Marks" : { "Sub1" : "blah", "Sub2" : "blah", "Sub3" : "blah", "Total" : "Total", }, "class" : "blah blah", "Transportation" : "blah blah", "Department" : "blah blah", }, "firebase_key_2" : { "Name" : "blah blah", "Address" : "blah blah", "Roll No" : "blah blah", "Marks" : { "Sub1" : "blah", "Sub2" : "blah", "Sub3" : "blah", "Total" : "Total", },

Cloud Functions for Firebase: get actual timestamp of database

房东的猫 提交于 2019-12-25 09:35:03
问题 I need to get the actual timestamp of the firebase database servers instead of the placeholder firebase.database.ServerValue.TIMESTAMP . In order to avoid an XY problem, I will provide my two use cases: a) I have created my own reset password system using cloud functions and JWT. A user requests to reset their password. I sign an object containing their username and the current timestamp(currently using Date.now()) and send it embedded to a link to their email. When they open the link, I need