|
|
@@ -64,7 +64,7 @@ export default {
|
|
|
// event.data - 存储 Message 对象的数组 - [Message]
|
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
|
- JSON.stringify(event.data),
|
|
|
+ JSON.stringify(event.data)
|
|
|
);
|
|
|
}
|
|
|
});
|
|
|
@@ -90,7 +90,7 @@ export default {
|
|
|
// event.data - 存储 Conversation 对象的数组 - [Conversation]
|
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
|
- JSON.stringify(event),
|
|
|
+ JSON.stringify(event)
|
|
|
);
|
|
|
}
|
|
|
});
|
|
|
@@ -101,7 +101,7 @@ export default {
|
|
|
// event.data - 存储 Group 对象的数组 - [Group]
|
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
|
- JSON.stringify(event.data),
|
|
|
+ JSON.stringify(event.data)
|
|
|
);
|
|
|
}
|
|
|
});
|
|
|
@@ -128,7 +128,7 @@ export default {
|
|
|
// event.data.message - 错误信息
|
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
|
- JSON.stringify(event),
|
|
|
+ JSON.stringify(event)
|
|
|
);
|
|
|
}
|
|
|
});
|
|
|
@@ -136,11 +136,11 @@ export default {
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
this.tim.on(TIM.EVENT.SDK_NOT_READY, function(event) {
|
|
|
// 收到 SDK 进入 not ready 状态通知,此时 SDK 无法正常工作
|
|
|
- // event.name - TIM.EVENT.SDK_NOT_READY
|
|
|
-
|
|
|
+ // event.name - TIM.EVENT.SDK_NOT_READY
|
|
|
+
|
|
|
if (window.ReactNativeWebView) {
|
|
|
window.ReactNativeWebView.postMessage(
|
|
|
- JSON.stringify(event),
|
|
|
+ JSON.stringify(event)
|
|
|
);
|
|
|
}
|
|
|
});
|
|
|
@@ -166,16 +166,27 @@ export default {
|
|
|
});
|
|
|
|
|
|
// 开始登录
|
|
|
- this.tim.login({
|
|
|
- userID: this.userID.toString(),
|
|
|
- userSig: this.userSig,
|
|
|
- });
|
|
|
-
|
|
|
- if (window.ReactNativeWebView) {
|
|
|
- window.ReactNativeWebView.postMessage(
|
|
|
- `用户${this.userID}登录成功`,
|
|
|
- );
|
|
|
- }
|
|
|
+ this.tim
|
|
|
+ .login({
|
|
|
+ userID: this.userID.toString(),
|
|
|
+ userSig: this.userSig,
|
|
|
+ })
|
|
|
+ .then(function(imResponse) {
|
|
|
+ console.log(imResponse.data); // 登录成功
|
|
|
+ if (window.ReactNativeWebView) {
|
|
|
+ window.ReactNativeWebView.postMessage(
|
|
|
+ `用户${this.userID}登录成功`
|
|
|
+ );
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(function(imError) {
|
|
|
+ console.log(imError)
|
|
|
+ if (window.ReactNativeWebView) {
|
|
|
+ window.ReactNativeWebView.postMessage(
|
|
|
+ JSON.stringify(imError)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
sendMessage(text, toUserId) {
|
|
|
let message = this.tim.createTextMessage({
|