Skip to content

Commit 652b8ab

Browse files
Merge pull request #7 from jpush/dev
update to 2.0.0-beta
2 parents f72f4ed + dde1d9d commit 652b8ab

File tree

104 files changed

+13695
-2566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+13695
-2566
lines changed

.gitignore

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# OSX
2-
#
3-
.DS_Store
4-
51
# Xcode
62
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## Build generated
76
build/
7+
DerivedData/
8+
9+
## Various settings
810
*.pbxuser
911
!default.pbxuser
1012
*.mode1v3
@@ -13,14 +15,52 @@ build/
1315
!default.mode2v3
1416
*.perspectivev3
1517
!default.perspectivev3
16-
xcuserdata
17-
*.xccheckout
18+
xcuserdata/
19+
20+
## Other
1821
*.moved-aside
19-
DerivedData
22+
*.xccheckout
23+
*.xcscmblueprint
24+
25+
## Obj-C/Swift specific
2026
*.hmap
2127
*.ipa
22-
*.xcuserstate
23-
project.xcworkspace
28+
*.dSYM.zip
29+
*.dSYM
30+
31+
# CocoaPods
32+
#
33+
# We recommend against adding the Pods directory to your .gitignore. However
34+
# you should judge for yourself, the pros and cons are mentioned at:
35+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36+
#
37+
# Pods/
38+
39+
# Carthage
40+
#
41+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
42+
# Carthage/Checkouts
43+
44+
Carthage/Build
45+
46+
# fastlane
47+
#
48+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
49+
# screenshots whenever they are needed.
50+
# For more information about the recommended setup visit:
51+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
52+
53+
fastlane/report.xml
54+
fastlane/Preview.html
55+
fastlane/screenshots
56+
fastlane/test_output
57+
58+
# Code Injection
59+
#
60+
# After new code Injection tools there's a generated folder /iOSInjectionProject
61+
# https://github.com/johnno1962/injectionforxcode
62+
63+
iOSInjectionProject/
2464

2565
# Android/IJ
2666
#
@@ -32,3 +72,24 @@ local.properties
3272
#
3373
node_modules/
3474
npm-debug.log
75+
76+
77+
78+
.qshell
79+
*.qshel
80+
*.DS_Store
81+
example/node_modules/
82+
*.gradle/
83+
gradle.properties
84+
build/
85+
build-res/
86+
/*/build/
87+
*.iml
88+
*.idea/
89+
*.DS_Store
90+
*.log
91+
.qshell
92+
*.qshell
93+
example/node_modules/*
94+
example/npm-debug*
95+

README.md

Lines changed: 23 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,41 @@
1-
# jmessage-react-plugin (iOS 尚未支持)
2-
## Android
1+
# jmessage-react-plugin
32

4-
#### 这是一个使用 JMessage-sdk 的 React Native 插件,目前实现了收发文字消息。
3+
极光官方开发的[极光 IM](https://docs.jiguang.cn/jmessage/guideline/jmessage_guide/) react-native 插件,同时支持 文字、图片、语言、文件和自定义消息。同时支持 iOS 和 Android 平台。
4+
5+
## 安装
56

6-
#### 安装
77
```
88
npm install jmessage-react-plugin --save
9+
npm install jcore-react-native --save
910
react-native link
1011
```
11-
安装完毕后,在 MainApplication 中加上 JMessagePackage 即可。
12-
```
13-
@Override
14-
protected List<ReactPackage> getPackages() {
15-
return Arrays.<ReactPackage>asList(
16-
new MainReactPackage(),
17-
new JMessageReactPackage(),
18-
);
19-
}
20-
```
21-
22-
#### example 使用
23-
```
24-
npm install react-native-jchat-demo
25-
react-native run-android
26-
```
27-
28-
关于 jmessage-sdk 的相关接口说明可以参考:
29-
##### [极光 IM Android SDK 概述](http://docs.jpush.io/client/im_sdk_android/)
30-
31-
##### [IM Android SDK Java docs](http://docs.jpush.io/client/im_android_api_docs/)
3212

33-
#### jmessage-react-plugin Android 的项目结构说明
34-
##### JS 部分
35-
除了入口 index.android.js 之外,都放在 react-native-android 文件夹下
36-
37-
##### Native部分
38-
- entity 根据需求抽象出的一些实体类,主要是为了使用 Gson 转换为 json 字符串传到 JS(如果是纯 React Native 应用,则不需要如此,直接请求服务端即可)
39-
- tools 主要是一些工具类
40-
- 其他 包括 Native 入口类以及 NativeModule 等
13+
## 配置
4114

42-
#### 接口调用
15+
#### Android
4316

44-
##### 在 JS 中调用 jmessage-sdk 的接口详情
45-
```
46-
const JMessageModule = NativeModules.JMessageModule;
47-
```
48-
- 加载 conversations:
49-
```
50-
JMessageModule.getConvList().then((list) => {
51-
_convList = JSON.parse(list);
52-
this.setState({
53-
dataSource: _ds.cloneWithRows(_convList),
54-
fetching: false
55-
});
56-
}).catch((e) => {
57-
console.log(e);
58-
this.setState({
59-
fetching: false
60-
});
61-
});
62-
```
63-
- 接收消息
64-
```
65-
const RECEIVE_MSG_EVENT = "receiveMsgEvent";
17+
#### 这是一个使用 JMessage-sdk 的 React Native 插件,支持文字、图片、语言、文件消息。
6618

67-
componentDidMount() {
68-
DeviceEventEmitter.addListener(RECEIVE_MSG_EVENT, (map) => {
69-
console.log("收到消息: " + map.message);
70-
let conversation = JSON.parse(map.conversation);
71-
for (let conv in _convList) {
72-
if (conv.username === conversation.username || conv.groupId === conversation.groupId) {
73-
conv = conversation;
74-
}
75-
}
76-
let newData = JSON.parse(JSON.stringify(_convList));
77-
newData.sort(this.by("date"));
78-
this.setState({
79-
dataSource: _ds.cloneWithRows(newData)
80-
});
81-
_convList = newData;
82-
});
83-
}
84-
```
85-
- 发送消息
86-
```
87-
const {username, appKey, groupId} = this.props;
88-
JMessageModule.sendTxtMsg(username, appKey, groupId, this.state.inputContent)
89-
.then((msg) => {
90-
console.log("Sending text message: " + msg);
91-
this.msgArr.push(JSON.parse(msg));
92-
console.log("msgArr: " + this.msgArr);
93-
this.setState({
94-
dataSource: this.state.ds.cloneWithRows(this.msgArr),
95-
inputContent: ""
96-
});
97-
if (this.listView !== null) {
98-
this.listView.scrollToEnd();
99-
}
100-
}).catch((e) => {
101-
console.log(e);
102-
this.setState({
103-
inputContent: ""
104-
});
105-
});
106-
```
107-
发送消息后还需要监听发送状态:
10819

20+
安装完毕后,在 MainApplication 中加上 JMessagePackage 即可。
10921
```
110-
const SEND_MSG_RESULT = "sendMsgResult";
111-
DeviceEventEmitter.addListener(SEND_MSG_RESULT, this.sendMsgResult);
112-
sendMsgResult = (msg) => {
113-
var message = JSON.parse(msg);
114-
for (var i = this.msgArr.length - 1; i >= 0; i--) {
115-
if (this.msgArr[i].msgId === message.msgId) {
116-
this.msgArr[i].sendState = message.sendState;
117-
}
118-
}
119-
let newData = JSON.parse(JSON.stringify(this.msgArr));
120-
this.setState({
121-
dataSource: this.state.ds.cloneWithRows(newData)
122-
});
123-
this.msgArr = newData;
124-
};
22+
@Override
23+
protected List<ReactPackage> getPackages() {
24+
return Arrays.<ReactPackage>asList(
25+
new MainReactPackage(),
26+
new JMessageReactPackage(),
27+
);
28+
}
12529
```
12630

127-
- 分页加载消息
128-
129-
```
130-
JMessageModule.getMessageFromNewest(username, appKey, groupId, this.START, this.PAGE_MSG_COUNT)
131-
.then((result) => {
132-
if ("" === result) {
133-
console.log("No last page");
134-
this.setState({
135-
fetching: false
136-
});
137-
return;
138-
}
139-
let msgData = JSON.parse(result);
140-
msgData.reverse();
141-
this.msgArr = this.msgArr.concat(msgData);
142-
this.MSG_OFFSET = this.START + msgData.length;
143-
this.START = this.MSG_OFFSET;
144-
this.setState({
145-
fetching: false,
146-
dataSource: this.state.ds.cloneWithRows(this.msgArr)
147-
});
148-
}).catch((e) => {
149-
console.log(e);
150-
this.setState({
151-
fetching: false
152-
});
153-
});
154-
```
31+
## API
15532

156-
- 进入会话(进入会话后,通知栏不会展示此会话中收到的消息)
33+
[API doc](./document/API.md)
15734

158-
```
159-
JMessageModule.enterConversation(username, appKey, groupId);
160-
```
161-
- 添加好友(无好友模式)
35+
## 更多
16236

163-
```
164-
JMessageModule.addFriend(inputTxt).then((result) => {
165-
var newDs = JSON.parse(result);
166-
_convList = [newDs, ..._convList];
167-
this.setState({
168-
dataSource: _ds.cloneWithRows(_convList)
169-
});
170-
}).catch((e) => {
171-
console.log(e);
172-
});
173-
```
37+
- QQ 群:553406342
38+
- [极光官网文档](http://docs.jiguang.cn/guideline/jmessage_guide/)
39+
- 插件问题可以直接提 [issue](https://github.com/jpush/jmessage-react-plugin/issues)
40+
- 有问题可访问[极光社区](http://community.jiguang.cn/)搜索和提问。
17441

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ buildscript {
44
}
55

66
dependencies {
7-
classpath 'com.android.tools.build:gradle:2.2.3'
7+
classpath 'com.android.tools.build:gradle:2.3.1'
88
}
99
}
1010

1111
apply plugin: 'com.android.library'
1212

1313
android {
1414
compileSdkVersion 23
15-
buildToolsVersion "23.0.2"
15+
buildToolsVersion "25.0.2"
1616

1717
defaultConfig {
1818
minSdkVersion 16
@@ -42,5 +42,5 @@ repositories {
4242

4343
dependencies {
4444
compile fileTree(dir: 'libs', include: ['*.jar'])
45-
compile "com.facebook.react:react-native:0.41.0"
45+
compile "com.facebook.react:react-native:+"
4646
}
-126 KB
Binary file not shown.
-77.4 KB
Binary file not shown.
-81.4 KB
Binary file not shown.

android/libs/gson-2.6.2.jar

-224 KB
Binary file not shown.
-291 KB
Binary file not shown.
-1.1 MB
Binary file not shown.
1.23 MB
Binary file not shown.

0 commit comments

Comments
 (0)