Lifecycle & bootstrapping (Web)
The SDK needs to do three things that involve your game:
- Pause and resume the game loop — whenever an ad is shown, the tab is backgrounded, or the channel demands it.
- Mute and unmute audio — same triggers, different hook, so you can cross‑fade cleanly.
- Show a splash screen while the game loads, branded per channel.
Lifecycle hooks cover (1) and (2); the bootstrapper covers (3).
Lifecycle hooks are required
Section titled “Lifecycle hooks are required”Implement every hook — even if one ends up a no‑op for your game, set it explicitly so it’s obvious you considered it. An empty () => {} is allowed; a missing hook is not.
When they fire
| Hook | Triggered by |
|---|---|
onSuspend / onResume | Interstitial, rewarded ads. Tab/app backgrounding. |
onAudioSuspend / onAudioResume | Same triggers, but separately so you can handle audio independently (e.g. cross‑fade). |
onGamePause | Channel‑level pause events (e.g. user navigates away). |
Not every channel fires every hook — they’re best‑effort. Implement all five for maximum portability.
Bootstrapper
Section titled “Bootstrapper”init()— render the splash screen for the current channel. Resolves immediately so you can start loading.setProgress(0..1)— call as many times as you want; the splash shows a progress bar where supported.complete()— hide the splash and let your game take over.
If the splash is hidden without setProgress(1) first, the bootstrapper still completes cleanly — progress is advisory.
Init order
Section titled “Init order”The complete startup looks like:
Environments
Section titled “Environments”Pass 'dev' to init() while developing to get noisier logging and looser defaults; omit or pass 'prod' for production. See Environments.
What can I do before complete()?
Section titled “What can I do before complete()?”A rule of thumb: call any module you like after FRVR.init(). Anything that needs network (IAP catalog, cloud storage) becomes reliable once complete() has fired.
Post‑complete hook
Section titled “Post‑complete hook”If you have code that must run once FRVR has finished bootstrapping — even if you’re not the one calling complete() — register a hook:
Setting it after bootstrap has already completed runs the callback immediately.