文档中心

消息格式

服务号消息内容分为以下六种类型:

  1. 简单文本消息
  2. 复杂文本消息
  3. 富文本消息
  4. 新富文本消息
  5. 图文消息
  6. 线性格式消息

简单文本消息

简单文本消息仅有文本内容,无响应动作。

对象 具体参数 类型 是否必须 描述
TextMessageContent text String 文本内容

Java

SendMessageResult result = messageClient.sendSingleMessage(
       new TextMessageContent("简单文本消息"), 
       new PersonMessageReceiver("zhongt", "钟涛"));

.Net

SendMessageResult result = messageClient.SendSingleMessage(
       new TextMessageContent("简单文本消息"), 
       new PersonMessageReceiver("zhongt", "钟涛"));

复杂文本消息

复杂文本消息是有概要、响应动作的文本消息。

对象 具体参数 类型 是否必须 描述
ComplexMessageContent brief String 消息概要
ComplexMessageType.TEXT(JAVA)
ComplexMessageType.Text(.Net)
常量 消息类型
ComplexMessageContentItem text String 文本内容

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("复杂文本消息概要", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是复杂文本消息的内容");
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexMessageContent = new ComplexMessageContent("复杂文本消息概要", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是复杂文本消息的内容");
complexMessageContent.AddMessageContentItem(contentItem);

SendMessageResult result = messageClient.SendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

富文本消息

富文本消息是有概要、响应动作,内容是一段HTML的消息。

对象 具体参数 类型 是否必须 描述
ComplexMessageContent brief String 消息概要
ComplexMessageType.RICH_TEXT(JAVA)
ComplexMessageType.RichText(.Net)
常量 消息类型
ComplexMessageContentItem html String 显示的HTML内容
Action Object 响应动作,这个第三部分讲述

Java

String html = "<div style=\"border:1px solid #ddd;border-radius:5px;box-shadow:1px 1px 5px #666;background:#fff;\">"+
          " <div style=\"padding:0px 15px 15px 15px;\">"+
          "  <h3>"+
          "    [此处录入通知标题]"+
          "  </h3>[此处录入通知内容]"+
          " </div>"+
          "  <div style=\"border-top:1px solid #ddd;padding:15px;\">"+
          "     <table cellpadding=\"0px\" cellspacing=\"0px\" width=\"100%\" class=\" noBorderTable\">"+
          "        <tbody>"+
          "             <tr>"+
          "                  <td>"+
          "                   点击查看全文 "+
          "                  </td>"+
          "                  <td align=\"right\">"+
          "                      &gt; "+
          "                  </td>"+
          "              </tr>"+
          "           </tbody>"+
          "       </table>"+
          "   </div>"+
          " </div>";


ComplexMessageContent complexTextMessage = new ComplexMessageContent("富文本消息消息概要", ComplexMessageType.RICH_TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem(html,Action.instanceAsOpenHtml("<b>你好,富文本消息!!</b>"));
complexTextMessage.addMessageContentItem(contentItem);
SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

String html = "<div style=\"border:1px solid #ddd;border-radius:5px;box-shadow:1px 1px 5px #666;background:#fff;\">"+
          " <div style=\"padding:0px 15px 15px 15px;\">"+
          "  <h3>"+
          "    [此处录入通知标题]"+
          "  </h3>[此处录入通知内容]"+
          " </div>"+
          "  <div style=\"border-top:1px solid #ddd;padding:15px;\">"+
          "     <table cellpadding=\"0px\" cellspacing=\"0px\" width=\"100%\" class=\" noBorderTable\">"+
          "        <tbody>"+
          "             <tr>"+
          "                  <td>"+
          "                   点击查看全文 "+
          "                  </td>"+
          "                  <td align=\"right\">"+
          "                      &gt; "+
          "                  </td>"+
          "              </tr>"+
          "           </tbody>"+
          "       </table>"+
          "   </div>"+
          " </div>";

ComplexMessageContent complexTextMessage = new ComplexMessageContent("富文本消息消息概要", ComplexMessageType.RichText);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem(html, Action.InstanceAsOpenHtml("<b>你好,富文本消息!!</b>"));
complexTextMessage.AddMessageContentItem(contentItem);
SendMessageResult result = messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

新富文本消息

新富文本消息是有概要、响应动作,内容是标题、内容概要、入口文字的消息。

对象 具体参数 类型 是否必须 描述
ComplexMessageContent brief String 消息概要
ComplexMessageType.NEW_RICH_TEXT(JAVA)
ComplexMessageType.NewRichText(.Net)
常量 消息类型
ComplexMessageContentItem NewRichMessageContent Object 新富文本内容
Action Object 响应动作,这个第三部分讲述
NewRichMessageContent title String 消息的标题
brief String 消息的概要描述信息
more String 如果more没有传入,或者传入的title值为空等异常情况,默认是”点击查看全文“

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("新富文本消息消息概要", ComplexMessageType.NEW_RICH_TEXT);
NewRichMessageContent newRichMessageContent = new NewRichMessageContent("新富文本消息", "这里是新富文本消息的基本内容");
ComplexMessageContentItem contentItem = new ComplexMessageContentItem(newRichMessageContent,
       Action.instanceAsOpenHtml("<b>你好,这里是新富文本消息的详细内容!!</b>"));
complexTextMessage.addMessageContentItem(contentItem);
SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexTextMessage = new ComplexMessageContent("新富文本消息消息概要", ComplexMessageType.NewRichText);
NewRichMessageContent newRichMessageContent = new NewRichMessageContent("新富文本消息", "这里是新富文本消息的基本内容");
ComplexMessageContentItem contentItem = new ComplexMessageContentItem(newRichMessageContent,
       Action.InstanceAsOpenHtml("<b>你好,这里是新富文本消息的详细内容!!</b>"));
complexTextMessage.AddMessageContentItem(contentItem);
SendMessageResult result = messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

图文消息

图文消息是有概要、响应动作,内容是图片文字结合的消息。

对象 具体参数 类型 是否必须 描述
ComplexMessageContent brief String 消息概要
ComplexMessageType.IMAGE_TEXT(JAVA)
ComplexMessageType.ImageText(.Net)
常量 消息类型
ComplexMessageContentItem text String 内容块的标题
img String 内容块的图片地址
Action Object 响应动作,这个第三部分讲述

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("图文消息消息概要", ComplexMessageType.IMAGE_TEXT);
ComplexMessageContentItem contentItem1 = new ComplexMessageContentItem("图文消息--URL",
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.instanceAsOpenUrl("http://www.mi.com"));
complexTextMessage.addMessageContentItem(contentItem1);
ComplexMessageContentItem contentItem2 = new ComplexMessageContentItem("图文消息1--HTML",
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.instanceAsOpenHtml("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.addMessageContentItem(contentItem2);
ComplexMessageContentItem contentItem3 = new ComplexMessageContentItem("图文消息2--HTML", 
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.instanceAsOpenHtml("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.addMessageContentItem(contentItem3);

ComplexMessageContentItem contentItem4 = new ComplexMessageContentItem("图文消息3--HTML", 
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.instanceAsOpenHtml("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.addMessageContentItem(contentItem4);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexTextMessage = new ComplexMessageContent("图文消息消息概要", ComplexMessageType.ImageText);
ComplexMessageContentItem contentItem1 = new ComplexMessageContentItem("图文消息--URL",
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.InstanceAsOpenUrl("http://www.mi.com"));
complexTextMessage.AddMessageContentItem(contentItem1);
ComplexMessageContentItem contentItem2 = new ComplexMessageContentItem("图文消息1--HTML",
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.InstanceAsOpenUrl("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.AddMessageContentItem(contentItem2);
ComplexMessageContentItem contentItem3 = new ComplexMessageContentItem("图文消息2--HTML", 
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.InstanceAsOpenUrl("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.AddMessageContentItem(contentItem3);

ComplexMessageContentItem contentItem4 = new ComplexMessageContentItem("图文消息3--HTML", 
       "http://img0.bdstatic.com/img/image/shouye/bizhi0323.jpg",
       Action.InstanceAsOpenUrl("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.AddMessageContentItem(contentItem4);

SendMessageResult result = messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

线性格式消息

线性格式消息是有概要、响应动作,内容可展示文本、Grid或Form,甚至组合展示的消息。
PS:文本、Grid、Form可自由搭配,显示顺序是添加到容器的顺序。

对象 具体参数 类型 是否必须 描述
ComplexMessageContent brief String 消息概要
ComplexMessageType.LINEAR(JAVA)
ComplexMessageType.Linear(.Net)
常量 消息类型
TitleLinearComplexMessageContentItem text : 标题内容
通过对象的set属性方法,还可以设置:
bgColor : 背景色
fontColor : 字体颜色
fontBold : 字体粗体
borderColor : 边框颜色
actionType : 响应类型
actionParam : 响应参数
Object 标题信息
TextLinearComplexMessageContentItem text : 文本内容
通过对象的set属性方法,还可以设置:
bgColor : 背景色
fontColor : 字体颜色
fontBold : 字体粗体
borderColor : 边框颜色
actionType : 响应类型
actionParam : 响应参数
Object 文本信息
GridLinearComplexMessageContentItem GridContent : 表格内容
GridContent详解:
Column(表头):
1.title : 标题
2.Alignment : 文本位置
3.width : 列宽(百分比,不必写‘%’)
通过对象的set属性方法,还可以设置:
actionType : 响应类型
actionParam : 响应参数
具体方法请查看下面示例
Object 表格信息
FormLinearComplexMessageContentItem FormContent : 表单内容
FormContent详解:
FormFieldConfig(表单属性设置):
1.width : 列宽(百分比,不必写‘%’)
2.Alignment : 文本位置
通过对象的set属性方法,还可以设置:
actionType : 响应类型
actionParam : 响应参数
具体方法请查看下面示例
Object 表单信息

Grid线性消息

Java

ComplexMessageContent complexMessageContent = new ComplexMessageContent("Grid线性消息概要", ComplexMessageType.LINEAR);

TitleLinearComplexMessageContentItem title = new TitleLinearComplexMessageContentItem("Grid标题");
TextLinearComplexMessageContentItem  brief  = new TextLinearComplexMessageContentItem("前言提示");
TextLinearComplexMessageContentItem  hint  = new TextLinearComplexMessageContentItem("Grid提示");

GridContent gridContent = new GridContent(2);
gridContent.addColumn(new Column("姓名", Alignment.center, 40));
gridContent.addColumn(new Column("部门", Alignment.left, 60));
gridContent.addData(new String[] {"张三","云应用平台部"});
gridContent.addData(new String[] {"李四","云应用体验部"});
gridContent.addData(new String[] {"王五","云应用平台部"});
gridContent.addData(new String[] {"孙六","云应用体验部"});  
GridLinearComplexMessageContentItem grid = new GridLinearComplexMessageContentItem(gridContent);

//显示顺序是添加到容器的顺序     
complexMessageContent.addMessageContentItem(title)
    .addMessageContentItem(brief)
    .addMessageContentItem(grid)
    .addMessageContentItem(hint);

SendMessageResult result = messageClient.sendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexMessageContent = new ComplexMessageContent("Grid线性消息概要", ComplexMessageType.Linear);

TitleLinearComplexMessageContentItem title = new TitleLinearComplexMessageContentItem("Grid标题");
TextLinearComplexMessageContentItem  brief  = new TextLinearComplexMessageContentItem("前言提示");
TextLinearComplexMessageContentItem  hint  = new TextLinearComplexMessageContentItem("Grid提示");

GridContent gridContent = new GridContent(2);
gridContent.AddColumn(new Column("姓名", Alignment.Center, 40));
gridContent.AddColumn(new Column("部门", Alignment.Left, 60));
gridContent.AddData(new String[] {"张三","云应用平台部"});
gridContent.AddData(new String[] {"李四","云应用体验部"});
gridContent.AddData(new String[] {"王五","云应用平台部"});
gridContent.AddData(new String[] {"孙六","云应用体验部"});  
GridLinearComplexMessageContentItem grid = new GridLinearComplexMessageContentItem(gridContent);

//显示顺序是添加到容器的顺序 
complexMessageContent.AddMessageContentItem(title)
    .AddMessageContentItem(brief)
    .AddMessageContentItem(grid)
    .AddMessageContentItem(hint);

SendMessageResult result = messageClient.SendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

Form线性消息

Java

ComplexMessageContent complexMessageContent = new ComplexMessageContent("Form线性消息概要", ComplexMessageType.LINEAR);

TitleLinearComplexMessageContentItem title = new TitleLinearComplexMessageContentItem("Form标题");
TextLinearComplexMessageContentItem  hint  = new TextLinearComplexMessageContentItem("Hint提示");

FormContent formContent = new FormContent(new FormFieldConfig(30,Alignment.center), new FormFieldConfig(70, Alignment.left));
formContent.addData("姓名", "张三");
formContent.addData("籍贯", "广州");
formContent.addData("年龄", "30");
formContent.addData("爱好", "唱歌、跳舞");
FormLinearComplexMessageContentItem form = new FormLinearComplexMessageContentItem(formContent);

//显示顺序是添加到容器的顺序
complexMessageContent.addMessageContentItem(title)
    .addMessageContentItem(form)
    .addMessageContentItem(hint);

SendMessageResult result = messageClient.sendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexMessageContent = new ComplexMessageContent("Form线性消息概要", ComplexMessageType.Linear);

TitleLinearComplexMessageContentItem title = new TitleLinearComplexMessageContentItem("Form标题");
TextLinearComplexMessageContentItem  hint  = new TextLinearComplexMessageContentItem("Hint提示");

FormContent formContent = new FormContent(new FormFieldConfig(30,Alignment.Center), new FormFieldConfig(70, Alignment.Left));
formContent.AddData("姓名", "张三");
formContent.AddData("籍贯", "广州");
formContent.AddData("年龄", "30");
formContent.AddData("爱好", "唱歌、跳舞");
FormLinearComplexMessageContentItem form = new FormLinearComplexMessageContentItem(formContent);

//显示顺序是添加到容器的顺序
complexMessageContent.AddMessageContentItem(title)
    .AddMessageContentItem(form)
    .AddMessageContentItem(hint);

SendMessageResult result = messageClient.SendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

响应动作

点击消息块的响应动作,有四种类型, 最复杂的是打开原生功能的响应动作,这个类型将单独讲解:

类型 调用函数 参数 说明 类型 描述
无响应动作 Action.instanceAsDoNothing 没有响应内容,不会触发跳转动作
(不设置响应动作默认是该类型)
打开URL Action.instanceAsOpenUrl url 打开url地址 String 点击消息块时,会以Link内置的浏览器
打开参数中指定的web页面(url)
请注意这个不包含BingoTouch远程地址
打开富文本 Action.instanceAsOpenHtml html 富文本内容 String 点击消息块时,会以Link内置的浏览器
打开参数中指定的富文本信息(html)
打开原生功能 Action.instanceAsOpenNative 详情请看下表 点击消息块时,会打开参数中指定的原生功能

打开原生功能具体也分为四种类型,如下表:

类型(调用函数) 参数 说明 类型 描述
打开市场内的应用
NativeCommandAndParamsBuilder
.buildAsOpenBingoTouchLocalAppPage
appCode 应用编码 String 应用市场中应用的编码
localPagePath 页面路径 String 打开的页面路径,相对路径
params 页面参数 可变参数 在bingotouch页面里可以拿到的参数,
这里传入的是可变的键值对参数,
例:new Param(key, value)
打开bingotouch远程页面
NativeCommandAndParamsBuilder
.buildAsOpenBingoTouchRemoteAppPage
remotePageUrl 页面地址 String 远程应用页面,绝对路径
打开Link动态
NativeCommandAndParamsBuilder
.buildAsOpenBlogPage
blogId 动态Id String 打开Link的动态id
打开特定原生功能
NativeCommandAndParamsBuilder
.buildAsOpenNativeFunction
command 原生功能指令 String 该指令内容比较复杂,
如果需要调用Link原生功能,
请咨询产品组。
params 附带参数 可变参数 在原生功能拿到的参数,
这里传入的是可变的键值对参数,
例:new Param(key, value)

响应动作示例

如第二部分消息内容所写的,所有的响应动作都是在ComplexMessageContentItem对象中设置的。

无响应动作消息

无响应动作时,不需要传任何参数。

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("无响应动作概要", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是无响应动作的内容");
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexMessageContent = new ComplexMessageContent("无响应动作概要", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是无响应动作的内容");
complexMessageContent.AddMessageContentItem(contentItem);

SendMessageResult result = messageClient.SendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

打开URL

打开一个URL地址,这里的地址并不包括BingoTouch远程地址,BingoTouch远程页面请按第四种类型打开。

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("打开URL概要", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是打开URL的内容",
     Action.instanceAsOpenUrl("http://www.bingosoft.net/"));
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexMessageContent = new ComplexMessageContent("打开URL概要", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是打开URL的内容",
    Action.InstanceAsOpenUrl("http://www.bingosoft.net/"));
complexMessageContent.AddMessageContentItem(contentItem);

SendMessageResult result = messageClient.SendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

打开富文本

以Link内置的浏览器打开参数中指定的富文本信息(html)

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("打开富文本概要", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是打开富文本的内容",
     Action.instanceAsOpenHtml("<b>这里是富文本消息的基本内容</b>"));
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexMessageContent = new ComplexMessageContent("打开富文本概要", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是打开富文本的内容",
    Action.InstanceAsOpenUrl("<b>这里是富文本消息的基本内容</b>"));
complexMessageContent.AddMessageContentItem(contentItem);

SendMessageResult result = messageClient.SendSingleMessage(complexMessageContent, new PersonMessageReceiver("zhongt", "钟涛"));

打开市场内的应用

如果对应用编码或应用的启动页面的内容不清晰,请咨询该应用的开发者。

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开一个Bingotouch本地应用", ComplexMessageType.TEXT);

Param name= new Param("name","Mrs.Lu");
Param age= new Param("age", "26");
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开BingoTouch本地应用",
    Action.instanceAsOpenNative(NativeCommandAndParamsBuilder.buildAsOpenBingoTouchLocalAppPage("BingoService", "index.html",name, age)));
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开一个Bingotouch本地应用", ComplexMessageType.Text);

Param name= new Param("name","Mrs.Lu");
Param age= new Param("age", "26");
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开BingoTouch本地应用", 
       Action.InstanceAsOpenNative(NativeCommandAndParamsBuilder.BuildAsOpenBingoTouchLocalAppPage("BingoService", index.html",name, age)));
complexTextMessage.AddMessageContentItem(contentItem);

SendMessageResult result = _messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

打开BingoTouch远程页面

此类型响应动作用于打开BingoTouch远程页面。

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开一个Bingotouch远程页面", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开BingoTouch远程页面", 
       Action.instanceAsOpenNative(NativeCommandAndParamsBuilder.buildAsOpenBingoTouchRemoteAppPage("http://dev.bingocc.cc:8060/bingotouch-ui/")));
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开一个Bingotouch远程页面", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开BingoTouch远程页面", 
       Action.InstanceAsOpenNative(NativeCommandAndParamsBuilder.BuildAsOpenBingoTouchRemoteAppPage("http://dev.bingocc.cc:8060/bingotouch-ui/")));
complexTextMessage.AddMessageContentItem(contentItem);

SendMessageResult result = _messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

打开Link动态

此类型响应动作用于打开Link的动态。

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开Link的动态", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开Link的动态详情", 
       Action.instanceAsOpenNative(NativeCommandAndParamsBuilder.buildAsOpenBlogPage("e388dbb4-f580-49fb-a3a7-6879ce2cf6ab")));
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开Link的动态", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开Link的动态详情", 
       Action.InstanceAsOpenNative(NativeCommandAndParamsBuilder.BuildAsOpenBlogPage("e388dbb4-f580-49fb-a3a7-6879ce2cf6ab")));
complexTextMessage.AddMessageContentItem(contentItem);

SendMessageResult result = _messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

打开特定原生功能

打开特定原生功能的使用比较复杂,如果需要调用Link原生功能,请咨询产品组

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开一个原生指令", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开原生的聊天页面", 
       Action.instanceAsOpenNative(NativeCommandAndParamsBuilder.buildAsOpenNativeFunction("StartChat")));
complexTextMessage.addMessageContentItem(contentItem);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

.Net

ComplexMessageContent complexTextMessage = new ComplexMessageContent("演示打开一个原生指令", ComplexMessageType.Text);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("点击可以打开原生的聊天页面", 
       Action.InstanceAsOpenNative(NativeCommandAndParamsBuilder.BuildAsOpenNativeFunction("StartChat")));
complexTextMessage.AddMessageContentItem(contentItem);

SendMessageResult result = _messageClient.SendSingleMessage(complexTextMessage, new PersonMessageReceiver("zhongt", "钟涛"));

响应动作调用类型

响应动作调用类型,是区分消息的响应动作是在什么位置被触发的,有三种类型。

  1. 不调用 : 当设置为不调用的时候,即使是有设置响应动作也不会触发动作。
  2. 消息列表调用 : 当设置为消息列表调用时候,用户在消息列表点击该服务号时就触发动作。
  3. 聊天界面调用 : 当设置为聊天界面调用时候,用户进入服务号聊天界面,点击消息才触发动作。

一般来讲,如果没有特殊的业务要求,都是使用第三种类型。
PS:上面所有的例子都没有设置响应动作的调用类型,其实就是默认第三种类型。

Java

ComplexMessageContent complexTextMessage = new ComplexMessageContent("复杂文本消息概要", ComplexMessageType.TEXT);
ComplexMessageContentItem contentItem = new ComplexMessageContentItem("这里是复杂文本消息的内容");
complexTextMessage.addMessageContentItem(contentItem);
//InvokeType.DO_NOTHING 不调用
//InvokeType.INVOKE_CUSTOM_APP 消息列表调用
//InvokeType.INVOKE_CHAT_WINDOW 聊天界面调用
complexTextMessage.setInvokeType(InvokeType.INVOKE_CUSTOM_APP);

SendMessageResult result = messageClient.sendSingleMessage(complexTextMessage, new PersonMessageReceiver("lufeng", "卢丰"));