Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program forwarding


May 18, 2021 WeChat Mini Program Development Document


Table of contents


Forward

Get more forwarding information

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.

Forwarding is initiated within the page

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.

Use guidelines

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.

  1. Clear meaning: Clear, clear graphical buttons will reduce the time for the user to understand. I n our resource download center, you can find such button footage and use it directly. O r you can flexibly design button styles that have a clear meaning, depending on the design style of your business. Of course, you can also use the text button directly, "forward to friends", it is also clear enough.
  2. Convenient to click: Button Click on the hot area, it should not be too small, and it should not be too large.At the same time, the forwarding button is the same as other buttons, and the heat zone should not be too dense to avoid user misoperation.
  3. On-demand: Not all pages are suitable for placing the forwarding button, involving non-public content of user privacy, or may interrupt the user to complete the current operation experience, this feature is not recommended.At the same time, due to the forwarding process, we will intercept the user-screen image as a map, so it is necessary to pay attention to help the user block personal information.
  4. Respect the will: I have a matter of course, not all users like to share your applet with friends.Therefore, it should not be an induction or mandatory behavior, such as forwarding to unlock a feature.Please note that this type of approach is not only recommended, but it may also violate our "Operational Specification" We strongly recommend that you read this part before use.

More, we show the most important points, if you have time, you can fully browse Design Guide I believe there will be more gains.

hint:

  1. Under the case of the forwarding of the forwarding, the current page will be taken by default, starting from the top, the high degree of 80% screen width as a forwarding picture.
  2. Forward debugging support, please see General forwarded debugging support with Forwarded with Sharegetnticket
  3. Only forward to the group chat can only get the Sharetickets return value, and there is no sharetickets.
  4. Shareticket is only valid in the current small program life cycle
  5. Due to strategic changes, small programs related capabilities are adjusted, developers can use the group ID in the wx.getshareInfo interface to develop.
  6. WeChat 7.0.12 starts, support group master forwarding small program at the same time set the message as the group to-do message, group to-do message will appear in the form of bubbles at the bottom of the chat window. B y default, each time a group to-do message is forwarded, a to-do message bubble is generated. M odifying the toDoActivityId property through the wx.updateShareMenu interface aggregates multiple to-do messages into the same, i.e. forwarding group-to-do messages for the same to-do-do-you-go message, with only one to-do message bubble appearing. ToDoActivityId needs to be created through the updatableMessage.createActivityId interface before forwarding.

News Feed

Forwarding News Feeds is supported starting with the base library 2.4.0. News Feed compares regular messages to the following features:

  1. After the message is sent out, the developer can modify some of the message content through the background interface.
  2. The message has a corresponding reminder button, the user clicks the reminder button to subscribe to the reminder, the developer can modify the message status in the background and push a reminder message to the user who subscribed to the reminder

The message property

News Feed has status, text content, and text color.

State

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

The status parameters

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)

How to use it

First, create activity_id

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:

  • Text: "Closed"
  • Text color: #00ff00

2. Declare the message type as News Feed before forwarding

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'
    }]
  }
})

Third, modify the content of News Feed

After the News Feed is sent out, you can modify the message content through updatableMessage.setUpdatable Msg.

The lower version is compatible

For client versions that do not support News Feed, they are displayed as normal messages when they are received