Not receiving supabase realtime updates

270 Views Asked by At

I would like to receive realtime updates for a specific table on my iOS client. I am able to successfully connect, but no messages are received.

Code:

var client = RealtimeClient(endPoint: "https://MY PROJECT ID.supabase.co/realtime/v1", params: ["apikey": MY PUBLIC KEY])
let channel = client.channel(.table("realtime_test", schema: "public"))

client.connect()
channel.on(.all) { message in
   print(message)
}
client.subscribe()


client.onError { error in
   print("Socket Error: \(error)")
}

Connection message:

 ["status": ok, "extension": postgres_changes, "channel": public:realtime_test, "message": Subscribed to PostgreSQL]

Some things to note:

  • I have RLS read policy set to anyone (I also tried with RLS disabled, no luck)
  • Realtime is enabled for the table and in replications
  • If my endpoint or apikey was entered incorrectly, I would not be able to connect at all

I wish I had an error or something to provide, but it just not working :/

1

There are 1 best solutions below

0
On

SOLVED

Apparently when doing .on(.all) you have to also listen to the onMessage callback.

channel.onMessage { msg in
   print(msg
   return msg
}

.insert, .update, .delete all work without the onMessage callback.