flutter_supabase_chat_core icon indicating copy to clipboard operation
flutter_supabase_chat_core copied to clipboard

Create new postgres function and trigger for publishing message events

Open hami-sh opened this issue 9 months ago • 1 comments

What does it do?

Added a new postgres function chats.send_push_notification() and trigger to publishes events to pg_notify so that listeners (ie, supabase edge functions) can respond (ie sending a push notification to a user or device). It sends an event for each user that is in a room except the author.

Why is it needed?

I need to implement offline notifications for the app I am building. I could use a background listener on my app to listen for events on the messages table, however this doesn't work if the app is closed or suspended in the background.

How to test it?

  1. Apply the migration
  2. Create a listener on the chat_push_notification postgres channel
  3. Send a message
  4. Observe that there are N-1 messages created on the channel, one for each of the members that wasn't the author.

Related issues/PRs

N/A

hami-sh avatar May 22 '24 12:05 hami-sh