Skip to content

Sharing

AI Summary

A short gist of this page, generated for you.

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

Players who share your game bring new players. The SDK opens the device's share sheet where one exists, and copies the link otherwise.

#shareGame(options?)

Shares a link to your game's page on Funox.

javascript
FunOxSDK.shareGame({
  text: 'I just scored 9500 in Ninja Jump! Can you beat me?'
}).then(function (result) {
  if (result.shared) {
    showMessage('Thanks for sharing!');
  }
});

result.shared is false when the player cancels.

#shareResult(options)

Shares a specific result, such as a score or a quiz outcome. Funox builds a link to your game's page with your values attached.

Option Type Description
params object Key/value pairs describing the result. Values are converted to strings
text string Optional message for the share sheet
title string Optional title. Defaults to the game's name
javascript
FunOxSDK.shareResult({
  params: { score: 9500, level: 12 },
  text: 'I scored 9500 in Ninja Jump! Can you beat me?'
}).then(function (result) {
  // result.shared — true if the link was shared or copied
  // result.method — 'native' or 'clipboard'
  // result.url    — the link that was shared
});

#Reading shared values

When someone opens that link, Funox passes the values to your game in the URL hash. Read them when the game starts:

javascript
var shared = new URLSearchParams(window.location.hash.slice(1));
if (!shared.has('score')) {
  // Standalone mode: the values arrive in the query string instead
  shared = new URLSearchParams(window.location.search);
}
if (shared.has('score')) {
  showChallengeScreen(Number(shared.get('score')));
}

Shared values come from a link anyone can edit. Treat them as display data, never as proof of a score.

#getShareUrl(options)

Builds the same link as shareResult() without opening a share sheet. Use it when your game draws its own share buttons.

javascript
FunOxSDK.getShareUrl({ params: { score: 9500 } }).then(function (result) {
  copyToClipboard(result.url);
});

#Good practice

  • Offer sharing after a good moment — a win, a high score — not before the player has played.
  • Never make sharing a condition for playing or for a reward.