> 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).

# 迷你应用分享链接

`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`返回包含 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.
