Skip to content

Platform events

AI Summary

A short gist of this page, generated for you.

Powered by AI. Summaries can miss nuance — when in doubt, read the page.

Funox can tell your game when something changes around it. Subscribe with FunOxSDK.on().

These events are only sent on Funox. None arrive in standalone mode.

#Events

Event Data When
pause — Funox wants the game paused
resume — The game may continue
mute — Funox wants the game silent
unmute — Sound may play again
userChanged { user } The player logged in or out. Also fires once shortly after init()
focus — The tab became visible
blur — The tab was hidden

#Listening

javascript
FunOxSDK.on('pause', function () {
  pauseGameLoop();
  pauseAudio();
});

FunOxSDK.on('resume', function () {
  resumeGameLoop();
  resumeAudio();
});

FunOxSDK.on('mute', function () {
  setVolume(0);
});

FunOxSDK.on('unmute', function () {
  setVolume(1);
});

FunOxSDK.on('userChanged', function (data) {
  // data.user — the player, or null after logout
  if (data.user) {
    updatePlayerName(data.user.name);
  } else {
    showGuestMode();
  }
});

FunOxSDK.on('blur', function () {
  pauseGameLoop();
});
Do not rely on these for your own ad calls

Pause and mute the game yourself around commercialBreak() and rewardedBreak(). Do not wait for a pause or mute event to do it.

#Removing listeners

javascript
function myPauseHandler() { /* ... */ }

FunOxSDK.on('pause', myPauseHandler);

// Remove one handler
FunOxSDK.off('pause', myPauseHandler);

// Remove every handler for one event
FunOxSDK.offAll('pause');

// Remove every handler for every event
FunOxSDK.offAll();

Remove listeners when you leave a scene. Registering the same handler again each time a scene starts makes it fire several times.