Naufal Rajabi
Naufal Rajabi

Reputation: 464

Growthbook immediate update on mobile app

I use Growthbook to maintain my feature toggle and some other remotely configured values on my Flutter app. I successfully connect the app by using the provided SDK and connection keys.

I created some "features" on the Growthbook UI, and tested out some changes on the features, and then published the changes. However, in the client app the changes doesn't happen immediately. The client should close and reopen the app to get the new value of the features.

In the code, I only call initialize() once, that is when the app started then use the same instance to get the value of the features at runtime.

Future<GrowthBookSDK> get gbApp => GBSDKBuilderApp(
        hostURL: Env.gbHostUrl,
        apiKey: Env.gbClientKey,
        growthBookTrackingCallBack: (gbExperiment, gbExperimentResult) {
          //  TODO: adding gb analytics callback
        },
      ).initialize();

Is there any way or configuration that can make the features update sent to the client App immediately after getting published (so the client doesn't have to reopen the app)? Or should we initialize the SDK first before getting the features value to make it happen?

Thanks in advance.

Upvotes: 1

Views: 897

Answers (1)

Angel Lam
Angel Lam

Reputation: 11

Recently, I have come across the same problem, where I needed the live update on my web app until I came across the same scenario. There isn't much on the documentation, so I don't know if this also applies to Flutter, however I think this might help some people:

There is a property on growthbook.loadFeatures called autoRefresh; set this to true, and any change done on the growthbook features will update live in a few seconds!

If, for some reason, you need to get the features on an specific navigation or action, you can also call growthbook.refreshFeatures().

I found some documentation within this sentence on the docs:

Until features are loaded, all features will evaluate to null. If you're ok with a potential flicker in your application (features going from null to their real value), you can call loadFeatures without awaiting the result.

Upvotes: 1

Related Questions