---
name: "share"
mode: "kit"
versionRequirements:
  - { name: "BizKit", version: "3.0.0" }
platform:
  - "iOS"
async: true
---

## share

> [VERSION] BizKit >= 3.0.0

> [PLATFORM] iOS

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Share text, images, files, web pages, or mini program content via the specified channel

### Parameters

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `type` | `"WeChat" \| "Message" \| "Email" \| "More"` | No | `'WeChat'` | Sharing channel. Defaults to WeChat if not provided. Allowed values: WeChat, Message, Email, More |
| `title` | `string` | Yes | - | title Title |
| `message` | `string` | Yes | - | message Text content |
| `contentType` | `"text" \| "image" \| "file" \| "web" \| "miniProgram"` | No | `'text'` | contentType Content type |
| `recipients` | `string[]` | No | - | recipients Email recipients/SMS recipients |
| `imagePath` | `string` | No | - | imagePath Image path |
| `filePath` | `string` | No | - | File path for sharing. Used when contentType == file; omitting it will cause file sharing to fail |
| `webPageUrl` | `string` | No | - | web Used when contentType == file |
| `miniProgramInfo` | `MiniProgramInfo` | No | - | miniProgramInfo Used when contentType == miniProgram, and the share channel must be WeChat. |
| `complete` | `() => void` | No | - | Callback invoked when the API call completes (runs on success and failure) |
| `success` | `() => void` | No | - | Callback invoked when the API call succeeds |
| `fail` | `(params: Object) => void` ↓see below | No | - | Callback invoked when the API call fails |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Extended error code |
| `errorMsg` | `string` | Extended error information |


### Referenced Types

##### `interface` MiniProgramInfo

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `userName` | `string` | Yes | Username |
| `path` | `string` | Yes | Mini program page path |
| `hdImagePath` | `string` | Yes | Image URL |
| `withShareTicket` | `boolean` | Yes | Whether to include a share ticket |
| `miniProgramType` | `number` | Yes | Mini program version type, corresponding to the miniProgramType field of the underlying share object |
| `webPageUrl` | `string` | Yes | Mini Program URL |


### Valid Values

##### `type`

| Value | Description | Since |
| --- | --- | --- |
| `WeChat` | WeChat | 4.14.8 |
| `Message` | SMS | 4.14.8 |
| `Email` | Email | 4.14.8 |
| `More` | More system share channels (invoke system share) | 4.14.8 |

##### `contentType`

| Value | Description | Since |
| --- | --- | --- |
| `text` | Text | 4.14.8 |
| `image` | Image | 4.14.8 |
| `file` | File | 4.14.8 |
| `web` | Web URL | 4.14.8 |
| `miniProgram` | WeChat Mini Program share content | 4.14.8 |


### Examples

```tsx
ty.share({
  type: "WeChat",
  title: "xx",
  message: "xx",
  contentType: "text",
  recipients: [],
  imagePath: "xx",
  filePath: "xx",
  webPageUrl: "xx",
  miniProgramInfo: {},
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});
```
