# Dynamic Messages

Support for forwarding dynamic messages starts with base library 2.4.0. Compared with common messages, dynamic messages have the following features:

  1. After a message is sent, the developer can modify part of the message content through the backend API.
  2. Messages have corresponding reminder button. Users can tap the reminder button to subscribe to the reminders. Developers can modify the message state through the backend and push a reminder message to the users who have subscribed to the reminders.

# Message Attributes

Dynamic messages have state, text content, and text color.

# State

A message has two states, each with its corresponding text content and color, where state 0 can be converted to states 0 and 1, and state 1 can no longer be converted.

State Text Content Color Allowed Conversion of State
0 “Members are joining, currently {member_count}/{room_limit} persons” #FA9D39 0, 1
1 “Has started” #CCCCCC None

# State parameters

Each state can carry parameters when it is converted. Specific parameters are described as follows.

Parameter Type Description
member_count string Valid for state 0, the value of member_count in the text content template
room_limit string Valid for state 0, the value of room_limit in the text content template
path string Valid for state 1, the path used when taping [Enter] to enable the Mini Program. For Mini Games, there is no concept of a page that can be used to transmit a queried character string (query), such as "?foo=bar"
version_type string Valid for state 1, the version used when taping [Enter] to enable the Mini Program. Valid parameters are: develop (developer version), trial (test version), release (official version)

# Usage

# 1. Create activity_id

Each dynamic message can be understood as an activity. Before launching an activity, activity_id needs to be created through the updatableMessage.createActivityId API. Subsequent forwarding and updating of dynamic messages require passing in this activity_id.

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

  • Text content: “Ended”
  • Text color: #00ff00

# 2. Declare the message as a dynamic message before forwarding

Pass in the isUpdatableMessage: true, templateInfo, and activityId parameters by calling the wx.updateShareMenu API, where activityId is obtained from 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 dynamic message content

After a dynamic message is sent, the message content can be modified through updatableMessage.setUpdatableMsg.

# Compatibility with Lower Versions

For the client versions that do not support dynamic messages, the received dynamic messages will be displayed as common messages