> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/common/growth/share/miniapp-share-link.md).

# Mini App 分享链接

`getTossShareLink` 函数会将用户指定的路径 **转换为可在 Toss 应用中打开的分享链接**。把这个链接传给他人时，Toss 应用会启动，并会 **直接跳转到指定的深度链接页面**可以。

如果未安装 Toss 应用，则会按如下方式运行。

* iOS → **App Store**跳转
* Android → **Google Play 商店**跳转

路径是指向 Toss 应用内部页面的 **深度链接(deep link)** 格式。例如可以按如下方式编写。

```
intoss://<应用名>
intoss://<应用名>/about?name=test
```

另外 `ogImageUrl`如果指定它，就可以在 SNS、聊天工具等外部平台分享时显示的 **预览图(OG 图片)** 可以直接设置。由于 OG 图片在各平台上的裁剪方式和缓存特性不同，为了在分享时按预期展示，请遵循以下内容。

* 图片 URL 必须是 `https://`以 **绝对路径**开头。
* **各平台推荐尺寸** · `关于比例、文件格式、文件大小等详细规则，请查看内部文档中的 OG 图片规则并据此应用。`

如果 OG 图片设置错误，预览可能会与预期不符，或在某些平台上完全不显示，请注意。

{% hint style="info" %}
**缓存相关说明**

外部平台会缓存 OG 元数据（图片/标题/描述），因此，曾经分享过的链接可能不会立即反映变更。如果需要快速生效，请使用各平台提供的 **调试工具**手动清除缓存。

* Kakao Debugger → <https://developers.kakao.com/tool/debugger/sharing>
* Facebook Debugger → <https://developers.facebook.com/tools/debug/>
  {% endhint %}

**签名**

```typescript
function getTossShareLink(url: string, ogImageUrl?: string): Promise<string>;
```

**参数**

* **url** · 必填

  是想通过深度链接打开的路径。 `intoss://` 开头的字符串。
* ogImageUrl string

  分享时在预览图(OG)中显示的图片 URL。 `https://` 必须是以

**返回值**

* `Promise<string>`

  `包含 deep_link_value`的 Toss 分享链接。

**示例**

{% tabs %}
{% tab title="js" %}

```js
import { share, getTossShareLink } from '@apps-in-toss/web-framework';

async function handleShare() {
  const tossLink = await getTossShareLink(
    'intoss://my-app',
    'https://static.toss.im/icons/png/4x/icon-share-dots-mono.png',
  );

  // 将生成的链接作为消息分享。
  await share({ message: tossLink });
}
```

{% endtab %}

{% tab title="React" %}

```tsx
import { share, getTossShareLink } from '@apps-in-toss/web-framework';
import { Button } from '@toss/tds-mobile';

function ShareButton() {
  async function handleClick() {
    const tossLink = await getTossShareLink(
      'intoss://my-app',
      'https://static.toss.im/icons/png/4x/icon-share-dots-mono.png',
    );

    // 将生成的链接作为消息分享。
    await share({ message: tossLink });
  }

  return <Button onClick={handleClick}>分享</Button>;
}
```

{% endtab %}

{% tab title="React Native" %}

```tsx
import { share, getTossShareLink } from '@apps-in-toss/framework';
import { Button } from '@toss/tds-react-native';

function ShareButton() {
  async function handleClick() {
    const tossLink = await getTossShareLink(
      'intoss://my-app',
      'https://static.toss.im/icons/png/4x/icon-share-dots-mono.png',
    );

    // 将生成的链接作为消息分享。
    await share({ message: tossLink });
  }

  return <Button onPress={handleClick}>分享</Button>;
}
```

{% endtab %}
{% endtabs %}

**体验示例应用**

[apps-in-toss-examples](https://github.com/toss/apps-in-toss-examples) 在仓库中 [with-share-link](https://github.com/toss/apps-in-toss-examples/tree/main/with-share-link) 下载代码，或扫描下方二维码亲自体验。

二维码链接: intoss\://with-share-link

### 发布前测试指南

`intoss://` scheme 是 **只能在应用正式发布后访问。** 为了在发布前测试功能，请使用上传时生成的 **测试 scheme（二维码）** 。

**① 在二维码中 `deploymentId` 查看**

每次上传应用 bundle 时，都会发放新的 `deploymentId`。在测试 scheme 中， `_deploymentId` 是必填参数。

示例：

```
intoss-private://appsintoss?_deploymentId=0198c000-68c3-7d2b-0000-2c00000005ec
```

**② 将 path/query 应用到 scheme 中进行测试**

* 应用子 path 时：

```
intoss-private://appsintoss/path/pathpath?_deploymentId=0198c000-68c3-7d2b-0000-2c00000005ec
```

* 应用查询参数时：queryParams 必须进行 URL 编码。

```
intoss-private://appsintoss?_deploymentId=0198c000-68c3-7d2b-0000-2c00000005ec&queryParams=%7B%22categoryKey%22%3A%22
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-zh/common/growth/share/miniapp-share-link.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
