Hello everyone Is there a way to implement a realt...
# sdk-swift
m
Hello everyone Is there a way to implement a realtime feature listener? i want to be able to toggle a feature on/off for all users at once, currently iam using the
refreshHandler
call back in the GrowthBookBuilder initialiser to listen on changes, whenever it is called i use the
isOn
function on all my feature keys that i want, but after some minutes in a session, it stops sending call backs in refreshHandler, why is that and is there a way to implement what i need?
this is my implementation for reference
Copy code
import Foundation
import GrowthBook

class FeatureToggleManager {

    static let shared = FeatureToggleManager()

    private var sdkInstance: GrowthBookSDK?

    @Published var isYourpartsOn = true
    @Published var isMaydayOn = true

    private init() {}

    func initFeatureToggle() {
        sdkInstance = GrowthBookBuilder(
            apiHost: "https://" + (getPlistString(key: Constants.InfoKeys.growthbookApiHost) ?? ""),
            clientKey: getPlistString(key: Constants.InfoKeys.growthbookClientKey),
            attributes: [:],
            trackingCallback: { experiment, experimentResult in },
            refreshHandler: { isRefreshed in
                debugPrint(isRefreshed)
                self.isYourpartsOn = self.isFeatureEnabled("yourparts-ios")
                self.isMaydayOn = self.isFeatureEnabled("mayday-ios")
            },
            backgroundSync: true).initializer()
    }

    func isFeatureEnabled(_ featureKey: String) -> Bool {
        return sdkInstance?.isOn(feature: featureKey) ?? true
    }
}
c
Hi, @mammoth-wolf-34989. Thank you for providing detailed information about the issue. We will review the matter with the refreshHandler and get back to you.
🙏 1
m
Hello @calm-dog-24239, Hope you are doing well. I want to followup on this issue, is there available another implementation or walk-around that i could implement unit the issue is resolved ? Thanks in advance.
c
Hi, @mammoth-wolf-34989. Our team will take a look, and I’ll get back to you with feedback. Additionally, we are checking the issue you mentioned with the interrupted connection and the refreshHandler working even after 10 hours. Could you please specify the platform and version you are using?
We found an issue with backgroundSync and fixed it. Now we are uploading the new release with the version of 53.
m
the issue is fixed in the new version thanks @calm-dog-24239 🙏 i just was wondering if this is the best way to implement feature flagging using Growthbook?
🙌 1
c
Are you using an SSE connection or not?
m
in my iOS app no