Skip to content

Commit ce6b06b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents fd91c5d + f77c1f2 commit ce6b06b

File tree

1 file changed

+118
-4
lines changed

1 file changed

+118
-4
lines changed

README.md

Lines changed: 118 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,123 @@
11
# ReactNative IMUI
22
项目fork自 jpush 的 [Aurora IMUI](https://github.com/jpush/aurora-imui/tree/master/ReactNative)
33

4-
54
## 使用
6-
当前提供的组件:
5+
参考[demo](https://github.com/reactnativecomponent/react-native-chat-demo)
6+
## 安装
7+
8+
```
9+
npm install react-native-imui --save
10+
react-native link
11+
```
12+
13+
如果 link 安卓失败,需要手动修改一下 `settings.gradle` 中的引用路径:
14+
15+
```
16+
include ':app', ':react-native-imui'
17+
project(':react-native-imui').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-imui/android')
18+
```
19+
20+
然后在 app 的 `build.gradle`中引用:
21+
22+
```
23+
dependencies {
24+
compile project(':react-native-imui')
25+
}
26+
```
27+
28+
**注意事项(Android):我们使用了 support v4, v7 25.3.1 版本,因此需要将你的 build.gradle 中 buildToolsVersion 及 compiledSdkVersion 改为 25 以上。可以参考 demo 的配置。**
29+
30+
## 配置
31+
32+
- ### Android
33+
34+
- 引入 Package:
35+
36+
> MainApplication.java
37+
38+
```
39+
import cn.jiguang.imui.messagelist.ReactIMUIPackage;
40+
...
41+
42+
@Override
43+
protected List<ReactPackage> getPackages() {
44+
return Arrays.<ReactPackage>asList(
45+
new MainReactPackage(),
46+
new ReactIMUIPackage()
47+
);
48+
}
49+
```
50+
51+
52+
53+
54+
55+
56+
- ### iOS
57+
- PROJECT -> TARGETS -> Build Settings -> Enable Bitcode Set to No
58+
- Find PROJECT -> TARGETS -> General -> Embedded Binaries and add RCTAuroraIMUI.framework
59+
60+
## 数据格式
61+
62+
使用 MessageList,你需要定义 `message` 对象和 `fromUser` 对象。
63+
64+
- `message` 对象格式:
65+
66+
**status 必须为以下四个值之一: "send_succeed", "send_failed", "send_going", "download_failed",如果没有定义这个属性, 默认值是 "send_succeed".**
67+
68+
```
69+
message = { // text message
70+
msgId: "msgid",
71+
status: "send_going",
72+
msgType: "text",
73+
isOutgoing: true,
74+
text: "text"
75+
fromUser: {}
76+
}
77+
78+
message = { // image message
79+
msgId: "msgid",
80+
msgType: "image",
81+
isOutGoing: true,
82+
progress: "progress string"
83+
mediaPath: "image path"
84+
fromUser: {}
85+
}
86+
87+
88+
message = { // voice message
89+
msgId: "msgid",
90+
msgType: "voice",
91+
isOutGoing: true,
92+
duration: number, // 注意这个值有用户自己设置时长,单位秒
93+
mediaPath: "voice path"
94+
fromUser: {}
95+
}
96+
97+
message = { // video message
98+
msgId: "msgid",
99+
status: "send_failed",
100+
msgType: "video",
101+
isOutGoing: true,
102+
druation: number
103+
mediaPath: "voice path"
104+
fromUser: {}
105+
}
106+
107+
message = { // event message
108+
msgId: "msgid",
109+
msgType: "event",
110+
text: "the event text"
111+
}
112+
```
113+
114+
- `fromUser` 对象格式:
115+
116+
```
117+
fromUser = {
118+
userId: ""
119+
displayName: ""
120+
avatarPath: "avatar image path"
121+
}
122+
```
7123

8-
### React Native
9-
- [AuroraIMUI](./ReactNative/README_zh.md)

0 commit comments

Comments
 (0)