Firebase Notification Inbox in Web App (Not FCM) - reactjs

I'm trying to implement notification inbox similar to stack overflow inbox where I can see related notification.
For now, I just want user to be notified whenever new comment is posted in the post (show number of notification when user logs in and whenever user opens that inbox it should go away).
I'm not sure how this can be done using firebase and how I should structure the data.
I'm thinking of having a comment collection inside a Post collection and use the onSnapshot to listen to changes in Post collection but how would i actually implement the notification part (whether comment is read or not)?

I would recommend to have a collection just for notifications like notifications/{userUid}/notifications/{notificationID} like here:
We use that structure for all of our apps that have such a feature. The notification itself is send using FCM but we store the data of it in such a separate collection. It also has the value isRead where we store just a boolean or a timestamp when the notification is read from the user. Each user has his own notifications collection and can only see those and change only the isRead value by the security rules.
With a limit query we show him only the last 25 to 50 messages.
If you don't know how to trigger the sending of the notifications: You will need to use the Firebase Cloud Functions and setup a trigger when a post/comment is created and send an FCM message and a notification in your users notifications collection as shown above.

Related

How do I send notification to button with React native firebase cloud message?

I have a post page, and this page will have a button when the correct answer to the question asked in the post is given, just like in stackoverflow, and when this button is pressed, I want the people who follow this post to be notified. I want to send notifications using a react native cloud message.
Calls to the Firebase Cloud Messaging API to send a message require that you specify the FCM server* key in your code. As its name implies, this key should only be used in server-side code, or in an otherwise trusted environment. The reason for this is that anyone who has the FCM server key can send whatever message they want to all of your users. For this reason it is not possible to send a message directly from one device to another device/user through FCM, the messages must always be sent from a trusted environment.
The common approach is to create a custom server-side endpoint/API (using Cloud Functions, or a server that you control) that makes the FCM call on the user's behalf, and then call that endpoint from within your React Native app. For an example of this, see use-case notifying users when something interesting happens in the Firebase documentation.

How to get notification on my server if any event is edited or deleted on user Google calender

After the successful authentication on Google, user get event information
Which is processed on our server.
But if any events edit or delete user is not able to getting update regarding this, user need again call calender api.
How we can get changing update regarding google calendar events on our server without again call of calendar api.
If I understand you correctly, you want to receive a notification to your server whenever a calendar event changes.
If that's the case, consider using push notifications:
First, set up a URL where notifications will be received.
Second, call Events: watch to set up the notification channel.
Take a look at push notifications for a complete guide on this, and Events: watch for documentation on the method you'll have to call after setting up the webhook.

Send updates to a user using Socket.io and nodejs

I'm building an app using MEAN Stack (something like Facebook). So a user can login to my app using different browsers and I want for example, if there user will add a new message to the MongoDB, I want to update his messages in the other sessions. The same of he will remove a massage. At the same time, there maybe logged in different users from different browsers and I want to notify the user with his update in the other sessions.
Does Socket.io supports such an option? And what is the best way to do it?
Thanks.
Yes socket.io do support that. Here is an example made by socket.io themselves: https://github.com/socketio/socket.io/tree/master/examples/chat
You should be looking for socket.on() which are the listeners for an event on the server side and look into socket.emit() which are the senders of the events. the .emit()could be added into an function which are triggered on a button click for example.
Depending on you needs, if you're going to send the message to every user using your app then you could use this above code. But if you only wants to send to a specific list of persons you should look into something called Rooms (http://socket.io/docs/rooms-and-namespaces/#rooms).
This does exactly what it sounds like, it emits the messages to the specific room where users have been added to when they connect to your application.

How to implement unsubscribe usecase for website

I'm sending automated emails and hence I should deliver an unsubscribe function. I have a User entity that is not used much, only when a user registers and the emails can be send to users who are not registered as Users. So when I send an email and I must include an unsubscribe link, should I keep a whole separate entity / class for class Unsubscriptions or include them as a variable in the User class whether or not a user is registered to receive emails?
Did you use any method for unsubscribe that you can recommend? Are there any frameworks for unsubriptions? GAE that I'm using has a very primitive framework for sending and receiving emails and I understand that Amazon has a much more developed API for manging large email list, but I suppose I can still do it all in GAE without Amazon though that would take longer time so I'm considering managing large email lists from Amazon. I have > 10 000 registered users that I never emailed and I'd like to email them a reminder that they are welcome to use my application and that they can unsubscribe from future mailings.
Each new class implies a new query, which adds to the total cost. Pack as much information that is practical into the User class. A simple boolean in the User class should work for active/inactive or subscribe/unsubscribe. Your app needs to accept emails to receive the Unsubscribe request and set the associated boolean to False.

How to implement Facebook Post Type objects in GAE?

I a new programmer and trying to implement a facebook type "feed" in my application. Like Whenever a user do some changes in his profile his linked profiles will get to know that in the form of news feed.
But I am stuck on that as I thought whenever any user saves any data (like "News", "Blog", "Event" or any "Comment") just send the id of the respective classes to the linked profiles and they will see it. Since the id is not generated before the object is saved , the problem is how can I send them. I thought of following workarounds but each have some problem.
Whenever a user posts a news .... a Post object will be made and added to User's Post Collection.
But How do the other users will knew about it.....
1) Send them the id .... but when the id is not created how can you send them the id.
2) Send them the post message and when ever they will click them ... the latest post to them from the particular user will be shown.. but if more than 3 messages then which will be shown?? Shown by the post creation Date no post greater than that date is shownn....but he needs to be shown newer posts..
3) Save the post in all followers feed. the data will be much larger then
4) all the followers on login will check all the persons they are following and save their feed after the time stamp? How to implement this as the Post is saved in User's Profile so I would have to check all the following person and then just check the feed and show them on his feed box; I think I would have to use batch Processes. Processing will take much longer.
I am using objectify-appengine to do operations on GAE.
Any help is appreciated
Are you wanting to update the page with posts in real time like on Facebook and Twitter? To achieve this on Google App Engine you can use the Channel API, which works in conjunction with Javascript to listen for new data and update the DOM.
This talk at Google I/O 2009 by Brett Slatkin describes exactly the pattern you should use for this.

Resources