Hi Team, My name is Amarnath Mamidibattula, and I...
# ask-questions
b
Hi Team, My name is Amarnath Mamidibattula, and I am a Lead Mobile Engineer of the Little Caesars Mobile Team. We are relatively new to the Growth Book and are attempting to determine whether we can enable backgroundSync after a specific number of hours, such as every four hours. We have been unable to locate any documentation that provides guidance on this functionality. We would be grateful if you could assist us in this matter. Your assistance is greatly appreciated. Thank you, Amarnath Mamidibattula
s
Hey @brave-plastic-57094! Can you share which SDK you're using in particular?
b
iOS SDK
👀 1
f
Sorry, this took a bit long to provide an answer for this. There's no straight forward way to do this unless the current SDK implementation is changed. But, you could do the following to achieve it @brave-plastic-57094. First, initialize the growthbook's instance without the SSE, meaning set the
backgroundSync
to
false
. You could then create a custom SSE connection manager with a sync schedule you like.
Copy code
// Step 1: Initialize GrowthBook with backgroundSync: false
var gb = GrowthBookBuilder(
    apiHost: "<https://cdn.growthbook.io>",
    clientKey: "sdk-abc123",
    attributes: [:],
    trackingCallback: { experiment, result in
        // Track experiments
    },
    backgroundSync: false // Important: disable default background sync
).initializer()

// Step 2: Create a custom SSE manager (implementation details in GitHub example)
let sseUrl = "\(apiHost)/sub/\(clientKey)"
let sseManager = CustomSSEManager(growthBookSDK: gb, sseUrl: sseUrl)

// Step 3: Start background sync with custom refresh schedule (every 5 minutes)
sseManager.startBackgroundSync(syncIntervalSeconds: 300)
I understand this is not in-built feature our SDK offers at this time but this is one possible way of achieving it.
b
Thank you 🙂 I will look into this and get back to you