Hi Team, 2 of our biggest Enterprise customers are...
# sdk-swift
f
Hi Team, 2 of our biggest Enterprise customers are requesting error handling and retry logic in the Swift SDK related to this GitHub issue. The customers use case is in the screenshot. Is there a workaround solution that we can provide or is this on the roadmap?
c
Hi @flaky-noon-11399. Please let us check that right now.
f
Thank you @calm-dog-24239 πŸ™
πŸ™Œ 1
c
We’re currently working on extending the Swift SDK to support authenticated use cases by allowing developers to pass a
tokenProvider
and an
onTokenExpired
callback directly through the
GrowthBookBuilder
initializer, like this:
Copy code
GrowthBookBuilder(
   ...
    tokenProvider: {
        return TokenStorage.shared.token
    },
    onTokenExpired: {
        TokenStorage.shared.updateToken()
    }
)
This will allow the SDK to automatically include the provided token in all requests, and to handle
401 Unauthorized
responses by invoking the refresh callback and retrying the request with a new token.
f
Thank you @calm-dog-24239 I'll let the customers know its in the works πŸš€
πŸ™Œ 1
c
Hi @flaky-noon-11399, We’ve just created a PR that addresses this need. It adds support for passing a custom authentication token, an
onTokenExpired
callback to refresh the token when needed, and also the ability to provide any additional headers required for your use case. We chose this approach to give users full flexibility in how they manage their authentication logic β€” since token handling can vary significantly across implementations. When a
401
response is detected, the
onTokenExpired
callback is triggered, allowing you to plug in any custom token refresh logic that fits your infrastructure. This should serve as a robust workaround for authenticated requests and simplify retry handling tied to token expiration. Let us know if you have any feedback or further requirements!
f
Thank you @calm-dog-24239!! That's amazing!! I'll let the customer know πŸš€
πŸ™Œ 1
c
You are welcome.