How can I listen to Growthbook-proxy using Swift? ...
# ask-questions
m
How can I listen to Growthbook-proxy using Swift? I couldn't find any samples on the documentation, or any public APIs that look like what I need.
f
@happy-autumn-40938 is this supported?
h
Not currently. Streaming/proxy support is still fairly new, and we only officially support streaming in the JS and React SDKs
You can roll your own subscription listener if you’d like though. I could provide some guidance on what you’d need to do
m
I'm currently preparing a Proof of Concept at the company where I work. I would greatly appreciate any guidance or advice, even if it's just to help me estimate the effort required @happy-autumn-40938
f
For a POC you could consider just using the regular cdn method
h
Full disclosure, I am not hugely familiar with the Swift SDK. But it seems like you should be able to get something working with a bit of effort. High level... 1. Streaming (via the proxy) relies on Server Sent Events. You will need some code that lives alongside your SDK to subscribe to your steaming endpoint. There is a GET endpoint on the proxy for subscribing using SSE of the form
https://<proxyurl>/sub/sdk-abcd1234
2. On streaming updates, you would need to manually update the SDK with the latest features. I believe you'd use the SDK's public method
featuresFetchedSuccessfully(features, isRemote)
to pass down the latest features.
Some info I found about using event source in Swift. I think your implementation would be much simpler though, no passed headers, only one type of callback. https://nickarner.com/notes/working-with-server-sent-events-in-swift-november-16-2021/
m
I'll give a try thanks @happy-autumn-40938 and @fresh-football-47124. Really appreciate