A Swift client for Supabase Realtime server.

Overview

realtime-swift

Listens to changes in a PostgreSQL Database and via websockets.

A Swift client for Supabase Realtime server.

Usage

Creating a Socket connection

You can set up one connection to be used across the whole app.

import Realtime

var client = RealtimeClient(endPoint: "https://yourcompany.supabase.co/realtime/v1", params: ["apikey": "public-anon-key"])
client.connect()

Socket Hooks

socket.onOpen { 
    print("Socket opened.")
}

socket.onError { error in
    print("Socket error: ", error.localizedDescription)
}

socket.onClose {
    print("Socket closed")
}

Disconnect the socket

Call disconnect() on the socket:

client.disconnect()

Credits

License

This repo is licensed under MIT.

Comments
  • Remove Starscream Dependency and bump minimum support platform

    Remove Starscream Dependency and bump minimum support platform

    This PR bumps the minimum supported platforms to:

      platforms: [
        .macOS(.v10_15),
        .iOS(.v13),
        .watchOS(.v6),
        .tvOS(.v13),
      ],
    

    That make's it possible to remove the Starscream dependency.

    opened by grsouza 3
  • StarScream Dependency prevents importing into Swift Playgrounds 4

    StarScream Dependency prevents importing into Swift Playgrounds 4

    This is definitely an edge case, but something I think that is important.

    The realtime-swift package cannot be imported into Swift Playgrounds 4 because of the dependency on StarScream. realtime-swift can already run with StarScream removed since an implementation of the Transport protocol using standard iOS libraries exists. Please see my fork for a working repo that can import into Swift Playgrounds 4: https://github.com/YeomansIII/realtime-swift

    Through my research, these Supabase Swift libraries (postgrest-swift, storage-swift, gotrue-swift) are some of the only 100% Swift packages that can actually be imported into Swift Playgrounds 4, which allows developers to create iOS apps directly on iPadOS without a Mac computer. This was important for me, because I was looking for a no-code backend like Firebase to use for my iOS app I am developing in Swift Playgrounds 4. Firebase and numerous other similar platforms were not able to be imported into Swift Playgrounds 4 because the packages contain Objective-C or other incompatible code/settings.

    While I know that removing the StarScream dependency allows importing into Swift Playgrounds 4, I do not know if this is an actual solution or what the potential solution might be to get the main realtime-swift repo working with Swift Playgrounds.

    So I would like to open up that discussion here.

    opened by YeomansIII 2
  • Issue With Channel + Schema

    Issue With Channel + Schema

    I love the project

    Im running into a when setting up a channel listener on a table with public schema.

    Currently, I can only receive data from my supabase DB if I'm using realtime:*, but whenever set a specific table with the schema set public:

    channel(.table("Media", schema: "public"))

    the listener returns no data and after the socket opens, it emits a Close Event shortly after. I made sure all of my tables were public and also replicated as per the requirements for real-time setup.

    Screen Shot 2022-01-14 at 2 24 17 PM

    Thanks you for the help!

    opened by lmick002 2
  • realtime doesn't seem to work with with xcframeworks.

    realtime doesn't seem to work with with xcframeworks.

    not sure if it's a side effect of CLib change from swift-nio

    sample app here https://github.com/wweevv-johndpope/DemoBazel/tree/gotrue-swift

    table is simple structure

        struct TestClass: Codable {
            var id: Int?
        }
    
    
    Screen Shot 2022-09-06 at 6 54 51 am

    I'm definitely on the right instance. pqxcxltwoifmxcmhghzf

    client connects successfully - I attempt to move subscription into the onOpen block - but no joy.

    
    
       let rt = RealtimeClient(endPoint: "https://pqxcxltwoifmxcmhghzf.supabase.co/realtime/v1", params: ["apikey": supabaseKey])
            rt.connect()
            rt.onOpen {
               
                let allUsersUpdateChanges =  rt.channel(.all)//rt.channel(.table("test", schema: "public"))
                allUsersUpdateChanges.on(.all) { message in
                    print(message)
                }
                allUsersUpdateChanges.subscribe()
            }
            self.realtimeClient = rt
    
    
    opened by wweevv-johndpope 1
  • Starscream dependency on zlib

    Starscream dependency on zlib

    https://github.com/daltoniam/Starscream/pull/844

    this prevents xcframeworks being spat out https://github.com/supabase-community/supabase-swift/issues/38

    opened by johndpope 1
  • Connection Issue

    Connection Issue

    Hello,

    I might be doing something totally off but having a hard time connecting to the server. I am getting an error of "Could not connect to the server."

    Heres what I am trying:

    var client = RealtimeClient(endPoint: "https://pkx....supabase.co/realtime/v1", params: ["apikey": "eyJhb..."])
    

    A few questions.

    1. Should use https and not wss in the url?
    2. Should the url end in supabase.io or supabase.co?
    opened by drewg233 1
  • Swiftification of the API

    Swiftification of the API

    Apply the usual Swift pattern to the API: Event and Topic are now proper Swift Enum. Limit the current implementation to the effectively supported features. Extend the tests to ensure the patterns are right. Add the subscription part to the README for ease of introduction to the framework.

    opened by mbarnach 1
  • Import FoundationNetworking if needed.

    Import FoundationNetworking if needed.

    Add FoundationNetworking if available. This is allowing Linux platforms to compile the framework, since the migration of URL-related function to the FoundationNetworking framework.

    opened by mbarnach 0
  • Fix ChannelTopic init from string and add unit tests

    Fix ChannelTopic init from string and add unit tests

    I created this PR in favor of #4 . Thanks @lmick002 for addressing it, I've just added a few minor things on top of it, such as:

    1. Refactoring ChannelTopic type for using RawRepresentable.
    2. Add unit tests for testing the ChannelTopic init from the rawValue string.

    Fixes #3

    opened by grsouza 0
  • Fix availability check

    Fix availability check

    What kind of change does this PR introduce?

    Fix availability check for URLSessionTransport.

    What is the current behavior?

    The current availability check consider only macOS versions.

    What is the new behavior?

    Availability check now consider macOS, iOS, tvOS and watchOS versions.

    opened by grsouza 0
Releases(0.0.2)
  • 0.0.2(Oct 6, 2022)

    What's Changed

    • Import FoundationNetworking if needed. by @mbarnach in https://github.com/supabase-community/realtime-swift/pull/7
    • Remove Starscream Dependency and bump minimum support platform by @grsouza in https://github.com/supabase-community/realtime-swift/pull/11

    Full Changelog: https://github.com/supabase-community/realtime-swift/compare/0.0.1...0.0.2

    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Feb 22, 2022)

    What's Changed

    • Fix availability check by @grsouza in https://github.com/supabase-community/realtime-swift/pull/1
    • Swiftification of the API by @mbarnach in https://github.com/supabase-community/realtime-swift/pull/2
    • Fix ChannelTopic init from string and add unit tests by @grsouza in https://github.com/supabase-community/realtime-swift/pull/5

    New Contributors

    • @grsouza made their first contribution in https://github.com/supabase-community/realtime-swift/pull/1
    • @mbarnach made their first contribution in https://github.com/supabase-community/realtime-swift/pull/2

    Full Changelog: https://github.com/supabase-community/realtime-swift/commits/0.0.1

    Source code(tar.gz)
    Source code(zip)
Owner
Supabase Community
Supabase Community
BubblesChatAppIos - A realtime messenger application Allows the users to communicate through virtual chats

Bubbles Chat App a realtime messenger application Allows the users to communicat

null 1 Jan 22, 2022
Legacy mobile Rocket.Chat client in Swift for iOS

IMPORTANT: PLEASE READ THIS FIRST Rocket.Chat mobile is moving to React Native. Development on this repository by Rocket.Chat has now ceased. If your

Rocket.Chat 1k Dec 22, 2022
ChatSecure is a free and open source encrypted chat client for iOS that supports OTR and OMEMO encryption over XMPP.

ChatSecure ChatSecure is a free and open source XMPP messaging client for iOS that integrates OTR and OMEMO encrypted messaging support, and has optio

ChatSecure 3.1k Dec 31, 2022
Colloquy is an advanced IRC, SILC & ICB client for macOS and iOS!

Colloquy Dependencies This repository uses git submodules for some of its dependencies, so you will have to check those out as well. You can do this f

Colloquy 175 Jan 7, 2023
A glossy Matrix collaboration client for iOS

Element iOS Element iOS is an iOS Matrix client provided by Element. It is based on MatrixKit and MatrixSDK. Beta testing You can try last beta build

Element 1.5k Jan 1, 2023
Free Jabber/XMPP client for iOS and macOS

Monal A cross platform, modern XMPP client for iOS and MacOS This is the Monal XMPP client as found in the app store. If you want to use the latest st

Monal 400 Jan 5, 2023
Mumble client for iOS-based devices

Mumble for iOS (iPhone, iPod touch and iPad) Note: This repo and the app for iOS are unmaintained. If you are interested in taking over development of

Mumble 185 Nov 18, 2022
iOS-mail — ProtonMail iOS client app

iOS-mail Introduction iOS-mail — ProtonMail iOS client app The app is intended for all users of the ProtonMail service. Whether they are paid or free,

null 1.2k Jan 3, 2023
Spika is universal chat module with backend, web, ios and Android client.

Spika Spika is messenger module for Web/iOS/Android with backend. You can include messenger feature to your app or service with minimum code. For deta

Clover Studio 608 Dec 23, 2022
Tinodios: Tinode Messaging Client for iOS

Tinodios: Tinode Messaging Client for iOS iOS client for Tinode in Swift. Status: beta. Usable and mostly stable but bugs may happen. Getting support

Tinode 173 Jan 5, 2023
Secret Messenger - a free and open source Jabber (XMPP) messaging client for Apple

Secret Messenger is a free and open source Jabber (XMPP) messaging client for Apple and Android devices focused on Privacy and Security with full OMEMO encrypted messaging support.

Secret Messenger 4 May 2, 2022
Swift-Chat-Application - Swift Chat Application Using Firebase , messagekit

Swift-Chat-Application Using Firebase , messagekit

Metin ATALAY 7 Oct 9, 2022
Messenger Clone - Real-time iOS Chat with Firebase Firestore written in Swift

Real time Swift iOS Chat with Firebase - Messenger Clone This is an extremely simple chat app source code of an iOS Swift Chat app. It leverages Messa

Instamobile 615 Dec 27, 2022
Real time chat app written in Swift 5 using Firebase

Quick Chat for iOS Quick Chat for iOS is a real time chat app written in Swift 5 using Firebase. Quick Chat allows to send and receive text messages,

Henry Aslanyan 1.8k Dec 10, 2022
A WeChat alternative. Written in Swift 5.

TSWeChat - A WeChat alternative, updated to Swift 5. 中文说明 Requirements Cocoapods 1.2.0 + iOS 10.0+ / Mac OS X 10.9+ Xcode 10.0+ Features Send your ric

Hilen Lai 3.7k Dec 31, 2022
Integrate third party libraries by using Cocoapods and Swift Package Manager, store data in the cloud using Firebase Firestore.

Integrate third party libraries by using Cocoapods and Swift Package Manager, store data in the cloud using Firebase Firestore. Exercising query and s

WEI 0 Dec 19, 2021
Real time chat application in Swift 5 using Firebase

Real time chat application in Swift 5 using Firebase

null 1 May 13, 2022
Fully Functional iOS14 Swift Chat app Using Firebase as backend.

Social Chat Messenger App This iOS14 Chat App is built with Swift in Xcode12 and Using Firebase as backend to authenticate users. Features Light and D

null 0 Nov 25, 2021
Create a real time chat application in Swift 5 using Firebase

Messenger Real Time Chat App Project to create a real time chat application in Swift 5 using Firebase. Features Facebook Log In Google Sign In Email/P

null 2 May 29, 2022