How do I manually sync a Mesibo profile with latest changes from server if that user published its data with LAZY mode? - mesibo

I made a page where users can update their names and status just like WhatsApp & Telegram.
These changes are published using LAZY mode since I don't want to update every user using the app right away. I just want to fetch it manually when necessary (for example when the user open the chat view with that user). (https://mesibo.com/documentation/api/real-time-api/profiles/#profile-publishing-mode)
The problem is: how can I fetch the updated profile of other users?
Whenever I get the profiles with Mesibo.getProfile("address") the data is still not updated.

since I don't want to update every user using the app right away.
Even if you use real-time mode, updates don't go to every user but only those users who have subscribed to it.
https://mesibo.com/documentation/api/real-time-api/profiles/#subscribing-to-a-profile
In lazy mode, it may be updated along with other profiles or when the message is received from the users. Before that, getProfile may not return the latest profile.
If you are starting with mesibo, recommend using real-time mode and optimizing later using the lazy mode

Related

Use Firebase Cloud Message with faketoken

Is it possible for my app Web to create a "faketoken" and use it to register with Backend and receives some information - hidden and without user confirmation?
What I need is to inform the browser, with information on screen that another user changed the object, so FrontEnd has to reload the data or block the Save action while the current user does not get the latest version of the object.
I just need to inform the Front End of this change and it resolves what to do.
Is not a push notification.
I don't know if firebase can do that or if I need to implement something like socket.io.
Thanks

How to sync IndexedDB with Firestore?

I am building a job portal for the web using React, Redux and Firebase/Firestore. I've completed all the features I needed except one.
I want unregistered-users/job-seekers to be able to:
Bookmark job posts.
Keep the record of applied jobs.
Keep the record of search queries.
I am thinking about using IndexedDB for this feature. Particularly Dexie.js to make things easier. However, this data will be persisted in user's browser and user will have no access to it in another browser or device. Therefore, I want to give users an option to be able to save all the data to Firestore if user sign into the website and I need this to be automatic. So, as soon as user signs in, I will save it to the database.
I thought about using Anonymous Authentication instead of IndexedDB/Firestore, so all the data will be saved into the database and as soon as user signs in using credentials, the user can claim the ownership of the data. However, this is an extra step to use these features I listed above and not everyone is happy with authenticating an app even though nothing is required from the user. Besides, there will be so many ghost accounts.
So, as I mentioned in the title; I want to save everything to IndexedDB (I will take care of this), but how am I going to synchronize all the data in IndexedDB to Firestore as soon as user signs in?
I imagined the basic process will be like this:
User clicks "Bookmark Job Post"
App checks if users is authenticated or not.
If authenticated, save the bookmark to the Firestore.
If not authenticated, save the bookmark to the IndexedDB.
If User decided to sign in or sign up, check IndexedDB and synchronize it with Firestore and clear IndexedDB.
How can I achieve the 5th step technically? Is there any built in system in Firebase? Also, please feel free to share your idea if you can think of another way implementing this feature. Should I be using firebase.auth().onAuthStateChanged() for the 5th step?
And lastly, how should I structure the Firestore to save bookmarked jobs, applied jobs and search history?
Should I create a bookmarkedJobs collection and have documents of jobPosts duplicated for each user, who bookmarked the job post? And every time a job post is updated by an employer, I will have a cloud function going through bookmarkedJobs collection, updating every instance of it?
Thank you
This may be of interest to you
https://dexie.org/docs/Syncable/Dexie.Syncable.js
Been looking into making my website fully static/pwa, and just using indexeddb, and some webservice for data handling/storage ..this seems like a interesting route to explore.

Flutter: offline local storage syncing with online e.g. firebase

Is this a common/reasonable Use case?
An app allows a user to save favorites locally so that the user doesn't need to signup.
Then the user afterwards desires to share their favorites.
Therefore favorites data needs to be synced from local to remote. The usual local storage for flutter is sqflite, and firebase/store is the remote. However, this seems cumbersome, as sql to nosql conversion is necessary.
I thought that this would be a general issue for UX etc, but I can't find any discussion of this issue? Maybe forcing the user to create an account is the most general solution?
It's a common understanding that if you don't have user account then you can't have any user data associated with your name. You don't have to force the user to have an account or lock them out.
When they favourite something just show a dialog telling them "If you don't have an account your favourites are stored on the device only. If you want your favourites to be available everywhere please create an account" then show options for "Create account" or "No, Thanks"
Create account: Goes to account creation page
No, Thanks: Adds the device to the favourites list and lets the user continue to do what your app does.
There's no problem to solve here from what I'm seeing. If you don't have an account you don't get account functionality. If you track users without them entering anything it's also a little bit illegal and creepy so no need to push the limits on how you can track the same user.
Another way to think of it is to make signup so easy they don't mind and also guarantee that it's worth it. Won't be used for spam or information selling. Take what's app as an example, even though you need to mobile number to send the messages, it's just used as a unique identifier and has nothing to do with the device's number.
Ask for their phone number or email or just any email, you'll most likely get fake info.
And what does your analytics say? Are you getting requests from users saying they lost all their information on a different device? How many people are using your favourite functionality?
I may have come to the party a little late here but here's my 2 cents worth.
The Sql to NoSql conversion is not cumbersome. In fact, there is a reasonable use case for this. I have the same requirement for an app that I am about to build.
Anyway, to store data in RDMDB or NoSQLDB you will need a data model to ensure consistency in your app. If the user has been using the app offline, and they later choose to go online, you can allow them to create the Remote Account, then check if they have local favorites. If they do, you will HAVE to ask them if they'd like to import them into the remote storage. If they choose to do so, you will then have to read their favorites from the local storage and store them in a List<Model> then map() that back to the online storage.
NoSqlDB can accept the json type data, so your model should include the conversion fromMap() and toJson() for this purpose (and others).
When I have come around to doing this, I will share my code (if I remember to come back here).

Firebase: action after read child

I'm working on project that sell unique soft products like serials or tickets. To be fast and reliable, we going to use Firebase Real-time Database.
The problem is I want to remove or update the sold ticket after the user get it.
One way to do so is using another server to do so manage the tickets and update the Firebase Database using REST API, but I want to do it with the Firebase only.
Another way to do it, after the user get a ticket, the client side app will sent a remove request. But I'm afraid of losing the data in the middle of this process. A user got a ticket but never removed from the database. As I said the ticket is unique.
How to do it with Firebase side only?

meteor- should I create new collection or extend the user profile?

So I have an application that allows users to invite each other to different events. Previously I had a separate collection called Invites that contained an entry for each user and an array of events they were invited to. Since I'm building a prototype, I have insecure on, and I would simply update Invites from the client side.
Recently I changed this so that when a user invites another to an event, it calls a meteor method and updates both the inviter and the invitee's profiles on the client side.
Now my app is running very slowly and I'm not sure why. Even just loading the first page of the app (the login button for example, which uses accounts UI takes forever to load). Since the changes to invitations are the only changes I've made, I'm guessing this is the issue. Is storing invitations on each user's profile the wrong way to go about this? Any ideas about how to debug this slowness? I'm new to meteor/ web dev in general and I'm not sure what the best practices are for writing efficient code.

Resources