May 18, 2021 WeChat Mini Program Development Document
Often developers want to be able to get some information, such as the identity of a group, when a small program is opened twice. N ow by calling wx.showShareMenu and setting withShareTicket to true, you can get a shareTicket in App.onLaunch or App.onShow when the forwarding card is opened by another user in a group chat after the user forwards the small program to any group chat. Forwarding information can be obtained by calling the wx.getShareInfo interface to pass in this shareTicket.
Base library 1.2.0 starts to support, and low versions need to be compatible.
By setting the property open-type"share" to the button component, the Page.onShareAppMessage event can be triggered after the user clicks the button, related component: button.
Forward buttons designed to help users share content and services with friends more smoothly. F orwarding should be user-spontaneous and within reach when needed. Developers will have a better user experience if they follow the guidelines below when using them.
More, we show the most important points, if you have time, you can fully browse Design Guide I believe there will be more gains.
Forwarding News Feeds is supported starting with the base library 2.4.0. News Feed compares regular messages to the following features:
News Feed has status, text content, and text color.
The message has two states, each with its corresponding text content and color. Where status 0 can be transferred to states 0 and 1, status 1 can no longer be transferred.
State | The content of the text | Color | The state in which the transfer is allowed |
---|---|---|---|
0 | "Members are joining, and there are currently member_count of people in room_limit. | #FA9D39 | 0, 1 |
1 | "Started" | #CCCCCC | No |
Parameters can be carried with each state transfer, as described below.
Parameters | Type | Description |
---|---|---|
member_count | string |
When status 0 is valid, the value of the text
member_count
the text template
|
room_limit | string |
When status 0 is valid, the value of the
room_limit
the text content template
|
path | string |
Status 1 is valid when clicking "Enter" to start the path used by the small program.
For games, there is no concept of a page that can be used to pass a query
"?foo=bar"
|
version_type | string |
Status 1 is valid, click "Enter" to start the version used by the small program.
Valid parameter values are:
develop
(development),
trial
(experience),
release
(official)
|
Each News Feed can be understood as an activity that needs to be created through the updatableMessage.createActivityId interface before it activity_id. Subsequent forwarding of News Feeds and updating News Feeds require this activity_id.
The default validity period for an activity is 24 hours. At the end of the event, the message content becomes a uniform style:
By calling the wx.updateShareMenu interface, pass in isUpdatableMessage: true, as well as templateInfo, activityId parameters. Where the activityId is obtained from step one.
wx.updateShareMenu({
withShareTicket: true,
isUpdatableMessage: true,
activityId: '', // 活动 ID
templateInfo: {
parameterList: [{
name: 'member_count',
value: '1'
}, {
name: 'room_limit',
value: '3'
}]
}
})
After the News Feed is sent out, you can modify the message content through updatableMessage.setUpdatable Msg.
For client versions that do not support News Feed, they are displayed as normal messages when they are received