realtime-swift icon indicating copy to clipboard operation
realtime-swift copied to clipboard

Realtime Presence feature

Open miguel-arrf opened this issue 1 year ago • 3 comments

Feature request

Is your feature request related to a problem? Please describe.

I'm developing an App where it is important to have real-time knowledge of which users are in which parts of the app. I was planning of doing this using the realtime presence capabilities from supabase.

Describe the solution you'd like

I'm looking for an API that allows to use the presence capabilities from supabase.

Describe alternatives you've considered

I've considered no alternatives.

Additional context

I've been trying to follow this guide, https://supabase.com/docs/guides/realtime/presence to create a Swift realtime presence feature on my app.

 var channel = realTimeClient.channel(.schema("public"), params: ["presence":"user1"])
        
        channel.onMessage { message in
            print("message: \(message.payload)")
            return message
        }
        channel.push(.join, payload: ["presence":"user2"])
        channel.subscribe()

For example, with something like this, I receive the following error: Realtime/Channel.swift:466: Fatal error: Tried to push join to schema("public") before joining. Use channel.join() before pushing events`` However, the channel has no public .join` method.

One of the issues is that the endpoint being used for realtime is v1. Are there any plans to update it to v2?

Maybe I'm interpreting this in a wrong manner and it is already possible to have a presence feature implemented with the current version of supabase-swift.

Thank you :)

miguel-arrf avatar Mar 12 '23 13:03 miguel-arrf

@miguel-arrf hey Miguel. The Supabase Swift library has got real time capabilities.

The Swift Docs over here as has examples: https://supabase.com/docs/reference/swift/subscribe

Please take a look and let me know if this helps.

maail avatar Jun 26 '23 01:06 maail

Hi @maail ! Thank you for the reply!

The feature that I think is missing (as least it was) is Realtime Presence.

I've implemented this in my app by embeding a WebView with the JS supabase library that can then communicate with my app. It's an ugly workaround, but one that works.

miguel-arrf avatar Jun 28 '23 08:06 miguel-arrf

If still in need try update-upstream branch (see #26)

foodisbeast avatar Sep 05 '23 19:09 foodisbeast