Skip to main content

Share API

Share API​

share(options)​

Opens the platform share sheet with a template ID and arguments (message metadata such as title, description, thumbnail, button text) agreed with the platform. It is unrelated to rewards (for rewarded sharing use the unified rewarded slot with action=SHARE) and is meant for shares whose content differs per call, such as multiplayer invitations. The platform handles the share UI; the SDK only receives the result.

Options:

ParameterTypeRequiredDescription
templateIdstring | number✅Template identifier — a positive integer (1 or more, a Kakao message template ID) or a 1–64 character string ('default' = the game's default template; anything else is a template name registered with the platform). How 0 and unregistered names are handled follows the per-host table below
templateArgsRecord<string, string>-Template arguments — string keys and values, at most 32 entries, 2048 characters per value, 8192 characters serialized in total (lengths are counted in UTF-16 code units)
successfunction-Success callback — success means "the share sheet was opened"
failfunction-Failure callback
completefunction-Completion callback

Success Response:

FieldTypeDescription
completedboolean (optional)Whether the share completed — present only when the platform can tell (table below)
errMsgstringResult message

Behavior per host:

HostHow templateId is interpretedcompleted
KakaoTalkA positive integer (Kakao message template ID), 'default', or a registered template name. templateArgs (TITLE, DESCRIPTION, THU, BUTTON_TEXT, etc. — varies by template) override the game's registered values; the launch link is set by the platform. However, arguments registered as link parameter keys (such as a room code) go into the launch link's query rather than the message body — keys may contain only letters, digits, _ and - (≤64 chars), values are arbitrary strings of ≤512 chars, at most 20 parameters and 2048 chars of parameters in total (6144 chars after URL encoding); reserved keys (referer, t_src, t_ch, t_obj, code, state, authCode, error, etc.) cannot be used, empty-string values are simply not sent (not a failure), and a constraint violation fails with share unavailable. Unregistered names and 0 fail with unknown templateIdAbsent — the sheet does not report completion or cancellation
KakaoPayGames without registered templates share TITLE and DESCRIPTION plus the platform link as text regardless of templateId (other arguments are ignored). For games with registered templates, 'default' and positive integers share as text (this path carries no link parameters, so send invitations through a named template), a registered name opens the KakaoTalk share sheet (KakaoPay app 26.7.0 or later — older apps and outside the app fall back to text) where the game's text/image arguments (TITLE, DESCRIPTION, THU, BUTTON_TEXT) are ignored and only the approved registered copy is sent — only arguments registered as link parameter keys are put into the link (keys and values of 1–64 letters, digits, _ or -, at most 20 parameters, link ≤2048 chars — otherwise invalid deeplink params; empty-string values are simply not sent (not a failure), and the keys code, _hash and share_link are accepted on send but dropped by the receiver, so do not use them). Unregistered names and 0 failMeans the sheet was opened and closed (not a completion guarantee)
monimotemplateId and arguments are ignored; the platform's fixed link is sharedWhether the share actually happened
Other hosts (environments whose servicePlatform is house)Depending on the platform, templateId and arguments are ignored and the platform's fixed link (or TITLE/DESCRIPTION text) is shared through the OS share sheet, or sharing is unsupported and the call fails with fail. They cannot be told apart by the servicePlatform value, so handle the failureWhether the share actually happened when shared through the OS (when no OS share sheet is available it is false after falling back to copying the link, or may be absent on success); - when unsupported
TudadaSDK.share({
templateId: 'default',
templateArgs: { TITLE: 'Play with me!', DESCRIPTION: 'Room code ABCDEF' },
success: (res) => console.log('Share sheet opened, completed:', res.completed),
fail: (err) => console.warn('Share failed:', err.errMsg),
});

shareAsync(options)​

Promise version of template share. Resolves with { completed? } on success and rejects with { errMsg } on failure.

Options: Same as share(options) without success, fail and complete.

Return Value (Promise<ShareResult>):

FieldTypeDescription
completedboolean (optional)Whether the share completed — see the table above for the meaning per host
try {
const res = await TudadaSDK.shareAsync({
templateId: 'default',
templateArgs: { TITLE: 'Play with me!', DESCRIPTION: 'Room code ABCDEF' },
});
console.log('Share sheet opened, completed:', res.completed);
} catch (err) {
console.warn('Share failed:', err.errMsg);
}

Deprecated

The reward-based share API (shareForReward / shareForRewardAsync) has been replaced by the unified rewarded slot and is kept for compatibility. For new integrations, retrieve slots with getRewardedAdSlots() and run them via showRewardedAd({ slotId }) (action=SHARE).

shareForReward(options)​

Executes a reward-based share. The share UI and reward decision are handled by the platform; the SDK only receives the final result.

Options:

ParameterTypeRequiredDescription
urlstring-URL to share
successfunction-Success callback
failfunction-Failure callback
completefunction-Completion callback

Success Response:

FieldTypeDescription
rewardedbooleanWhether reward was granted
errMsgstringResult message
TudadaSDK.shareForReward({
url: 'https://example.com/share',
success: (res) => {
if (res.rewarded) {
console.log('Share complete - reward granted');
}
},
fail: (err) => console.error('Share failed:', err.errMsg),
});

shareForRewardAsync(options)​

Promise version of reward-based share.

Options:

ParameterTypeRequiredDescription
urlstring-URL to share

Return Value (Promise<ShareForRewardResult>):

FieldTypeDescription
rewardedbooleanWhether reward was granted
const result = await TudadaSDK.shareForRewardAsync();
if (result.rewarded) {
console.log('Share complete - reward granted');
}