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 :/
SOLVED
Apparently when doing .on(.all) you have to also listen to the onMessage callback.
.insert, .update, .delete all work without the onMessage callback.