How to push notification in django rest api for implementing it in mobile app?

1.9k Views Asked by At

I am working on django api project and kind of stucked in pushing notification can anyone give me idea how do i push notification by saving it into my database? For example, If a user followed another user then the followed user should be notified that he/she is being followed by certain user.

2

There are 2 best solutions below

1
On

StackOverflow is not allowing me to comment, so I'm posting this as an answer, I hope it helps. You could use Firebase Cloud Messaging and Firebase Functions. Otherwise, you have to implement your push notification protocol using something like Django Channels or come up with some other socket programming solutions.

2
On
There are two part of your question :-
  1. Notifications can be implemented using Firebase cloud messaging. For implementing it using api's you have to use Firebase Cloud messaging Service.

  2. Now, for the next part of the question,How should you send notification to the followed user then what you have to do, when user X follows user Y then lets say you are executing Function F(), when X follows Y and in this situation you have the ID's of both the users so now make a function and just where you have to pass the ID of the user Y, after that send notification to them.

Firebase official docs : https://firebase.google.com/docs/cloud-messaging

I hope it helps :)