群邀请消息获取

This commit is contained in:
2022-02-22 14:59:53 +08:00
parent d812ac2862
commit 66092967cb
9 changed files with 163 additions and 126 deletions

View File

@@ -41,7 +41,7 @@ const notifyMsgTypes = [
const imLibListeners = () => {
// 添加连接状态监听函数
IMLib.addConnectionStatusListener((res) => {
console.log('连接状态监听', res.data.status)
console.error('连接状态监听', res.data.status)
uni.$emit('onConnectionStatusChange', res.data.status)
})
// 添加消息监听函数
@@ -69,7 +69,7 @@ const imLibListeners = () => {
store.dispatch('updateContact', JSON.parse(message.content.data))
// 调用完更新之后,删除这条消息
IMLib.deleteMessagesByIds([message.messageId])
} else if (message.objectName === IMLib.ObjectName.ContactNotification) {
} else if (message.objectName === IMLib.ObjectName.ContactNotification) {
console.error('触发一个新好友的通知事件', message);
// 触发一个新好友的通知事件
uni.$emit('onContactNotification', message)
@@ -85,13 +85,28 @@ const imLibListeners = () => {
uni.$emit('onReceiveMessage', message)
}
})
// 监听消息回执
// 监听私聊消息已读回执
IMLib.addReadReceiptReceivedListener(({
data
}) => {
console.error("监听私聊消息已读回执: ", data);
uni.$emit('onReadReceiptReceived', data)
})
// 监听消息撤回操作
IMLib.addRecallMessageListener((res) => {
console.error("消息撤回: ", res);
})
// 监听需要群聊消息回执
IMLib.addReceiptRequestListener(({
data
}) => {
console.error('onReceiptRequested', data);
uni.$emit('onReceiptRequested', data)
})
// 群消息已读的回执
IMLib.addReceiptResponseListener((res) => {
console.error('addReceiptResponseListener', res);
})
}
const callLibListeners = () => {
@@ -100,7 +115,7 @@ const callLibListeners = () => {
CallLib.onCallReceived(({
data
}) => {
console.log('onCallReceived');
console.error('onCallReceived');
uni.navigateTo({
url: '/pages/im/private/call?targetId=' + data.targetId + '&mediaType=' +
data.mediaType
@@ -112,27 +127,27 @@ const callLibListeners = () => {
})
// 外呼
CallLib.onCallOutgoing((res) => {
console.log('onCallOutgoing', res);
console.error('onCallOutgoing', res);
uni.$emit('onCallOutgoing')
})
// 远端响铃
CallLib.onRemoteUserRinging((res) => {
console.log('onRemoteUserRinging', res);
CallLib.onRemoteUserRinging((res) => {
console.error('onRemoteUserRinging', res);
uni.$emit('onRemoteUserRinging')
})
// 远端加入
CallLib.onRemoteUserJoined((res) => {
console.log('远端接听');
console.error('远端接听');
uni.$emit('onRemoteUserJoined')
})
// 断开链接
CallLib.onCallDisconnected((res) => {
console.log('断开链接', res)
console.error('断开链接', res)
uni.$emit('onCallDisconnected')
})
// 远端挂断
CallLib.onRemoteUserLeft((res) => {
console.log('远端离开', res)
console.error('远端离开', res)
uni.$emit('onRemoteUserLeft')
})
}

View File

@@ -16,8 +16,8 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
'RC:SightMsg',
'RC:ReferenceMsg',
'RC:CombineMsg',
'RC:GrpNtf',
'RC:InfoNtf'
'RC:GrpNtf',
'RC:InfoNtf'
]
RongIMLib.getHistoryMessagesByTimestamp(
@@ -60,18 +60,16 @@ const getPendingList = (callback, total) => {
// 群组申请列表,邀请列表
const getGroupPendinglist = (targetId, callback) => {
let total = 1000
RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], total, 0, (res) => {
if (res.code === 0) {
const pendings = res.conversations.filter((item) => {
return item.targetId == targetId &&
item.objectName == RongIMLib.ObjectName.ContactNotification &&
item.latestMessage.operation === 'GroupPending'
})
const conversationType = RongIMLib.ConversationType.SYSTEM
const objectNames = ['RC:ContactNtf']
callback(pendings)
RongIMLib.getHistoryMessagesByTimestamp(conversationType, targetId, objectNames, 0, 1000, true,
({
messages
}) => {
callback(messages)
}
})
)
}
/**
@@ -97,6 +95,11 @@ const sentText = (conversationType, targetId, content, user, callback) => {
messageId
}) => {
if (code === 0) {
if (conversationType == 3) {
RongIMLib.sendReadReceiptRequest(messageId, (res) => {
console.log('发送回执请求', res);
})
}
callback(messageId)
} else {
console.log('发送失败', msg);