# Updatable Messages

Forwarding of updatable messages is supported as of base library 2.4.0. Compared with common messages, updatable messages have the following features:

  1. After a message is sent, the developer can modify part of the message content via the backend API.
  2. Users can tap the Notification button to subscribe to the message notifications. Developers can modify the message status in the backend and push a notification message to the users who have subscribed to notifications.

# Message Properties

Properties for updatable messages include state, text content, and text color.

# State

A message has two states, each with its own text content and color. State 0 can be converted to states 0 and 1, and state 1 cannot be converted.

State Text content Color State that can be converted to
0 "Members are joining. Currently, there are {member_count}/{room_limit} persons." #FA9D39 0, 1
1 "Started" #CCCCCC None

# State parameters

Each state can carry the following parameters when it is converted:

Parameter Type Description
member_count string The value of member_count in the text content template, which is valid for state 0.
room_limit string The value of room_limit in the text content template, which is valid for state 0.
path string The path used when Enter is tapped to start the Mini Program. It is valid when state is 1. In Mini Games, there are no pages, and therefore, it can be used to transfer query strings, for example, "?foo=bar".
version_type string The version used when Enter is tapped to start the Mini Program. It is valid when state is 1. Valid values: develop (developer version), trial (test version), and release (official version).

# Usage

# 1. Create an activity_id

Each updatable message can be considered as an activity. Before launching an activity, an activity_id needs to be created via the updatableMessage.createActivityId API. The activity_id is required for subsequent forwarding and updating of updatable messages.

The default validity period for an activity is 24 hours. At the end of the activity, the message content will take on a unified style:

  • Text content: "Ended"
  • Text color: #00ff00

# 2. Declare the message to be an updatable message before forwarding

Pass in the isUpdatableMessage: true, templateInfo, and activityId parameters by calling the wx.updateShareMenu API. The activityId is obtained in step 1.

wx.updateShareMenu({
  withShareTicket: true,
  isUpdatableMessage: true,
  activityId: '', // Event ID
  templateInfo: {
    parameterList: [{
      name: 'member_count',
      value: '1'
    }, {
      name: 'room_limit',
      value: '3'
    }]
  }
})

# 3. Modify updatable message content

After an updatable message is sent, the message content can be modified via updatableMessage.setUpdatableMsg.

# Compatibility with Older Versions

For client versions that do not support updatable messages, received updatable messages will be displayed as common messages.