App Lifecycle
How the SDK follows the app between foreground and background, and when to call shutdown.
The SDK observes the app lifecycle itself. configure() starts watching the app (UIApplication notifications on iOS, ProcessLifecycleOwner on Android; React Native and Flutter run on those same native SDKs), so there is nothing to wire:
- In the foreground, the SDK polls entitlements, virtual currencies and remote config, and sends queued attributes and session events every ~30 s. Returning to the foreground refreshes at once instead of waiting out the interval.
- On entering the background, polling pauses and the SDK flushes queued attributes and session events once, so a value written just before the app is backgrounded reaches the server without a relaunch. On iOS this runs inside a background task. Anything that does not make it is kept on the device and sent on the next foreground. A refused API key (401/403, for example after a key roll or expiry) also keeps queued attributes, session events and funnel events on the device; the SDK then waits between attempts (1 s, doubling to about 4 min) instead of re-sending them on every tick.
React Native also records session events (open, background, close) automatically from AppState.
Types on this page
These are void methods with no return value. Full definitions: Methods reference → Lifecycle.
| Method | Signature (RN) | Effect |
|---|---|---|
setForeground | setForeground(active: boolean) | Not needed. A manual override of the foreground state, honoured until the next lifecycle transition. |
shutdown | shutdown() | Stops the SDK's background work — polling and lifecycle observation. It does not flush; queued attributes and events stay on the device. |
Call shutdown only on teardown
You rarely need shutdown(): calling configure() again already replaces the previous instance. Reserve it for tearing the SDK down for good — never call it on a background transition.
Rovenue.shutdown();Rovenue.shared.shutdown()Rovenue.shared.shutdown()shutdown() also cancels the SDK's internal Task (Swift); a configure-twice cancels the internal coroutine scope (Kotlin). Any change-stream collectors running inside those scopes will stop. See Reacting to changes for correct collector wiring.