消息

得到会话ID

// type group/user 
//id groupid/recver_user_id
IM.utils.getChatId(type,id);

发送消息

发送文本消息

IM.sendMessageByText(chatId,this.text);

发送图片消息

var attach = {"name":"1.txt","size":111,"path":""}
IM.sendMessageByImage(chatId,attach);

发送文件消息

var attach = {"name":"1.txt","size":111,"path":""}
IM.sendMessageByFile(chatId,attach);

发送音频消息

var attach = {"name":"1.txt","size":111,"path":""}
IM.sendMessageByVoice(chatId,attach);

发送视频消息

var attach = {"name":"1.txt","size":111,"path":""}
IM.sendMessageByShoot(chatId,attach);

发送链接消息

var data = {"title":"数学作业通知","desc":"1.书本P9-10<br> 2.口算P8<br>3.作业本P8","url":"http://www.baidu.com","icon":"http://cdn-img.easyicon.net/png/11569/1156983.gif"} ;
IM.sendMessageByApp(chatId,data);

发送位置消息

var longitude = "30.278572" ;
var latitude = "120.143341" ;
var name = "求是大厦" ;
var address = "浙江省杭州市西湖区教工路8号" ;		IM.sendMessageByLocation(chatId,longitude,latitude,name,address);

发送通知消息

var text = "欢迎加入对话" ;
IM.sendMessageByNotify(chatId,text);

接收消息

接收消息在SDK中自动处理,会激发 onNewMessage事件

离线消息

IM.getOfflineMessage();

得到会话消息

IM.store.loadChatMsg(chatId);

新消息提示

//收到新的消息
IM.onNewMessage = function(msg){
	var type = _.$route.params.type ;
	var id = _.$route.params.id ;

	//如果刚好在对话窗体
	if ((type == msg.chatType) && (id == msg.toId)){
		IM.setReaded(msg);
	}
}

消息回执

//设置消息已读
IM.setReaded(msg);

//设置会话已读
IM.setReadedByChat(chatId);