forked from lomocoin/react-native-lomocoin-rongcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
142 lines (132 loc) · 5.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
'use strict';
import {
NativeModules,
DeviceEventEmitter,
NativeEventEmitter,
Platform
}
from 'react-native';
const RongCloudIMLib = NativeModules.RongCloudIMLibModule;
var _onRongCloudMessageReceived = function (resp) {
console.log("融云接受消息:" + JSON.stringify(resp));
}
// DeviceEventEmitter.addListener('onRongMessageReceived', (resp) => {
// typeof (_onRongCloudMessageReceived) === 'function' && _onRongCloudMessageReceived(resp);
// });
const RongCloudIMLibEmitter = new NativeEventEmitter(RongCloudIMLib);
const subscription = RongCloudIMLibEmitter.addListener(
'onRongMessageReceived',
(resp) => {
typeof (_onRongCloudMessageReceived) === 'function' && _onRongCloudMessageReceived(resp);
}
);
const ConversationType = {
PRIVATE: 'PRIVATE',
DISCUSSION: 'DISCUSSION',
SYSTEM: 'SYSTEM'
};
export default {
ConversationType: ConversationType,
onReceived(callback) {
_onRongCloudMessageReceived = callback;
},
initWithAppKey(appKey) {
return RongCloudIMLib.initWithAppKey(appKey);
},
connectWithToken(token) {
return RongCloudIMLib.connectWithToken(token);
},
getTotalUnreadCount() {
// 获取全部未读消息数量(此消息数量为SDK本地查询到的未读消息数(有可能包含已退出群组的消息数量))
return RongCloudIMLib.getTotalUnreadCount();
},
getTargetUnreadCount(conversationType, targetId) {
// 获取某个会话类型的target 的未读消息数
return RongCloudIMLib.getTargetUnreadCount(conversationType, targetId);
},
getConversationsUnreadCount(conversationTypes) {
// 获取某些会话类型(conversationTypes为数组)的未读消息数(此消息数量为SDK本地查询到的未读消息数(有可能包含已退出群组的消息数量))
return RongCloudIMLib.getConversationsUnreadCount(conversationTypes);
},
clearUnreadMessage(conversationType, targetId) {
return RongCloudIMLib.clearUnreadMessage(conversationType, targetId);
},
searchConversations(keyword) {
return RongCloudIMLib.searchConversations(keyword);
},
getConversationList() {
return RongCloudIMLib.getConversationList();
},
getLatestMessages(type, targetId, count) {
return RongCloudIMLib.getLatestMessages(type, targetId, count);
},
getHistoryMessages(type, targetId, oldestMessageId, count) {
return RongCloudIMLib.getHistoryMessages(type, targetId, oldestMessageId, count);
},
getDesignatedTypeHistoryMessages(type, targetId, objectName, oldestMessageId, count) {
return RongCloudIMLib.getDesignatedTypeHistoryMessages(type, targetId, objectName, oldestMessageId, count);
},
//仅支持android
getDesignatedDirectionypeHistoryMessages(type, targetId, objectName, baseMessageId, count, direction) {
return RongCloudIMLib.getDesignatedDirectionypeHistoryMessages(type, targetId, objectName, baseMessageId, count, direction);
},
//仅支持android
getBaseOnSentTimeHistoryMessages(type, targetId, sentTime, before, after) {
return RongCloudIMLib.getBaseOnSentTimeHistoryMessages(type, targetId, sentTime, before, after);
},
sendTextMessage(conversationType, targetId, content, pushContent) {
return RongCloudIMLib.sendTextMessage(conversationType, targetId, content, pushContent);
},
sendImageMessage(conversationType, targetId, imageUrl, pushContent) {
return RongCloudIMLib.sendImageMessage(conversationType, targetId, imageUrl, pushContent);
},
voiceBtnPressIn(conversationType, targetId, pushContent) {
return RongCloudIMLib.voiceBtnPressIn(conversationType, targetId, pushContent);
},
voiceBtnPressOut(conversationType, targetId, pushContent) {
return RongCloudIMLib.voiceBtnPressOut(conversationType, targetId, pushContent);
},
voiceBtnPressCancel(conversationType, targetId) {
return RongCloudIMLib.voiceBtnPressCancel(conversationType, targetId);
},
audioPlayStart(filePath) {
return RongCloudIMLib.audioPlayStart(filePath);
},
audioPlayStop() {
return RongCloudIMLib.audioPlayStop();
},
setConversationNotificationStatus(conversationType, targetId, isBlocked) {
//设置会话消息提醒 isBlocked(true 屏蔽 false 新消息提醒) (return 0:(屏蔽) 1:(新消息提醒))
return RongCloudIMLib.setConversationNotificationStatus(conversationType, targetId, isBlocked);
},
getConversationNotificationStatus(conversationType, targetId) {
//获取会话消息提醒状态 (return 0:(屏蔽) 1:(新消息提醒))
return RongCloudIMLib.getConversationNotificationStatus(conversationType, targetId);
},
screenGlobalNotification() {
//屏蔽全局新消息提醒
return RongCloudIMLib.screenGlobalNotification();
},
removeScreenOfGlobalNotification() {
//移除全局新消息屏蔽
return RongCloudIMLib.removeScreenOfGlobalNotification();
},
getGlobalNotificationStatus() {
//获取全局新消息提醒状态 ( return 0:(屏蔽) 1:(新消息提醒))
return RongCloudIMLib.getGlobalNotificationStatus();
},
//isReceivePush-true 开启后台推送 false-关闭后台推送
disconnect(isReceivePush) {
return RongCloudIMLib.disconnect(isReceivePush);
},
logout() {
return RongCloudIMLib.logout();
},
getFCMToken() {
if (Platform.OS === 'android') {
return RongCloudIMLib.getFCMToken();
} else {
return '';
}
},
};