安裝
Add InsForge to your Swift Package Manager dependencies:Enable Logging (Optional)
For debugging, you can configure the SDK log level and destination:
Log Destinations:
Use
.info or .error in production to avoid exposing sensitive data in logs.思維模型
Swift SDK 透過 Socket.IO 連線到 InsForge 即時。訂閱頻道名稱,如order:123 或 chat:room-1,然後監聽發佈到這些頻道的事件名稱。
事件由資料庫觸發器發佈,這些觸發器呼叫 realtime.publish(...) 或由已加入頻道的用戶端發佈。有關頻道和 RLS 模型的詳細資訊,請參閱即時概覽。
快速入門
connect()
建立即時連線。subscribe()
訂閱頻道並接收發佈到該頻道的訊息。realtime.channels 上啟用了 RLS,訂閱會根據 SELECT 原則進行檢查。
publish()
發佈事件到頻道。用戶端必須訂閱頻道才能發佈到該頻道。
realtime.messages 上啟用了 RLS,發佈也會根據 INSERT 原則進行檢查。