Manually flush your stored events by leveraging the flush API.
3 minute read
This guide walks you through the flush API and the different event flushing policies supported by the RudderStack Kotlin and Swift SDKs.
Overview
The RudderStack Kotlin and Swift SDKs provide a flush API that lets you manually flush any stored events irrespective of the configured flush policies.
You can trigger a flush API call as follows:
analytics.flush()
The corresponding Java snippet is shown below:
analytics.flush();
analytics.flush()
The corresponding Objective-C snippet is shown below:
[analyticsflush];
If you have added a mobile device mode integration plugin, then a flush API call will also trigger the integration’s flush API, if it is supported.
Flush policies
RudderStack supports three configurable flush policies. By default, all three policies are enabled.
Count flush policy
The CountFlushPolicy triggers a flush call when a predefined threshold for the event count is reached.
Flush policies
Data type
Notes
flushAt
Integer
The value of this parameter must be within the range of 1 to 100 - the default value is 30.
Frequency flush policy
The FrequencyFlushPolicy automatically triggers a flush at the specified intervals.
Flush policies
Data type
Description
flushIntervalInMillis
Long
Minimum allowed value is1 millisecond - the default value is 10 seconds.
Startup flush policy
The StartupFlushPolicy automatically triggers a one-time flush API call after the Kotlin SDK is initialized.
Set a flush policy
You can select and set a flush policy depending on your use case.
Selecting a flush policy from the provided list overrides the default flush policy.
The following examples highlight how you can set the FrequencyFlushPolicy in the Kotlin and Swift SDKs:
Add FrequencyFlushPolicy during the SDK initialization, as shown below. Replace the WRITE_KEY and DATA_PLANE_URL parameters in the below snippet with the Kotlin source write key and your data plane URL.
Add FrequencyFlushPolicy during the SDK initialization. Replace the WRITE_KEY and DATA_PLANE_URL parameters in the below snippet with the Swift source write key and your data plane URL.
Add FrequencyFlushPolicy during the SDK initialization. Replace the WRITE_KEY and DATA_PLANE_URL parameters in the below snippet with the Swift source write key and your data plane URL.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.