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."
Related
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.
So for the past few days I have been reading through the Realm documentation and I am very excited to use this data synchronization solution in upcoming projects. After using standard database schemas (SQL, Firebase, etc). I am still not fully understanding the best way to utilize Realms. I see Realms are meant to be very flexible, but there are not many examples or docs of how to set up and efficient structure.
So, I wanted to just provide a simple collaborative app idea, and show my first thoughts on how I would set up the Realms. For simplicity, lets say this is a messaging app that contains chatrooms. Users can create chat rooms and the owner of the room can invite people to their room. Once that user is added to a room, they will have read/write access to the room.
My current structure:
1) A realm for each user. (/Users/uid) . Each one of these realms will have public read access and write access only for the user that owns it.
2) A realm for each chatroom. (ChatRooms/uid) . Each chat room will hold the various models pertaining to that specific room (messages, likes, notifications, etc). Initially only the owner will have read/write access, everyone else will have no access. The owner can then start handing out read/write permissions to the users they invite.
3) A public realm that holds mappings of a user to a chatroom. (ChatMembers). This realm will hold models that have two attributes, a user id and a chatroom id. A user can query this realm by there id to see what chatroom realms they will have access to.
I feel this is a very basic structure, but I am still not positive if this is utilizing Realm to the best of its abilities. Also, if anyone can lead me to some better documentation, please do. Would appreciate anyones feedback!!
Refer to: https://docs.realm.io/platform/getting-started-1/android-quick-start/step-4-chat-room-permission-api
Here they have used the permission API and partial sync,to design a chat app that enables the user to create public and private chat rooms.
I would also recommend you to follow the previous steps also mentioned in the above link, to have a basic understanding of how realm works.
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
I'm using Parse for the first time to play around with.
I use Realm.io as a offline db.
Both are very powerful and it's great to get to know them better.
(Big up to both teams!)
My app should be able to be used on remote locations, where you can't get data from Parse. I want to be able to rely on Realm in these situations.
I just implemented user management in Parse, but I don't know what would be the best way to reflect this with realm. Should I create a User object in realm and make a one to one relation with all my models. Should I save the username as a property in the models?
I also tried the combination of Realm and Parse. And yes you'll have to sync the data manually between both datasets by creating models for each.
But I think writing (almost) the same model classes for both Parse and Realm could be counter-productive. That's why I dropped Realm and used Parse LocalDataStore instead. By using localDataStore, you still would have to write the sync logic yourself but the code would be cleaner (in my opinion).
Another option is to go for Firebase. Firebase handles the sync logic itself so you don't have to and it even gives you real-time sync. So I would highly recommend you check that out. But Firebase doesn't have Push Notifications. For that you can still use Parse.
Hope this helps.
Update
Firebase now offers push notifications as well. (and Parse has been discontinued)
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.