firebase-realtime-database

Can Swift 4's JSONDecoder be used with Firebase Realtime Database?

£可爱£侵袭症+ 提交于 2020-12-24 06:48:24
问题 I am trying to decode data from a Firebase DataSnapshot so that it can be decoded using JSONDecoder. I can decode this data fine when I use a URL to access it with a network request (obtaining a Data object). However, I want to use the Firebase API to directly obtain the data, using observeSingleEvent as described on this page. But, when I do this, I cannot seem to convert the result into a Data object, which I need to use JSONDecoder. Is it possible to do the new style of JSON decoding with

Can Swift 4's JSONDecoder be used with Firebase Realtime Database?

旧巷老猫 提交于 2020-12-24 06:47:04
问题 I am trying to decode data from a Firebase DataSnapshot so that it can be decoded using JSONDecoder. I can decode this data fine when I use a URL to access it with a network request (obtaining a Data object). However, I want to use the Firebase API to directly obtain the data, using observeSingleEvent as described on this page. But, when I do this, I cannot seem to convert the result into a Data object, which I need to use JSONDecoder. Is it possible to do the new style of JSON decoding with

Check if value in Firebase Realtime Database is equal to String [duplicate]

馋奶兔 提交于 2020-12-23 08:21:04
问题 This question already has an answer here : Android Firebase Checking if Data is Equal To String (1 answer) Closed last year . When a user logs in on my application, I want to check if the userType is a "Customer" or a "Venue Owner". This decides which activity is run next. Currently, the application crashes when attempting to log in. Here is my Firebase Realtime database structure: Here is the related code: public void loginUser(View v) { if(e1.getText().toString().equals("") && e2.getText()

Check if value in Firebase Realtime Database is equal to String [duplicate]

我只是一个虾纸丫 提交于 2020-12-23 08:19:26
问题 This question already has an answer here : Android Firebase Checking if Data is Equal To String (1 answer) Closed last year . When a user logs in on my application, I want to check if the userType is a "Customer" or a "Venue Owner". This decides which activity is run next. Currently, the application crashes when attempting to log in. Here is my Firebase Realtime database structure: Here is the related code: public void loginUser(View v) { if(e1.getText().toString().equals("") && e2.getText()

Firebase database listeners don't work on android with wifi

走远了吗. 提交于 2020-12-23 04:18:00
问题 In my code user signs in to Firebase with Google like explained in: https://firebase.google.com/docs/auth/android/google-signin This works fine. When a user opens the program, it loads the initialization values from the firebase database. Here is the code: private void loadPrefsFromDB() { mAuth = FirebaseAuth.getInstance(); user = mAuth.getCurrentUser(); uid = user.getUid(); FirebaseDatabase.getInstance().getReference().child("users").child(uid) .addListenerForSingleValueEvent(new

Firebase database listeners don't work on android with wifi

徘徊边缘 提交于 2020-12-23 04:17:21
问题 In my code user signs in to Firebase with Google like explained in: https://firebase.google.com/docs/auth/android/google-signin This works fine. When a user opens the program, it loads the initialization values from the firebase database. Here is the code: private void loadPrefsFromDB() { mAuth = FirebaseAuth.getInstance(); user = mAuth.getCurrentUser(); uid = user.getUid(); FirebaseDatabase.getInstance().getReference().child("users").child(uid) .addListenerForSingleValueEvent(new

Firebase Realtime database: Does 'value' event fires automatically

眉间皱痕 提交于 2020-12-16 04:59:44
问题 As I understand, when this following line of code is interpreted/executed by Javascript ref.on('value',callback) (similar to document.addEventListener('click', callback) ). The callback gets attached to the el/object for that event such that when that event executes then the attached callback (event handler) gets fired. But I observe that firebase 'value' event will automatically fire when there is some data at this ref , when the above line of code is interpreted/executed by Javascript even

Firebase Realtime database: Does 'value' event fires automatically

久未见 提交于 2020-12-16 04:59:13
问题 As I understand, when this following line of code is interpreted/executed by Javascript ref.on('value',callback) (similar to document.addEventListener('click', callback) ). The callback gets attached to the el/object for that event such that when that event executes then the attached callback (event handler) gets fired. But I observe that firebase 'value' event will automatically fire when there is some data at this ref , when the above line of code is interpreted/executed by Javascript even

Firestore document creation fails without an error

孤者浪人 提交于 2020-12-15 06:41:55
问题 Edit3: Okay, it seems like it's an issue with Firebase, someone else tweeted about having the same issue. I also contacted support. A piece of Swift code that handles creating documents suddenly stopped working. No errors are thrown, Firebase doesn't complain in the log and I can verify from the console that the document is not created, I can verify that the device has a healthy internet connection. I also disabled offline persistence for Firebase just to be sure. When I try debugging it, the

How can I sort chat list by the most recent message?

流过昼夜 提交于 2020-12-15 05:27:11
问题 I don't know why I got stuck on a problem that the chatList is not sorting by the last message time or by the most recent message. I have tried by storing timestamp in the database and orderChildBy timestamp but it still not working. This is the way how I created chatList in the firebaseDatabase val timeAgo = Date().time val myTimeMap = HashMap<String, Any?>() myTimeMap["timestamp"] = timeAgo.toString() myTimeMap["id"] = friendId val friendTimeMap = HashMap<String, Any?>() friendTimeMap[