firebase-realtime-database

Swift Showing last sent message in chat using firebase

一笑奈何 提交于 2020-01-06 14:37:12
问题 I am trying to show my last sent message on my home screen of the chat messenger, from storyboard it looks like : and the code I used are: func getAllMsg() { self.users = [] let fromId = Auth.auth().currentUser!.uid let ref = Database.database().reference().child("privateMessages").child(fromId) ref.observeSingleEvent(of: .value) { (snapshot) in for snap in snapshot.children.allObjects as! [DataSnapshot] { // retrieving receiver's ID let chatUserID = snap.key let ref2 = Database.database()

Firebase Database overwrites previous value with setValue()

余生颓废 提交于 2020-01-06 12:47:30
问题 So I have a Database in Firebase. This code is in onCreate(): DatabaseReference mDatabaseRefUser =FirebaseDatabase.getInstance().getReference("Users"); This code is in another method that gets called onClick: mDatabaseRefUser.child("Chat").child(mAuth.getCurrentUser().getUid()) .child(userID).child(uploadID).child("Messages").push().setValue(new ChatMessage(addMessageEditText.getText().toString(), mAuth.getCurrentUser().getEmail())); mDatabaseRefUser.child("Chat").child(userID) .child(mAuth

Firebase Database overwrites previous value with setValue()

我的未来我决定 提交于 2020-01-06 12:47:10
问题 So I have a Database in Firebase. This code is in onCreate(): DatabaseReference mDatabaseRefUser =FirebaseDatabase.getInstance().getReference("Users"); This code is in another method that gets called onClick: mDatabaseRefUser.child("Chat").child(mAuth.getCurrentUser().getUid()) .child(userID).child(uploadID).child("Messages").push().setValue(new ChatMessage(addMessageEditText.getText().toString(), mAuth.getCurrentUser().getEmail())); mDatabaseRefUser.child("Chat").child(userID) .child(mAuth

How to check value in realtime database (ON/OFF)

我们两清 提交于 2020-01-06 11:17:08
问题 How i can in this code @Override protected void onStart() { super.onStart(); //if the user is already signed in //we will close this activity //and take the user to profile activity if (mAuth.getCurrentUser() != null) { finish(); startActivity(new Intent(this, ActivitySplash.class)); } } make check whether the child (userId) is set to ON / OFF and if ON then we run the code if (mAuth.getCurrentUser() != null) { finish(); startActivity(new Intent(this, ActivitySplash.class)); } if OFF then we

java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible

こ雲淡風輕ζ 提交于 2020-01-06 09:56:35
问题 My error is: Task exception on worker thread: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/android.myland.com.land-1/base.apk): com.google.android.gms.measurement.internal.zzt.zzEd(Unknown Source) This is pro level: dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.1.0' }

java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible

一曲冷凌霜 提交于 2020-01-06 09:55:09
问题 My error is: Task exception on worker thread: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/android.myland.com.land-1/base.apk): com.google.android.gms.measurement.internal.zzt.zzEd(Unknown Source) This is pro level: dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.1.0' }

Create new path in Firebase Realtime Database programmatically?

有些话、适合烂在心里 提交于 2020-01-06 09:05:31
问题 In Firebase documentation I don't found the anweser. How to add a new path in real-time database programmatically in Javascript? Like (just an example): standard path: https://testapp.firebaseio.com/ And in the app I want to say something like: If this, then create a path like this: https://testapp.firebaseio.com/info/important/personal 回答1: Keys and paths in the Firebase Database are automatically created when you write a value to them. So to generate the path info/important/personal , you

How to update multiple children under child node using a transaction?

*爱你&永不变心* 提交于 2020-01-06 08:44:48
问题 Here's my data structure, how it is organized (firebase database): -database -productsList -item1: 0 -item2: 0 -item3: 0 -item4: 0 -orders -order1: -... -order2: -... -... I'm building a shopping app that has a list of products. Customers can choose what they want to buy and make an order. When they do the product's quantities would increase based on what they've chosen. Say a customer chose to buy 2 units of item2 e 5 units of item4, when one sends a request it will write at a different

How to update multiple children under child node using a transaction?

别来无恙 提交于 2020-01-06 08:44:07
问题 Here's my data structure, how it is organized (firebase database): -database -productsList -item1: 0 -item2: 0 -item3: 0 -item4: 0 -orders -order1: -... -order2: -... -... I'm building a shopping app that has a list of products. Customers can choose what they want to buy and make an order. When they do the product's quantities would increase based on what they've chosen. Say a customer chose to buy 2 units of item2 e 5 units of item4, when one sends a request it will write at a different

Firebase ListView is not updating in real time

∥☆過路亽.° 提交于 2020-01-06 08:43:14
问题 When I make changes to the data which is displayed using ListView and DataSnapshot the data is not refreshed in real time until I restart the Activity . The ListView loads and displays all the data without any problem. Why is this happening and how to solve this ? MainMenuRequest.java public class MainMenuRequest extends AppCompatActivity { String UserNameString; DatabaseReference db; ListView lv; ArrayList<RequestItem> list = new ArrayList<>(); RequestItemAdapter adapter; @Override protected