Unable to listen to postgres_changes

Hi guys!
I'm trying to listen to INSERT events on the table messages on my react native app.
I already impersonated the user on the realtime dashboard and filtered for postgres changes only and I can indeed see the new message showing up there, but for some reason, on my app, the listeners never trigger and I'm running out of ideas.
The broadcast listener works perfectly but postgres_changes listener doesn't work at all.

This is my code
 const channel = supabase
      .channel("notifications")
      // New messages
      .on(
        "postgres_changes",
        { event: "INSERT", schema: "public", table: "messages" },
        (payload) => {
          const msg = payload.new as {
            conversation_id: string;
            sender_id: string;
          };
          console.log(msg, " new message");

          if (msg.sender_id === user.id) return;

          setUnreadConversations((prev) => {
            const next = new Set(prev);
            next.add(msg.conversation_id);
            return next;
          });

          queryClient.invalidateQueries({ queryKey: ["conversations"] });
        }
      )
Was this page helpful?