var APP_ID = 'baiVxKUMBFQQgEJrt04CqCrj-gzGzoHsz';
var APP_KEY = 'Q35SbtGngJk5N9rCHGYoMTOd';
var realtime = new AV.Realtime({
appKey: APP_KEY,
appId: APP_ID
});
var service =realtime.createIMClient("@clientid");
service.then(function (_service) {
_service.on(realtime.UNREAD_MESSAGES_COUNT_UPDATE, function (conversations) {
for (let conv of conversations) {
alert('你有未读消息');
// console.log(conv.id, conv.name, conv.unreadMessagesCount);
}
});
_service.on("message", function (message, conversation) {
alert('有新消息');
});
})