Leanplum’s SDK is designed to sync variables, user attributes, messages, and A/B tests on
Leanplum.start at the beginning of a new session (see how we define a session). This ensures users receive the latest updates and messages, and that they are entered into latest A/B tests.
By default, we do not sync these values in the middle of a user’s session (after the initial call to
start). Our SDK was designed this way to keep it as efficient as possible, requiring only one call to Leanplum’s servers for an entire session, and to keep your app as stable as possible by not altering the app as your users use it.
For most cases, syncing on start is the easiest and best way to keep variables, message targeting and A/B test segments up-to-date.
However, there may be some cases where you want to update your messaging or A/B tests mid-session, to be sure a user is appropriately targeted and/or included in a test.
Some examples might be:
- 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)
For these cases, you can force a content update by calling
Leanplum.forceContentUpdate(), which syncs variables, user attributes, messages, and A/B tests. Any callbacks you have setup, like
onVariablesChanged, will be invoked again automatically.
Caution: 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. Be sure to consider this when implementing