Last modified February 13, 2019 by Shelly Wolfe

SDK integration best practices

This article provides recommendations on how to optimize your Swrve integration. For more information about Swrve integration, see the following articles:


New session interval

The default new session interval is 30 seconds. That is, Swrve automatically treats an app session as a new session if the user has returned to the app after having left it for 30 seconds. Swrve recommends this default value as users tend to lose focus on the app when they have stopped using it for half a minute. For information on how to customize the new session interval, see How do I configure the new session interval?


Session start timeout

The default session start timeout (the time that in-app messages have to load and display after the session has started) is 5 seconds. Swrve recommends this default value so that session start messages don’t interrupt the user flow. If a user is on a slow connection, the in-app message is cached and displayed immediately when they next open the app.


Send events interval

The SDKs send user events automatically at app start-up and at each 60-second interval thereafter (this interval value may change as it is configurable by Swrve’s servers). If you decide to disable this feature, Swrve recommends that you send events each minute as events have a significant impact on the segments to which users are assigned. Segments must be up to date if they are to have an impact on your audience.


Refresh campaigns and user resources

User resources and campaigns are reloaded automatically by the SDKs at app start-up and at each 60-second interval thereafter (this value may change as it is configurable by Swrve’s servers). If you decide to disable this feature and if you have any campaigns (such as in-app messages or A/B tests) that are based on user segments, Swrve recommends that you reload campaigns at app start-up and on a constant basis thereafter.


Flush to disk on application pause

Events are flushed to disk automatically on application pause. You should flush events to disk to avoid any event loss when the application is either paused or closed.


Send events on application resume

Events are sent automatically on application resume. As soon as the app is active again, you should immediately send events that were flushed to disk on application pause.