How to integrate news article / comments with Firebase? - android

I've been trying to create an app that follows these three steps:
Register via Facebook
Create new user in Firebase database
Allow registered users to see news articles and comment
I am stuck on #3. I'm not sure this is efficient, but I want to post articles on a site such as Wordpress or whatever and parse the JSON to the app. However, I do not know how to implement the comments.

You could have, in the Firebase realtime DB, a structure like:
[root]
-[article_urls]
-[comments]
-[comment_id]
-[content]->value
-[user_id]->value
etc.
The interesting bit of the Firebase database documentation would be:
best practice firebase database: ie, keep your data flat
How to add data to a list in Firebase database: When you add a new comment to an article you are actually adding it to a list

Related

Dashboard from Firestore data?

I have made a simple Android app with Flutter, that sends data to Firestore. Now, I need to build a dashboard that will be able to view the data. Excel doesn't work, I tried Zapier but it seems too limited, and I gave a look at Retool , but it seems to only work with RealTime database, not Firestore yet.
Would you guys be able to recommend something ?
Zapier does the job. I just had to name every row accordingly to the fields from firestore
Chartbrew.com supports connections to Firestore. You can run queries using Firestore operations and generate charts and tables to explore the data.

Should I use a database with back4app

I am building a Q&A app for android and I am using Back4App.
Is there a way to achieve the following without creating a local data:
Get random question.
Keep data when user offline.
Update data when the user is online.
Back4App is a BaaS, there you can save information regarding a user to the Database, using the Android SDK, you can save your objects offline (check here) and The Local Datastore doesn’t need to be saved to the cloud, you can check more here.
You can work with a separate logic using in your Cloud Code section, there, you can deploy your code if you need to implement a different logic, read more here.
Also, it seems that you need to manage your objects on the cloud, at the moment, you can read the guides below:
Create Object
Retrieve Object
Update Object
Delete Object

Using firebase real time database or firestore to set up rss feed or feed for social media platform

I'd like to create an application that includes something like an rss feed or a feed that you might see instagram or facebook. I'm currently trying to accomplish this using the firebase real time database or firestore as a backend to store the posts shown to the users. I can't seem to think of a way to make this work. The ideal solution sends a list of posts in chronological order that doesn't need any additional sorting on the client. When I tried to use the real time database, I could easily add all the relevant posts in their own path and sort them on the client side (or maybe use cloud functions to sort the data on the server side). When trying to come up with the solution using firestore, my idea was to have the post document hold a reference to a sub collection that holds the list of subscribers/followers but I can't seem to find a way to select a post based on whether a document exists in a referenced sub collection.
FYI, the reason why I want the ideal solution is because PAGINATION.
I have little to no experience with Firestore. With Firebase however, if I understand you correctly, this is easy to achieve.
The first part is storing your date, make sure you store it as a timestamp (date.getTime()).
Then you can do the following:
db.ref('posts').orderByChild('date').limitToLast(10)
This allows you to fetch the last 10 posts. To get the previous 10 you grab the date from the earliest of those posts and do:
db.ref('posts').orderByChild('date').endAt(previousDate - 1).limitToLast(10)
Note that you might want to handle this differently if 2 posts have the same date value.

Firebase Instance

I have a question of logic with Firebase. The following is:
I have chat, like WhatsApp, when I open the window of a room I instantiate the Firebase and the window is real-time, for that I am using to implement ArrayAdapter the Firebase to recover and gives push the messages, it is ok for me .
My problem is in recent conversation list, it still is still no real-time connection to the firebase because of this my doubt logic:
1- I create an instance of Firebase for each row of my ListView Adapter that implements this screen? I do not know if Firebase see this as a good practice, moreover, I would have to create an instance of array Firebase.
2 - Today I create my own chat Rooms as taking a part of TimeMillis to maintain the uniqueness of the names of Rooms. From that, I change this to also use ArrayAdpter and let Firebase create the unique Chars for these rooms and have a single instance in the same way it works in the Chat window with open Room? The problem I see in this is that once the local Instance of Firebase will hear all the real-time updates of all the beds, including those not belonging to the user in question. This is easy to be treated by checking the room that Firebase is pushing for the client belongs to it or not, but I think that a security breach, do not you think?
If anyone has any better suggestions, please tell me.
The structure today my firebase console for this project:
{
   chats
        {
           Room1 {},
Room2 {},
...
}
}
Firebase already has an official example of a chat application https://github.com/firebase/firechat
If you follow their database structure you can accomplish this functionality quite easily. You can look at it here.
Basically they have room-messages, room-users and users to keep track of users, rooms, and messages. For more questions about how to strucuture data in firebase, see https://firebase.google.com/docs/database/web/structure-data. With this structure you can listen for updates to an individual room.
Per firebase documentation "it's best to keep your data structure as flat as possible."

Creating Collections in Kinvey (Android)

I recently started using Kinvey as a backend for my Android app. The documentation doesn't have a lot of info about Collections. I want to know if it's possible to create Collections using the same concepts applied to MySQL tables for example:
A Collection called Users will hold a User ID, Username, User Email
And another Collection called Items corresponding to users -> Item ID, Item Name, User ID.
Has anyone successfully created Collections like this using Kinvey?
kinvey.com
I have also contacted their support team about this bu no reply yet.
I'm an engineer at Kinvey and can help you at this. Kinvey uses a NoSQL store on the back end, so the concepts are a little different than those of a relational database system like MySql, but in general the same thought process can apply. A Collection is similar to a table, although it is Schema-less. This means that attributes (columns in MySql terms) can be added dynamically as needed. You simply create the collection, and then start saving data objects to it. For more info on our Android library specifically, take a look at our Data Store User Guide.

Categories

Resources