Data flushing for MAUI SDK
Control how the Bloomreach MAUI SDK uploads cached data to the API. Choose a flushing mode, set the flush period, and trigger a manual flush in your app.
Data flushing
The SDK caches data (sessions, events, customer properties, etc.) in an internal database and periodically sends it to the Marketing API. After the SDK uploads the data, the values in the Marketing web app are updated. The SDK then removes the cached data from its internal database. This process is called data flushing.
By default, the SDK automatically flushes the data as soon as it's tracked or when the app is backgrounded. You can configure the flushing mode to customize this behavior.
You can also turn off automatic flushing completely. In this case, you must manually flush every time there's data to flush.
The SDK flushes data only when the device has a stable network connection. If a connection error occurs while flushing, the SDK keeps the data cached until the connection is stable and the data is flushed successfully.
Flushing modes
The SDK supports the following four flushing modes, defined in BloomreachSDK/Lib/Models/FlushMode.cs. They specify how often, or whether, the SDK flushes data automatically.
| Name | Description |
|---|---|
FlushMode.Immediate (default) | Flushes all data immediately as it's received. |
FlushMode.Period | Flushes data in the interval specified using SetFlushPeriod(TimeSpan) and when the app is closed or goes to the background. |
FlushMode.AppClose | Flushes data any time the app resigns active state. |
FlushMode.Manual | Disables any automatic upload. It's the responsibility of the developer to flush data manually. |
To set the flushing mode, initialize the SDK first, then call the SetFlushMode() method with the desired mode as a parameter:
Bloomreach.BloomreachSDK.SetFlushMode(FlushMode.Manual);When you use flush mode FlushMode.Period, the default interval depends on the platform:
- Android: 60 minutes.
- iOS: 5 minutes.
To specify a different interval, call the SetFlushPeriod() method with a TimeSpan value as a parameter:
Bloomreach.BloomreachSDK.SetFlushMode(FlushMode.Period);
Bloomreach.BloomreachSDK.SetFlushPeriod(new TimeSpan(0,10,0)); // 10 minutesOn iOS, SetFlushPeriod() also switches the flushing mode to FlushMode.Period.
To read the current flushing mode and interval, use GetFlushMode() and GetFlushPeriod():
FlushMode mode = Bloomreach.BloomreachSDK.GetFlushMode();
TimeSpan period = Bloomreach.BloomreachSDK.GetFlushPeriod();The returned interval depends on the platform:
- Android:
GetFlushPeriod()returns the interval in every flushing mode. - iOS:
GetFlushPeriod()returns the interval only inFlushMode.Period. In other modes, it returnsTimeSpan.Zero.
Manual flushing
To trigger a data flush to the API manually, use the following method:
bool flushed = await Bloomreach.BloomreachSDK.FlushData();The task returns false if the upload failed, for example without a network connection.
Updated 1 day ago

