调用方式:
nim.event.publishEvent(options)
发布某事件
IM订阅事件分为两类:
nim.event.publishEvent({ "type": 1, "value": 100003, "ext": "hello world", // 单位秒 "validTime": 60, "broadcastType": 2, "sync": false})// 监听此事件的其它用户nim.on('pushEvents', function (events) { console.log('收到订阅事件', events)})
按照事件类型,以及订阅的账户列表,查询订阅关系
订阅指定用户的事件。无论是内置的在线状态事件或是自定义的事件,都需要通过该 API 订阅后才能接收。
订阅事件后,应用开发者通过 IMEventInterface.pushEvents 函数监听订阅事件。
nim.event.subscribeEvent({ "type": 1, "accounts": [ "zk2" ], // 订阅有效期: 9000s "subscribeTime": 9000, "sync": true})
根据事件类型,以及订阅的账户列表,取消订阅
调用方式: