firebase-realtime-database

Set a maximum number of children in Firebase

橙三吉。 提交于 2020-05-23 11:02:50
问题 There are some other (older) questions about this, but since they already are a few years old, I am curious if there have been an update about this. I want to animate a lottery, in which users can buy tickets. Everything is going well, but I want to make sure there are never more than a thousand sold tickets. It has to be server side, and these are my rules: "Lottery": { ".read": "auth != null", ".write": "auth != null", "counter": { ".validate": "newData.isNumber() && newData.val() > 0 &&

How to prevent access to Firebase Realtime Database from browser console?

三世轮回 提交于 2020-05-23 07:18:51
问题 I have this JavaScript code where users sign in to my app using their google account. //firebase db congifurations const config = { apiKey: "my_api_key", authDomain: "my-app.firebaseapp.com", projectId: "my-app", databaseURL: "https://my-app.firebaseio.com", }; //signin callback implemented using - https://developers.google.com/identity/sign-in/web/sign-in function onSignIn(googleUser) { var profile = googleUser.getBasicProfile(); let fullName = profile.getName().split(" "); let userName =

Firebase function (written in NodeJS) to delete file from Cloud Storage when an object is removed from Realtime Database

℡╲_俬逩灬. 提交于 2020-05-23 04:34:04
问题 I am new to NodeJS and I am trying to write the next method for Cloud Functions for Firebase. What I am trying to achieve: The function should be triggered when the user removes a Photo object from Firebase DB; The code should remove the file object from Storage corresponding to the Photo obj. These is my Firebase DB structure: photos/{userUID}/{photoUID} { "dateCreated": "2017-07-27T16:40:31.000000Z", "isProfilePhoto": true, "isSafe": true, "uid": "{photoUID}", "userUID": "{userUID}" } And

Firebase firestore variable name changed

瘦欲@ 提交于 2020-05-21 07:39:08
问题 My firestore variables are saved by other names in cloud firestore. I think this is related to proguard, but I am not getting it. Following are my username. public String id; public String name; public String number; public String profilePic; public String shopPic; and following is the screenshot, what is saved on firestore. Here is some related code, which is very simple FirestoreUrls.get().getAccountsCollection() .document().set(binding.getUser()).addOnCompleteListener(new

Asynchronous Swift call into array

无人久伴 提交于 2020-05-19 02:24:21
问题 Currently I am attempting to push values into an array of note objects from firebase The only issue is due to Firebases asynchronous nature, I am having trouble getting the main thread to wait until the fetch function is completed. I have viewed many answers on this site and I have read up on the Semaphores and Dispatch queue documentation however I cannot get this fetch to work. It appears that most of the people here are attempting to use a table view which I am not. Here is the fetch code

Asynchronous Swift call into array

自闭症网瘾萝莉.ら 提交于 2020-05-19 02:24:04
问题 Currently I am attempting to push values into an array of note objects from firebase The only issue is due to Firebases asynchronous nature, I am having trouble getting the main thread to wait until the fetch function is completed. I have viewed many answers on this site and I have read up on the Semaphores and Dispatch queue documentation however I cannot get this fetch to work. It appears that most of the people here are attempting to use a table view which I am not. Here is the fetch code

Firebase android error “Failed to convert value of type ”

放肆的年华 提交于 2020-05-18 05:29:35
问题 This code is crashing on start; E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.manya.eventspage, PID: 2974 com.google.firebase.database.DatabaseException: Failed to convert value of type java.util.HashMap to String at com.google.android.gms.internal.zzamy.zzcg(Unknown Source) at com.google.android.gms.internal.zzamy.zzb(Unknown Source) at com.google.android.gms.internal.zzamy.zza(Unknown Source) at com.google.firebase.database.DataSnapshot.getValue(Unknown Source) at com.example

Swift -Firebase is it possible to Post and Observe at same time

雨燕双飞 提交于 2020-05-17 09:33:07
问题 When I want to observe I run: let likesRef = Database.database().reference().child("likes").child(postId) likesRef.observeSingleEvent(of: .value, with:{ (snapshot) in let likes = snapshot.childrenCount let totalLikes = Int(likes) // display totalLikes }) When I want to post I run: let dict = [uid: 1] let likesRef = Database.database().reference().child("likes").child(postId) likesRef.updateChildValues(dict) { [weak self](error, ref) in if let error = error { return } // if no error then

google maps run before i fetch my data from firebase hence it crashed

匆匆过客 提交于 2020-05-17 08:11:33
问题 Im fetching lat and lng from firebase but it runs after onMapReady hence when i pass coords to onMapReady it crashed beacause arraylist has nothing I want to run onMapReady after my data is loaded in my arrays private void loadMapPins(){ Query q = FirebaseDatabase.getInstance().getReference("HOSTELS").orderByChild("LOCATION_ID").equalTo(hostelID); q.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { for(DataSnapshot

App crash after remove value of Firebase Database

青春壹個敷衍的年華 提交于 2020-05-17 07:03:15
问题 I have a problem when I try removing values of firebase database, It's works correctly but my app still crashing :/ So I managed to get the code to work which adds a value to "Carte". But now I'm trying with a NumberPicker to remove a certain number of Carte and add entries to something else. Here is my code which adds entries with a loop. if (i == R.id.ParticipCarte1) { FirebaseUser user = mAuth.getCurrentUser(); final NumberPicker np = new NumberPicker(getActivity()); np.setMinValue(1);