Sharing
share(content)
Section titled “share(content)”Call the system share function.
SuperSDK.share('Text to share');requestShortUrl(url, baseUrl?)
Section titled “requestShortUrl(url, baseUrl?)”Generate short links. Convert long URLs into short links for easier sharing.
// Use default prefixconst shortUrl = await SuperSDK.requestShortUrl('https://example.com/very/long/path?param=value');console.log(shortUrl);// "https://s.supersdk.com/AbCd12"
// Use custom prefixconst shortUrl2 = await SuperSDK.requestShortUrl('https://example.com/very/long/path', 'https://s.a.com/');console.log(shortUrl2);// "https://s.a.com/AbCd12"Parameter Description:
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Original long link |
| baseUrl | string | No | Custom 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}requestShortUrlWithHtml(html, baseUrl?)
Section titled “requestShortUrlWithHtml(html, baseUrl?)”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 prefixconst shortUrl = await SuperSDK.requestShortUrlWithHtml('<html><body><h1>Hello World</h1></body></html>');console.log(shortUrl);// "https://s.supersdk.com/XyZ789"
// Use custom prefixconst shortUrl2 = await SuperSDK.requestShortUrlWithHtml('<h1>Campaign page</h1>', 'https://s.a.com/');console.log(shortUrl2);// "https://s.a.com/XyZ789"Parameter Description:
| Parameter | Type | Required | Description |
|---|---|---|---|
| html | string | Yes | HTML content (full document or fragment) |
| baseUrl | string | No | Custom 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}