Syncing with Leanplum mid-session

Using forceContentUpdate method to sync during a user's session, instead of just at session start.

Leanplum’s SDK is designed to sync variables, user attributes, messages, and A/B tests at the beginning of a new user session with the Leanplum.start(). This ensures from the start of a users session they will receive the latest updates, messages, and and A/B tests.

We will then, by default after the initial call to Leanplum.start(), not automatically sync these assets (variables, messages, A/B tests) in the middle of a user’s session. Our SDK was designed this way with efficiency in mind. By only requiring one call to the Leanplum servers for an entire session, this will keep your app as stable as possible and not alter the user experience in your app.

For most cases, syncing on start is the best and easiest way to keep variables, messages and A/B test segments up-to-date.


A session starts when a unique user has opened the app and initialized Leanplum (calling Leanplum.start). The session end is defined by 30 minutes or more inactivity after the app is backgrounded. A session will also end if the app remains open but inactive for two or more hours. A force quit of the app (killing the app) also counts as a session end.

forceContentUpdate Method

While most use cases can be best handled with syncing with Leanplum.start(), there may be some cases, however, where you are required to update which variables, messages or A/B tests a user should receive mid-session. In these use cases, you will want to ensure a user is appropriately targeted and/or included in a test.

Examples of such use cases include:

  • when a user comes back from backgrounding the app (and something may have changed server-side)
  • when a user levels up in a game (State or Event change)
  • when a user goes from a silver member to gold (User Attribute change)

In these cases, you sync with Leanplum mid-session by calling the Leanplum.forceContentUpdate() method. This methods will sync variables, user attributes, messages, and A/B tests. Once forceContentUpdate() is executed, any callback you have implemented, such as onVariablesChanged, will once again be invoked again automatically.


Calling forceContentUpdate will update all of your variables, user attributes, messages and A/B tests, so it can (depending on how your app is set up to work with Leanplum) affect the functionality and UI of your app. Make sure you consider this when implementing forceContentUpdate.

Unity syncing and batching

When using Unity, the data will be synced on Leanplum.Start and Leanplum.ForceContentUpdate as for native SDKs.
The data is batched and sent on OnApplicationPause and OnApplicationQuit events. The OnApplicationPause is triggered by focus/unfocus Unity, when playing in the Unity Editor.
When running on mobile devices, the native background and resume are used.