How can I trigger notification using socket.io, so whenever there is new entry in database, it automatically shows notification?
What kind of notifications are we talking about? Native push notifications? Some custom in-app notification?
Native push notification
You wouldn’t even need SocketIO for that. If you use Ionic Apps for your push notifications, here’s an example:
- User sends a message
- The request is sent to the backend
- The backend handles the request
- Before responding, the backend calls the Ionic Apps API to send the appropriate notification
- Backend responds to the client
Now if you need to do this on a user-basis, I’m not sure how that works on Ionic Apps. The functionality is there, I simply haven’t made it before. If it’s for something like news, so that everyone has to receive it, then it’s simple enough after you manage to get notifications setup properly.
So yeah, basically try to look into using Ionic Apps for notifications. Get it working using the site, try the API, then setup the backend.
Edit: About the user basis stuff, what you could do is save the token you get when registering the device with the user in your backend, then the backend would look up the token for a user when needed and send the notification to just that token.