-
Notifications
You must be signed in to change notification settings - Fork 28
Events
Hevin edited this page Aug 16, 2017
·
9 revisions
插件所提供的事件监听:
- receiveMessage: 收到聊天消息
- clickMessageNotification: 点击消息通知
- syncOfflineMessage: 同步离线消息
- syncRoamingMessage: 同步漫游消息
- loginStateChanged: 登录状态变更
- contactNotify: 好友相关事件
- retractMessage: 消息撤回
注意:必须先调用
init
方法进行初始化,事件监听才会生效。
收到聊天消息事件。
var listener = function (msg) {
// do something.
}
JMessage.addReceiveMessageListener(listener)
JMessage.removeReceiveMessageListener(listener)
点击通知栏消息通知事件监听。
iOS 需要配合 jpush-phonegap-plugin 才能生效。
var listener = function (msg) {
// do something.
}
JMessage.addClickMessageNotificationListener(listener)
JMessage.removeClickMessageNotificationListener(listener)
离线消息同步监听。
var listener = function (event) {
var conversation = event.conversation
var messageArray = event.messageArray
}
JMessage.addSyncOfflineMessageListener(listener)
JMessage.removeSyncOfflineMessageListener(listener)