Skip to content

Commit c2ca5c6

Browse files
author
Hevin
committed
Merge branch 'dev'
2 parents 71fd135 + 35a4057 commit c2ca5c6

File tree

7 files changed

+33
-23
lines changed

7 files changed

+33
-23
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JMessage PhoneGap / Cordova Plugin
22

3-
[![release](https://img.shields.io/badge/release-3.4.0-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases)
3+
[![release](https://img.shields.io/badge/release-3.4.4-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases)
44
[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-green.svg)](https://github.com/jpush/jmessage-phonegap-plugin)
55
[![Code Triagers Badge](https://www.codetriage.com/jpush/jmessage-phonegap-plugin/badges/users.svg)](https://www.codetriage.com/jpush/jmessage-phonegap-plugin)
66
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
@@ -9,7 +9,9 @@
99

1010
若只需要简单的聊天功能,可优先考虑使用 [JMessage Web SDK](https://docs.jiguang.cn/jmessage/client/im_sdk_js_v2/)
1111

12-
注意:从 v3.4.0 开始支持 cordova-android 7.0.0,因 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。如果需要安装之前版本的插件,请先安装 v1.2.0 以下版本的 cordova-plugin-jcore,再安装插件。
12+
>注意:从 v3.4.0 开始支持 cordova-android 7.0.0,因 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。
13+
>
14+
>如果需要安装之前版本的插件,请先自行安装 v1.2.0 以下版本(建议安装 v1.1.12,cordova-plugin-jcore 向下兼容)的 cordova-plugin-jcore,再安装插件,否则运行会报错。
1315
1416
## Full Documentation
1517

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jmessage-phonegap-plugin",
3-
"version": "3.4.0",
3+
"version": "3.4.4",
44
"description": "JMessage Cordova Plugin.",
55
"cordova": {
66
"id": "jmessage-phonegap-plugin",

plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="jmessage-phonegap-plugin"
5-
version="3.4.0">
5+
version="3.4.4">
66

77
<name>JMessage</name>
88
<description>集成极光 IM 和推送功能</description>
@@ -158,6 +158,7 @@
158158
</config-file>
159159

160160
<lib-file src="src/android/libs/jmessage-android_v2.4.1.jar" />
161+
161162
<source-file src="src/android/JMessagePlugin.java" target-dir="app/src/main/java/cn/jiguang/cordova/im"/>
162163
<source-file src="src/android/JMessageUtils.java" target-dir="app/src/main/java/cn/jiguang/cordova/im"/>
163164
<source-file src="src/android/JsonUtils.java" target-dir="app/src/main/java/cn/jiguang/cordova/im"/>

src/android/JsonUtils.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ static JSONObject toJson(Message msg) {
124124
result.put("id", String.valueOf(msg.getId())); // 本地数据库 id
125125
result.put("serverMessageId", String.valueOf(msg.getServerMessageId())); // 服务器端 id
126126
result.put("from", toJson(msg.getFromUser())); // 消息发送者
127-
result.put("isSend", msg.getDirect() == MessageDirect.send); // 消息是否是由当前用户发出
127+
128+
boolean isSend = msg.getDirect().equals(MessageDirect.send);
129+
result.put("isSend", isSend); // 消息是否是由当前用户发出
128130

129131
JSONObject targetJson = null;
130132
switch (msg.getTargetType()) {
131133
case single:
132-
if (msg.getDirect() == MessageDirect.send) { // 消息发送
134+
if (isSend) { // 消息发送
133135
targetJson = toJson((UserInfo) msg.getTargetInfo());
134136
} else { // 消息接收
135137
targetJson = toJson(JMessageClient.getMyInfo());
@@ -141,6 +143,7 @@ static JSONObject toJson(Message msg) {
141143
case chatroom:
142144
targetJson = toJson((ChatRoomInfo) msg.getTargetInfo());
143145
break;
146+
default:
144147
}
145148
result.put("target", targetJson);
146149

@@ -186,7 +189,9 @@ static JSONObject toJson(Message msg) {
186189
case eventNotification:
187190
result.put("type", "event");
188191
List usernameList = ((EventNotificationContent) content).getUserNames();
189-
result.put("usernames", toJson(usernameList));
192+
if (usernameList != null) {
193+
result.put("usernames", toJson(usernameList));
194+
}
190195
switch (((EventNotificationContent) content).getEventNotificationType()) {
191196
case group_member_added:
192197
//群成员加群事件
@@ -200,7 +205,9 @@ static JSONObject toJson(Message msg) {
200205
//群成员退群事件
201206
result.put("eventType", "group_member_exit");
202207
break;
208+
default:
203209
}
210+
default:
204211
}
205212
} catch (JSONException e) {
206213
e.printStackTrace();

src/ios/Plugins/JMessageHelper.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ - (void)onSyncOfflineMessageConversation:(JMSGConversation *)conversation
217217

218218
#pragma mark - Group 回调
219219

220-
- (void)onGroupInfoChanged:(JMSGGroup *)group{
221-
[[NSNotificationCenter defaultCenter] postNotificationName:kJJMessageGroupInfoChanged object:[group groupToDictionary]];
222-
}
223-
224220
@end
225221

226222

src/ios/Plugins/JMessagePlugin.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,7 @@ -(void)initNotifications {
145145
selector:@selector(didReceiveRetractMessage:)
146146
name:kJJMessageRetractMessage
147147
object:nil];
148-
149-
[defaultCenter addObserver:self
150-
selector:@selector(groupInfoChanged:)
151-
name:kJJMessageGroupInfoChanged
152-
object:nil];
148+
153149

154150
[defaultCenter addObserver:self
155151
selector:@selector(onSyncOfflineMessage:)
@@ -422,10 +418,6 @@ - (void)unreadChanged:(NSNotification *)notification{
422418
[self evalFuntionName:@"onUnreadChanged" jsonParm:[notification.object toJsonString]];
423419
}
424420

425-
- (void)groupInfoChanged:(NSNotification *)notification{
426-
[self evalFuntionName:@"onGroupInfoChanged" jsonParm:[notification.object toJsonString]];
427-
}
428-
429421
- (void)loginStateChanged:(NSNotification *)notification{
430422
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"loginStateChanged", @"value": notification.object}];
431423

@@ -987,12 +979,24 @@ - (void)getHistoryMessages:(CDVInvokedUrlCommand *)command {
987979
if ([limit isEqualToNumber:@(-1)]) {
988980
limit = nil;
989981
}
982+
983+
BOOL isDescend = false;
984+
if (param[@"isDescend"]) {
985+
NSNumber *number = param[@"isDescend"];
986+
isDescend = [number boolValue];
987+
}
988+
990989
NSArray *messageList = [conversation messageArrayFromNewestWithOffset:param[@"from"] limit:limit];
991990

992991
NSArray *messageDicArr = [messageList mapObjectsUsingBlock:^id(id obj, NSUInteger idx) {
993992
JMSGMessage *message = obj;
994993
return [message messageToDictionary];
995994
}];
995+
996+
if (isDescend) {
997+
messageDicArr = [[messageDicArr reverseObjectEnumerator] allObjects];
998+
}
999+
9961000
[self handleResultWithArray:messageDicArr command:command error:error];
9971001
}];
9981002
}

www/JMessagePlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ var JMessagePlugin = {
3535
* 是否开启了自定义接收方通知栏功能。
3636
* @type {?boolean}
3737
*/
38-
isCustomNotificationEnabled: null,
38+
isCustomNotificationEnabled: undefined,
3939
/**
4040
* 设置此条消息在接收方通知栏所展示通知的标题。
4141
* @type {?string}
4242
*/
43-
notificationTitle: null,
43+
notificationTitle: undefined,
4444
/**
4545
* 设置此条消息在接收方通知栏所展示通知的内容。
4646
* @type {?string}
4747
*/
48-
notificationText: null
48+
notificationText: undefined
4949
},
5050
/**
5151
* @param {object} params = {

0 commit comments

Comments
 (0)