Skip to content

Sharing

Call the system share function.

SuperSDK.share('Text to share');

Generate short links. Convert long URLs into short links for easier sharing.

// Use default prefix
const shortUrl = await SuperSDK.requestShortUrl('https://example.com/very/long/path?param=value');
console.log(shortUrl);
// "https://s.supersdk.com/AbCd12"
// Use custom prefix
const shortUrl2 = await SuperSDK.requestShortUrl('https://example.com/very/long/path', 'https://s.a.com/');
console.log(shortUrl2);
// "https://s.a.com/AbCd12"

Parameter Description:

ParameterTypeRequiredDescription
urlstringYesOriginal long link
baseUrlstringNoCustom short link prefix, e.g., https://s.a.com/. If not provided, the default value is used.

Return value: Promise<string> - Short link string

Features:

  • Identical URLs called repeatedly return the same short link (idempotent).
  • Short links are permanently valid.
  • Timeout duration 10 seconds

Error Handling:

try {
const shortUrl = await SuperSDK.requestShortUrl('https://example.com/page');
// Use short links
} catch (error) {
console.error('Could not create short link:', error.message);
// Possible errors: URL is required, network exception, appbridge not available
}

Generate short links from HTML content. When accessing the generated short link, the HTML page is rendered directly without a 302 redirect. Suitable for scenarios such as generating dynamic share pages and activity posters.

// Use default prefix
const shortUrl = await SuperSDK.requestShortUrlWithHtml('<html><body><h1>Hello World</h1></body></html>');
console.log(shortUrl);
// "https://s.supersdk.com/XyZ789"
// Use custom prefix
const shortUrl2 = await SuperSDK.requestShortUrlWithHtml('<h1>Campaign page</h1>', 'https://s.a.com/');
console.log(shortUrl2);
// "https://s.a.com/XyZ789"

Parameter Description:

ParameterTypeRequiredDescription
htmlstringYesHTML content (full document or fragment)
baseUrlstringNoCustom short link prefix, e.g., https://s.a.com/. If not provided, the default value is used.

Return value: Promise<string> - Short link string

Features:

  • Each call generates a new short link (idempotency deduplication is not performed).
  • Short links are permanently valid.
  • HTML content size limit 1MB
  • Timeout duration 10 seconds

Error Handling:

try {
const shortUrl = await SuperSDK.requestShortUrlWithHtml('<h1>Campaign page</h1><p>Campaign details...</p>');
// Use short link sharing
} catch (error) {
console.error('Could not create short link:', error.message);
// Possible errors: HTML content is required, content exceeds size limit, network exception
}