Supported from Base Library 2.14.3 onwards
Supported Platforms: Android
Client Version: Opening Mini Program in webview requires WeChat 7.0.22 or later; opening Mini Program for files and videos requires WeChat 8.0.0 or later; opening Mini Program for images requires WeChat 8.0.1 or later
Supported Types: Mini Program only; WeChat Mini Games are not supported
Feature Overview
An entry to open materials (files, images, videos, and webviews) within WeChat chats using Mini Program has been added. Users can use Mini Program to process files, images, videos, and webviews in chats. For example, using Mini Program to save files to the cloud drive, apply filters to images, edit videos, or save webviews to notes, etc. Currently, only images without QR codes support being opened directly via Mini Program.
When a user opens materials in a WeChat chat, the entry to open them using Mini Program will appear if Mini Program is configured to support that material type, has passed review, and the user has previously used that Mini Program.
In PC environments where the base library version is greater than 3.7.6, users can trigger Mini Program to open by dragging and dropping files. After dragging in a file that meets the rules, the framework side will reLaunch the Mini Program. If the dragged file does not meet the rules, the framework side will prompt the user that the file is not supported.
Usage Instructions
Developers must declare the supported file types in the Mini Program Global Configuration(app.json). Only one processing method can be declared for a specific file type.
{
"supportedMaterials": [
{
"materialType": "text/html",
"name": "Open with ${nickname}",
"desc": "Description",
"path": "pages/index/"
},
{
"materialType": "video/*",
"name": "Play with ${nickname}",
"desc": "Description",
"path": "pages/index/"
},
{
"materialType": "video/mp4",
"name": "Play with ${nickname}",
"desc": "Description",
"path": "pages/index/"
}
]
}
| Property | Type | Required | Description |
|---|---|---|---|
| materialType | String | Yes | The MimeType of the supported file type. Audio and video support wildcard mode for secondary configuration, e.g., video/*. If both wildcard mode and exact type configurations exist, the exact type configuration takes precedence (e.g., if both video/* and video/mp4 exist, the configuration for video/mp4 is used first). |
| name | String | Yes | The title configured by the developer, which will be displayed on the material page. The configuration must include ${nickname}, which will be automatically replaced with the Mini Program name after code package compilation. If an abbreviation is declared, it will be prioritized over the Abbreviation. Apart from ${nickname}, the remaining characters must not exceed 6. |
| desc | String | Yes | A description of the usage, which will be displayed in the recommendation list. The character count must not exceed 22. |
| path | String | Yes | The page to navigate to when opening Mini Program in this scenario |
MimeType types supported by the latest client version:
| MimeType | File Extension | Description |
|---|---|---|
| video/* | Video files | |
| audio/* | Audio files | |
| image/* | Image files | |
| text/html | Webview | |
| text/plain | .txt | |
| text/markdown | .md | Markdown file |
| application/* | Generic file configuration | |
| application/pdf | ||
| application/msword | .doc | |
| application/vnd.openxmlformats-officedocument.wordprocessingml.document | .docx | |
| application/vnd.ms-word.document.macroEnabled.12 | .docm | |
| application/vnd.ms-excel | .xls | |
| application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | .xlsx | |
| application/vnd.ms-excel.sheet.macroEnabled.12 | .xlsm | |
| application/vnd.ms-powerpoint | .ppt | |
| application/vnd.openxmlformats-officedocument.presentationml.presentation | .pptx | |
| application/zip | .zip | |
| application/vnd.rar | .rar | |
| application/x-7z-compressed | .7z | |
| application/x-photoshop | .psd | |
| application/acad | .dwg | |
| application/x-cdr | .cdr | |
| application/dxf | .dxf | |
| application/step | .stp | |
| application/rtf | .rtf | |
| application/postscript | .ai |
Mini Program Startup Parameters
The scene value in Mini Program Startup Parameters is 1173. In this scene, there is an array forwardMaterials at the same level as the startup parameters and query, representing forwarded file information. Each object in the array contains the attributes {type,name,path,size}, representing file type, file name, file path or URL, and file size, respectively.
Publishing
When submitting Mini Program for review, the declared supportedMaterials are audited for compliance. The entry point for opening the corresponding file types will only appear after Mini Program is published and goes live.
If the features implemented in Mini Program have low value, they will not pass the review. This includes, but is not limited to, the following scenarios:
-
The functionality after opening
Mini Programis unrelated to the corresponding material: It simply uses this entry point to open your ownMini Programwithout performing any processing on the material. -
The method of processing the material after opening
Mini Programis too simple: For example, merely playing a video or viewing a.docx file are simple functions that can be achieved through WeChat chat alone.
Developers are advised to adapt their solutions based on the specific features of their Mini Program and user needs.
Debugging
Experience Version
The Experience Version Mini Program supports configuring supportedMaterials independently. Its Mini Program configuration is separate from that of the Release Version. Consequently, the corresponding entry Mini Program list will also display the Experience Version Mini Program separately.
Developer Tools
Developers can debug this feature using the scene value 1173 in custom compilation mode.