This question already has answers here:
Can I get firebase analytics data using query?
(3 answers)
Is there any api for dashboard analytics data?
(1 answer)
Is it possible to collect data from Firebase Analytics Console programmatically?
(1 answer)
Closed 3 years ago.
In my java android app I'm recording with the firebase analytics some events that the user watches in the app, like every time the user watch an item. I would like to retrieve this data to, for example, show the user the yesterday's top most watched items. How can I achieve that?
The only information that I can find is to retrieve data from the firebase database which I'm not using. Can someone point me in the right direction?
Thanks
Just had a quick look at the below docs
https://firebase.google.com/docs/analytics/
I can't see a "get" method for receiving data. :( So I don't think they offer it right now.
You could get the same result by using the Real-Time Database.
set the value with something like: (the below is javascript but the idea will be the same)
// get next ID
id = Firebase.database().ref().child("users").push().key;
// get all users
const users = Firebase.database().ref().child("users");
var userOBJ = {};
users.on('value', function (snap) {
userOBJ[id] = {username: ..., watch_item:1234 });
users.update(userOBJ);
To get the object data
dbOBJ = Firebase.database().ref().child("users").child(id);
dbOBJ.on('value', function(snapshot){
snapshot.val();
});
Related
This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Closed 1 year ago.
I'm using the FirebaseRecyclerAdapter to display a list of announcements to students in a university app training project I'm working on. The data is stored in the folowing structure:
each student has a department, year and a language field
each announcement has a targeted department, year and language
my goal is to only display the announcements that are targetted to the currently logged in student, but I couldn't find a way to perform such query in firebase database.
fetching all the announcements wouldn't cause any privacy issues, so I thought of filtering the data in the FirebaseRecyclerAdapter. I saw (this) answer that implements a Filterable then calls the FirebaseRecyclerAdapter.getFilter().filter() method to do the filtering. However, I need to run the filter() method automatically everytime more data is fetched from the database and I have no idea how to do this.
To get only the announcements for the current user, you need to do two steps:
Load the current user, so you can look up their department.
Create a query for only the announcements of that department, something like:
Code:
Query query = FirebaseDatabase.getInstance().getRef("Announcements").orderByChild("department").equalTo("CCNE");
You can then create the FirebaseRecyclerAdapter based on the query, instead of the direct reference to all Announcements.
This question already has answers here:
Check if value in Firebase Realtime Database is equal to String [duplicate]
(2 answers)
Closed 2 years ago.
I'm working on a Doctor-on-Demand kind of application and I want to use firebase for the project. I have 3 types of users and Apps:
Patients
Doctors
Admin
What are workaround on this, for example for the case of authentication each have their own custom fields.
Its not clear why you want to use firebase and for what purpose. I mean how you want to use firebase here. Please give some more detail about it.
Set the value like is_admin == 1 and is_doctors == 2 and is_patients == 3 and please give some more detail about it.
This question already has answers here:
Android Firebase multiple sort
(1 answer)
How to sort Firebase records by two fields (Android) [duplicate]
(1 answer)
Filter and sort on multiple values with Firebase
(1 answer)
Closed 3 years ago.
I am using Firebase Recycler Adapter on the Real Time Data Base (RTDB). Unfortunately, the query feature for the RTDB is quite limited and is causing me some problems. Here is the problem I am trying to solve:
Imagine I have an object model consisting of the name and the national origin of a person. I can query all the people with a particular national origin as shown below:
Query query = FirebaseDatabase.getInstance().getReference().child("People").orderByChild("nationalOrigin").equalTo("USA");
FirebaseRecyclerOptions<People> options = new FirebaseRecyclerOptions.Builder<People>()
.setQuery(query, People.class)
.build();
This correctly query all the people with national origin being "USA". However, what if I also want to sort the data alphabetically based on the name of the person before populating the recycle view. What is the best way of dong this?
Thanks in advance.
This question already has answers here:
Google Firestore - How to get several documents by multiple ids in one round-trip?
(17 answers)
Closed 4 years ago.
I have below FireStore data
And I have a list specialUsers which is defined as
val specialUsers = arrayOf("stark#gmail.com", "lannester#gmail.com")
So I want to get collections which are in the specialUsers, something like
collection("users").whereIn(specialUsers)
But, couldn't find any documentation related to this. How can I perform above intention in Firestore?
As he says here in 6:19
There is still no way for the database to automatically grab specific user name and profile for each review as I requesting them. I would need to make separate database request for every single review I get to fetch this information and that's bad. so If we wont to automatically include information about who rote a particular review we will need to copy sample of the user profile to the particular review and this is the way (to brake data Normalization) specifically in could FireStore.
This question already has answers here:
Query based on multiple where clauses in Firebase
(8 answers)
Closed 5 years ago.
Query q = FirebaseDatabase.getInstance().getReference().child("Chats").orderByChild("senderkey")
.equalTo(FirebaseAuth.getInstance().getCurrentUser().getUid());
In the above code I'm querying using sender = x , what if i want to make this statement senderkey = x and receiverkey = y.
In short, how to use AND in firebase ?
because:
I’m displaying the data by querying by senderkey but I don’t want to display the duplicated data again, if the senderkey is repeated i want it to be displayed once
I don't think this is possible. You can't query on multiple children. If you know you want the last message with a specific sender id you can use the limitToLast() function which will eliminate the duplicate concern.
More info on Firebase Database Queries here: https://firebase.google.com/docs/database/admin/retrieve-data
These type of queries are not allowed in firebase realtime database You can use firestore for multiple where queries by the way.
If you want to stick with firebase realtime database then you should work on your data model and create combine key to search and perform AND operation.
For example to perform AND operation you need to create a key
"name_createdAt" = "chickungunya_moka"
and then do query for
orderByChild("name_reportedAt").equalsTo(name+"_"+reportedAt);