|
@@ -52,12 +52,12 @@ export default {
|
|
|
|
|
|
|
|
// 监听事件,如:
|
|
// 监听事件,如:
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.SDK_READY, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.SDK_READY, (event)=>{
|
|
|
// 收到离线消息和会话列表同步完毕通知,接入侧可以调用 sendMessage 等需要鉴权的接口
|
|
// 收到离线消息和会话列表同步完毕通知,接入侧可以调用 sendMessage 等需要鉴权的接口
|
|
|
// event.name - TIM.EVENT.SDK_READY
|
|
// event.name - TIM.EVENT.SDK_READY
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- this.tim.on(TIM.EVENT.MESSAGE_RECEIVED, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.MESSAGE_RECEIVED, (event)=>{
|
|
|
console.log(event);
|
|
console.log(event);
|
|
|
// 收到推送的单聊、群聊、群提示、群系统通知的新消息,可通过遍历 event.data 获取消息列表数据并渲染到页面
|
|
// 收到推送的单聊、群聊、群提示、群系统通知的新消息,可通过遍历 event.data 获取消息列表数据并渲染到页面
|
|
|
// event.name - TIM.EVENT.MESSAGE_RECEIVED
|
|
// event.name - TIM.EVENT.MESSAGE_RECEIVED
|
|
@@ -70,21 +70,21 @@ export default {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.MESSAGE_REVOKED, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.MESSAGE_REVOKED, (event)=>{
|
|
|
// 收到消息被撤回的通知。使用前需要将SDK版本升级至v2.4.0或以上。
|
|
// 收到消息被撤回的通知。使用前需要将SDK版本升级至v2.4.0或以上。
|
|
|
// event.name - TIM.EVENT.MESSAGE_REVOKED
|
|
// event.name - TIM.EVENT.MESSAGE_REVOKED
|
|
|
// event.data - 存储 Message 对象的数组 - [Message] - 每个 Message 对象的 isRevoked 属性值为 true
|
|
// event.data - 存储 Message 对象的数组 - [Message] - 每个 Message 对象的 isRevoked 属性值为 true
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.MESSAGE_READ_BY_PEER, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.MESSAGE_READ_BY_PEER, (event)=>{
|
|
|
// SDK 收到对端已读消息的通知,即已读回执。使用前需要将SDK版本升级至v2.7.0或以上。仅支持单聊会话。
|
|
// SDK 收到对端已读消息的通知,即已读回执。使用前需要将SDK版本升级至v2.7.0或以上。仅支持单聊会话。
|
|
|
// event.name - TIM.EVENT.MESSAGE_READ_BY_PEER
|
|
// event.name - TIM.EVENT.MESSAGE_READ_BY_PEER
|
|
|
// event.data - event.data - 存储 Message 对象的数组 - [Message] - 每个 Message 对象的 isPeerRead 属性值为 true
|
|
// event.data - event.data - 存储 Message 对象的数组 - [Message] - 每个 Message 对象的 isPeerRead 属性值为 true
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.CONVERSATION_LIST_UPDATED, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.CONVERSATION_LIST_UPDATED, (event)=>{
|
|
|
// 收到会话列表更新通知,可通过遍历 event.data 获取会话列表数据并渲染到页面
|
|
// 收到会话列表更新通知,可通过遍历 event.data 获取会话列表数据并渲染到页面
|
|
|
// event.name - TIM.EVENT.CONVERSATION_LIST_UPDATED
|
|
// event.name - TIM.EVENT.CONVERSATION_LIST_UPDATED
|
|
|
// event.data - 存储 Conversation 对象的数组 - [Conversation]
|
|
// event.data - 存储 Conversation 对象的数组 - [Conversation]
|
|
@@ -95,7 +95,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- this.tim.on(TIM.EVENT.GROUP_LIST_UPDATED, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.GROUP_LIST_UPDATED, (event)=>{
|
|
|
// 收到群组列表更新通知,可通过遍历 event.data 获取群组列表数据并渲染到页面
|
|
// 收到群组列表更新通知,可通过遍历 event.data 获取群组列表数据并渲染到页面
|
|
|
// event.name - TIM.EVENT.GROUP_LIST_UPDATED
|
|
// event.name - TIM.EVENT.GROUP_LIST_UPDATED
|
|
|
// event.data - 存储 Group 对象的数组 - [Group]
|
|
// event.data - 存储 Group 对象的数组 - [Group]
|
|
@@ -107,21 +107,21 @@ export default {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.PROFILE_UPDATED, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.PROFILE_UPDATED, (event)=>{
|
|
|
// 收到自己或好友的资料变更通知
|
|
// 收到自己或好友的资料变更通知
|
|
|
// event.name - TIM.EVENT.PROFILE_UPDATED
|
|
// event.name - TIM.EVENT.PROFILE_UPDATED
|
|
|
// event.data - 存储 Profile 对象的数组 - [Profile]
|
|
// event.data - 存储 Profile 对象的数组 - [Profile]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.BLACKLIST_UPDATED, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.BLACKLIST_UPDATED, (event)=>{
|
|
|
// 收到黑名单列表更新通知
|
|
// 收到黑名单列表更新通知
|
|
|
// event.name - TIM.EVENT.BLACKLIST_UPDATED
|
|
// event.name - TIM.EVENT.BLACKLIST_UPDATED
|
|
|
// event.data - 存储 userID 的数组 - [userID]
|
|
// event.data - 存储 userID 的数组 - [userID]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.ERROR, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.ERROR, (event)=>{
|
|
|
// 收到 SDK 发生错误通知,可以获取错误码和错误信息
|
|
// 收到 SDK 发生错误通知,可以获取错误码和错误信息
|
|
|
// event.name - TIM.EVENT.ERROR
|
|
// event.name - TIM.EVENT.ERROR
|
|
|
// event.data.code - 错误码
|
|
// event.data.code - 错误码
|
|
@@ -134,7 +134,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.SDK_NOT_READY, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.SDK_NOT_READY, (event)=>{
|
|
|
// 收到 SDK 进入 not ready 状态通知,此时 SDK 无法正常工作
|
|
// 收到 SDK 进入 not ready 状态通知,此时 SDK 无法正常工作
|
|
|
// event.name - TIM.EVENT.SDK_NOT_READY
|
|
// event.name - TIM.EVENT.SDK_NOT_READY
|
|
|
|
|
|
|
@@ -146,7 +146,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.KICKED_OUT, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.KICKED_OUT, (event)=>{
|
|
|
// 收到被踢下线通知
|
|
// 收到被踢下线通知
|
|
|
// event.name - TIM.EVENT.KICKED_OUT
|
|
// event.name - TIM.EVENT.KICKED_OUT
|
|
|
// event.data.type - 被踢下线的原因,例如 :
|
|
// event.data.type - 被踢下线的原因,例如 :
|
|
@@ -156,7 +156,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
- this.tim.on(TIM.EVENT.NET_STATE_CHANGE, function(event) {
|
|
|
|
|
|
|
+ this.tim.on(TIM.EVENT.NET_STATE_CHANGE, (event)=>{
|
|
|
// 网络状态发生改变(v2.5.0 起支持)。
|
|
// 网络状态发生改变(v2.5.0 起支持)。
|
|
|
// event.name - TIM.EVENT.NET_STATE_CHANGE
|
|
// event.name - TIM.EVENT.NET_STATE_CHANGE
|
|
|
// event.data.state 当前网络状态,枚举值及说明如下:
|
|
// event.data.state 当前网络状态,枚举值及说明如下:
|
|
@@ -171,7 +171,7 @@ export default {
|
|
|
userID: this.userID.toString(),
|
|
userID: this.userID.toString(),
|
|
|
userSig: this.userSig,
|
|
userSig: this.userSig,
|
|
|
})
|
|
})
|
|
|
- .then(function(imResponse) {
|
|
|
|
|
|
|
+ .then((imResponse)=>{
|
|
|
console.log(imResponse.data); // 登录成功
|
|
console.log(imResponse.data); // 登录成功
|
|
|
if (window.ReactNativeWebView) {
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
window.ReactNativeWebView.postMessage(
|
|
@@ -179,7 +179,7 @@ export default {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
- .catch(function(imError) {
|
|
|
|
|
|
|
+ .catch((imError)=> {
|
|
|
console.log(imError)
|
|
console.log(imError)
|
|
|
if (window.ReactNativeWebView) {
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
window.ReactNativeWebView.postMessage(
|