firebase-realtime-database

Firebase Realtime Database addValueEventListener

好久不见. 提交于 2019-12-23 22:17:51
问题 I have set setPersistenceEnabled to true and I am using a addValueEventListener and inside that a onDataChange method. Will my app always download the data from server every time that method is called or will my app get the data from the cache if available? When I am offline I am sure that the data comes from the cache. #askFirebase 回答1: When you attach a listener with addValueEventListener() and the data is available in the local disk cache, the onDataChange() method will immediately fire

Update Marker when Location Change based on Value of Child Firebase Android

谁说我不能喝 提交于 2019-12-23 22:12:03
问题 I need help with Firebase database. What I'm trying to do is to display all users from AvailableWorkers (e.g, N2GCEIGYBaRiNrFPawklx1NymF3, ruN5PaZC0WNZYm6YJrRtbQVXOoH2) on my maps. Here's a screenshot of the Firebase Database Here's my current code: private void loadAllAvailableWorkers(final LatLng location) { //Delete markers on the map including client location and available workers mMap.clear(); //After delete, add location back mMap.addMarker(new MarkerOptions() .position(location) .icon

Firebase Authentication: Verify email before sign up

∥☆過路亽.° 提交于 2019-12-23 22:00:47
问题 Here is my idea: After registing, an email will be sent to the user. After the user verifies the email, the new account with user's info will be added to Firebase. If not, the account won't be added. But i don't know how to do it. Here is my code: auth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { FirebaseUser user = auth

Cannot read property 'user_id' of undefined

你说的曾经没有我的故事 提交于 2019-12-23 22:00:35
问题 I want to send device to device push notification through firebase cloud functions. I am writing node.js script exports.sendNotification = functions.database.ref('/messages/{user_id}/{rec_user_id}').onWrite((event) => { const sender_user_id = event.params.user_id; const receiver_user_id = event.params.rec_user_id; console.log('We have a notification from : '+ sender_user_id+ " | Receiced by " + receiver_user_id); return; }); After deploying function on firebase cloud i got an error TypeError:

Android Firebase database transaction

牧云@^-^@ 提交于 2019-12-23 20:14:57
问题 ATNRef= FirebaseDatabase.getInstance().getReference("AvailableTokenNumber"); ATNRef.runTransaction(new Transaction.Handler() { @Override public Transaction.Result doTransaction(MutableData mutableData) { if (mutableData.getValue(int.class ) == 0){ mutableData.setValue(2); data.tokenNo = 1; return Transaction.success(mutableData); }else { data.tokenNo=mutableData.getValue(int.class); mutableData.setValue(data.tokenNo + 1); return Transaction.success(mutableData); } } Whenever the code is run

Firebase: Listening to multiple user nodes

谁说我不能喝 提交于 2019-12-23 19:55:30
问题 I'm working on an app using Firebase and Geofire. On running the Geo query at the current location, let's say I receive 10 keys in the OnKeyEntered override method. Each of these keys is essentially a user node in Firebase. I need to listen to each of the user in the query area for any data change so that I can show updates on the map in realtime. Currently, I'm adding a ValueEventListener for every key entered but I'm not sure if starting so many listeners at the same time is good idea. The

Firebase Android delete node key in ListView on longpress

假装没事ソ 提交于 2019-12-23 19:44:46
问题 Tried to search a lot but after 2 days I'm still stucked on this problem. I have the following database in my Firebase which is populated in my ListView . For each row in the ListView is displayed data1 and data2. test-3db7e | +---users | +---W9KkXAidmHgyOpyeQPeT5YxgQI42 | +---data | | | +----LIv-OeQdixT0q6NZ-jL | | | | | +---data1: "Data1" | | | | | +---data2: "Data2" | | | +----LIv-R3PRKaEHaAcMjWu | | | +---data1: "Data1" | | | +---data2: "Data2" | +---name: "The user's name" Until now it

Gradle must have Dependency on com.google.firebase:firebase-core for Firebase services to work as intended [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-23 19:35:07
问题 This question already has an answer here : Do I need Firebase Core for Firebase Database? (1 answer) Closed last year . While compiling I'm getting a warning like this, The app Gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended. just add the below line updated implementation 'com.google.firebase:firebase-core:17.0.0' 回答1: I think your gradle has the below implementation missing. Add this to your app level build.gradle . com.google

How to ensure that the execution of functions are in order?

六眼飞鱼酱① 提交于 2019-12-23 18:56:27
问题 I have a HTTP-triggered function which returns an increment number every time the endpoint is called. The code looks like this: export const reserve = functions.https.onRequest((req, resp) => { cors(req, resp, async () => { if (req.method.toLowerCase() !== 'post') { resp.status(405); resp.end(); } else { const path = `counter`; const ref = firebase.database().ref(path); const oldCount = (await ref.once('value')).val(); await ref.set(oldCount + 1); resp.status(200).send({ number: oldCount });

Firebase database getInstance crash

帅比萌擦擦* 提交于 2019-12-23 18:50:34
问题 I've seen numerous questions asking why an app crashes with the following error log : Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object. I configured firebase through Android studio. I still encounter the error. I believe there's no error with the google-services.json file as this was auto created by Android Studio. Any help would be appreciated! I'd be glad to add more details about any piece of code that I'm asked to supply. EDIT :