15,682 questions
307
votes
8
answers
271k
views
Query based on multiple where clauses in Firebase
{
"movies": {
"movie1": {
"genre": "comedy",
"name": "As good as it gets",
"lead": "Jack Nicholson&...
61
votes
6
answers
47k
views
How to return DataSnapshot value as a result of a method?
I don't have much experience with Java. I'm not sure if this question is stupid, but I need to get a user name from Firebase realtime database and return this name as a result of this method. So, I ...
891
votes
10
answers
327k
views
Is it safe to expose Firebase apiKey to the public?
The Firebase Web-App guide states I should put the given apiKey in my Html to initialize Firebase:
// TODO: Replace with your project's customized code snippet
<script src="https://www.gstatic....
83
votes
2
answers
31k
views
Firebase query if child of child contains a value
The structure of the table is:
chats
--> randomId
-->--> participants
-->-->--> 0: 'name1'
-->-->--> 1: 'name2'
-->--> chatItems
etc
What I am trying to do is query the chats table to find all the ...
16
votes
1
answer
5k
views
getContactsFromFirebase() method return an empty list
public List<String> getContactsFromFirebase(){
FirebaseDatabase.getInstance().getReference().child("Users")
.addListenerForSingleValueEvent(new ValueEventListener() {
...
33
votes
4
answers
10k
views
Why does my function that calls an API or launches a coroutine return an empty or null value?
(Disclaimer: There are a ton of questions which arise from people asking about data being null/incorrect when using asynchronous operations through requests such as facebook,firebase, etc. My ...
113
votes
1
answer
31k
views
Speed up fetching posts for my social network app by using query instead of observing a single event repeatedly
I have an array of keys which lead to post objects for my social network like so /posts/id/(post info)
When I load the posts I load /posts/0 and then /posts/1 etc using the observeSingleEventOfType(....
30
votes
2
answers
13k
views
How to return a DocumentSnapShot as a result of a method?
A custom object that takes a parameter of (DocumentSnapShot documentsnapShot). also is an inner object from Firebase that retrieves a snapshot and set the values to my custom model also have its ...
40
votes
3
answers
39k
views
Firebase Query Double Nested
Given the data structure below in firebase, i want to run a query to retrieve the blog 'efg'. I don't know the user id at this point.
{Users :
"1234567": {
name: 'Bob',
...
590
votes
32
answers
637k
views
How to handle notification when app in background in Firebase
Here is my manifest:
<service android:name=".fcm.PshycoFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT&...
29
votes
3
answers
20k
views
Setting Singleton property value in Firebase Listener
I'm currently testing out Firebase along with a Singleton model I plan to use to access during the lifecycle of the whole app. I'm now stuck with something that seems really trivial but I can't figure ...
16
votes
6
answers
57k
views
How to send one to one message using Firebase Messaging
I have been trying to read the official docs and guides about how to send message from one device to another. I have saved registration token of both devices in the Real Time Database, thus I have the ...
127
votes
3
answers
63k
views
Cloud Functions for Firebase trigger on time?
I am looking for a way to schedule Cloud Functions for Firebase or in other words trigger them on a specific time.
13
votes
4
answers
13k
views
How can I retrieve data from Firebase to my adapter
My structure
So I have an app in which users upload posts in my adapter. I can retrieve the post description and the post picture, but when I try to retrieve the poster's name the app seems to crash, ...
43
votes
15
answers
132k
views
How to get URL from Firebase Storage getDownloadURL
I'm trying to get the "long term persistent download link" to files in our Firebase storage bucket.
I've changed the permissions of this to
service firebase.storage {
match /b/project-xxx.appspot....
203
votes
27
answers
150k
views
Get Download URL from file uploaded with Cloud Functions for Firebase
After uploading a file in Firebase Storage with Functions for Firebase, I'd like to get the download url of the file.
I have this :
...
return bucket
.upload(fromFilePath, {destination: ...
19
votes
1
answer
12k
views
Firestore whereEqualTo, orderBy and limit(1) not working
I want to query my Workout Collection for the latest workout from a routine. Meaning I query with whereEqualTo my routineKey, order it by the Started TimeStamp in descending order and then limit to 1 ...
82
votes
6
answers
59k
views
Android app not receiving Firebase Notification when app is stopped from multi-task tray
I have read a similar question on SO, however, I was not able to get the correct answer from it.
I have a system wherein we send notification to around 500 devices.
Unfortunately, many of these ...
131
votes
20
answers
159k
views
How to get a list of all files in Cloud Storage in a Firebase app?
I'm working on uploading images, everything works great, but I have 100 pictures and I would like to show all of them in my View, as I get the complete list of the images in a folder, I can not find ...
46
votes
3
answers
28k
views
Many to Many relationship in Firebase
I have a Firebase database. I have Companies and Contractors. A Contractor can work for more than one Company and a Company can have multiple Contractors. This is a straightforward many to many ...
39
votes
4
answers
27k
views
Firebase android : make username unique
Parse will shut down at the end of the year, so I decided to start using Firebase. I need to implement a register process with 3 fields : email, username, password (Email & username must be unique ...
16
votes
3
answers
14k
views
How to return a list from Firestore database as a result of a function in Kotlin?
I'm building an app for a friend and I use Firestore. What I want is to display a list of favorite places but for some reason, the list is always empty.
I cannot get the data from Firestore. This is ...
67
votes
4
answers
19k
views
Firebase Offline Capabilities and addListenerForSingleValueEvent
Whenever I use addListenerForSingleValueEvent with setPersistenceEnabled(true), I only manage to get a local offline copy of DataSnapshot and NOT the updated DataSnapshot from the server.
However, if ...
44
votes
2
answers
9k
views
How to write denormalized data in Firebase
I've read the Firebase docs on Stucturing Data. Data storage is cheap, but the user's time is not. We should optimize for get operations, and write in multiple places.
So then I might store a list ...
82
votes
21
answers
47k
views
Firebase kicks out current user
So I have this issue where every time I add a new user account, it kicks out the current user that is already signed in. I read the firebase api and it said that "If the new account was created, the ...
31
votes
5
answers
20k
views
Firebase UI authentication with google fails with message (code:10 message:10)
I've made a chat app that uses Firebase's feature Real-time database.
I face a problem with google authentication. The problem started when I downloaded the app from the Play Store, the authentication ...
29
votes
3
answers
15k
views
How to paginate Firestore with Android?
I read Firestore documentation and all articles on internet(stackoverflow) about Firestore pagination but no luck. I tried to implement the exact code in docs, but nothing happens. I have a basic ...
39
votes
4
answers
19k
views
Best way to manage Chat channels in Firebase
In my main page I have a list of users and i'd like to choose and open a channel to chat with one of them.
I am thinking if use the id is the best way and control an access of a channel like USERID1-...
211
votes
17
answers
108k
views
Google Firestore - How to get several documents by multiple ids in one round-trip?
I am wondering if it's possible to get multiple documents by a list of ids in one round trip (network call) to the Firestore database.
101
votes
17
answers
67k
views
Firestore: How to get random documents in a collection
It is crucial for my application to be able to select multiple documents at random from a collection in firebase.
Since there is no native function built in to Firebase (that I know of) to achieve a ...
510
votes
29
answers
479k
views
No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase
I am building a Flutter application and I have integrated Firebase, but I keep getting this error when I click on a button either to register, login, or logout. I have seen other people have asked the ...
81
votes
14
answers
89k
views
How to send device to device messages using Firebase Cloud Messaging?
After searching the docs I could not find any info on how to send device to device messages using FCM without the use of an external server.
For example, if I was creating a chat application I would ...
10
votes
1
answer
7k
views
How to check a certain data already exists in firestore or not
Before adding a new data into the firestore, i want to check already a data of the same kind exists in the database or not.if already a data was present means i want to prevent the user from entering ...
57
votes
3
answers
27k
views
Restricting child/field access with security rules
I'm writing an app that allows users to submit nominations which are moderated before being displayed to other users. This requires a number of restrictions I've so far been unsuccessful in ...
62
votes
13
answers
31k
views
How to perform compound queries with logical OR in Cloud Firestore?
From the docs:
You can also chain multiple where() methods to create more specific queries (logical AND).
How can I perform an OR query?
Example:
Give me all documents where the field status is ...
3
votes
5
answers
11k
views
How to use getdownloadurl in recent versions?
Uri downloaduri=taskSnapshot.getDownloadUrl();//here i cant use getdownloadurl() function
DatabaseReference new_prod=db.push();
new_prod.child("product name").setValue(...
287
votes
35
answers
284k
views
Enabling CORS in Cloud Functions for Firebase
I'm currently learning how to use new Cloud Functions for Firebase and the problem I'm having is that I can't access the function I wrote through an AJAX request. I get the "No 'Access-Control-...
200
votes
14
answers
227k
views
Why is my React component is rendering twice?
I don't know why my React component is rendering twice. So I am pulling a phone number from params and saving it to state so I can search through Firestore. Everything seems to be working fine except ...
34
votes
2
answers
18k
views
How do you prevent duplicate user properties in Firebase?
I'm Using FirebaseSimpleLogin to create users and handle authentication.
When I try and create a new user with simple login via the $createUser() method, firebase won't create the user if the email ...
6
votes
1
answer
11k
views
How to get the download url from Firebase Storage?
I want to get the Download Url from uploadTask.addOnProgressListener method of Firebase. How can I get the Download Url using following code?
UploadTask uploadTask = storageRef.putBytes(data);
...
43
votes
5
answers
55k
views
Delete firebase data older than 2 hours
I would like to delete data that is older than two hours. Currently, on the client-side, I loop through all the data and run a delete on the outdated data. When I do this, the db.on('value') function ...
347
votes
33
answers
307k
views
Firebase onMessageReceived not called when app in background
I'm working with Firebase and testing sending notifications to my app from my server while the app is in the background. The notification is sent successfully, it even appears on the notification ...
16
votes
1
answer
10k
views
What is denormalization in Firebase Cloud Firestore?
What is really this denormalization all about when talking about Firebase Cloud Firestore? I read a few articles on the internet and some answers here on stackoverflow and most of the answers ...
335
votes
30
answers
299k
views
Cloud Firestore collection count
Is it possible to count how many items a collection has using the new Firebase database, Cloud Firestore?
If so, how do I do that?
22
votes
4
answers
16k
views
How to list subcollections in a Cloud Firestore document
Say I have this minimal database stored in Cloud Firestore. How could I retrieve the names of subCollection1 and subCollection2?
rootCollection {
aDocument: {
someField: { value: 1 },
...
222
votes
28
answers
180k
views
Google Firestore: Query on substring of a property value (text search)
I am looking to add a simple search field, would like to use something like
collectionRef.where('name', 'contains', 'searchTerm')
I tried using where('name', '==', '%searchTerm%'), but it didn't ...
72
votes
7
answers
64k
views
How do I return a list of users if I use the Firebase simple username & password authentication
Not sure if I am doing something wrong but using this api https://www.firebase.com/docs/security/simple-login-email-password.html I can successfully create a user - according to the return message, ...
26
votes
4
answers
57k
views
How to save the current date/time when I add new value to Firebase Realtime Database
I want to save the current date/time in specific field when I add new value to Firebase Realtime Database via control panel.
How can I achieve that?
Please help me.
15
votes
6
answers
46k
views
Checking if a particular value exists in the Firebase database
I am making an Android application using Firebase realtime database. When a new user registers on my app, that user's data is saved in the Firebase database.
A user has to provide the following ...
13
votes
2
answers
4k
views
FirebaseListAdapter not pushing individual items for chat app - Firebase-Ui 3.1
I am making a chat app on Android that uses google firebase to store messages that users write to each other. To display these messages to the users I read them from the database and organize them ...