Strapi Real Time Database Update Socket.IO with React Native. How to send updates?

I am developing a food delivery application with React Native and I am using Strapi as the Backend/Admin Panel for this app. The problem, however, came up with orders as I don’t see a way to notify the client (app in this case), that the order state has changed - display different data. Currently, the updates in Strapi and DB are happening on Stripe changes, passed along by Webhooks and admin manual changes. Is there a way, that by using Socket io I can send the notification to the client as well? For instance, your order was processed by kitchen staff and is now cooking, your order is being delivered, wait patiently.

I am developing a food delivery application with React Native and I am using Strapi as the Backend/Admin Panel for this app. The problem, however, came up with orders as I don’t see a way to notify the client (app in this case), that the order state has changed - display different data. Currently, the updates in Strapi and DB are happening on Stripe changes, passed along by Webhooks and admin manual changes. Is there a way, that by using Socket io I can send the notification to the client as well? For instance, your order was processed by kitchen staff and is now cooking, your order is being delivered, wait patiently.

I read through this, but essentially it’s waiting for input from the client before sending a notification, in my case client will not send anything, only receive notifications.

Closest answer to my issue was this, however it seems to be outdates as the link does not work

System Information
  • Strapi Version: 3.4.4:
  • Operating System: Mac OS Catalina 10.15.7:
  • Database: Mongo Atlas:
  • Node Version: 14.15.5:
  • NPM Version:
  • Yarn Version:

System Information
  • Strapi Version: 3.4.4:
  • Operating System: Mac OS Catalina 10.15.7:
  • Database: Mongo Atlas:
  • Node Version: 14.15.5:
  • NPM Version:
  • Yarn Version:

For anyone looking at this question in the future and wondering how to implemetn real-time database using strapi here is the answer strapio/index.js at master · larsonnn/strapio · GitHub
After searching for a while I noticed this package, however in my use case the updates are not based on user roles, so I modified the solution to meet those needs, but the general way of implementing the logic is the same!

4 Likes

Nice point.

Adding to this, since we had a forum thread for that package. I built a test plugin (shared the code with that package author) on how it could be used as a middleware instead of just custom logic: StrapIO the ez to use socket.io configurator - #8 by DMehaffy

1 Like