diff --git a/README.md b/README.md index 6539149..ce0ff25 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JMessage PhoneGap / Cordova Plugin -[![release](https://img.shields.io/badge/release-3.4.0-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases) +[![release](https://img.shields.io/badge/release-3.4.4-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases) [![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-green.svg)](https://github.com/jpush/jmessage-phonegap-plugin) [![Code Triagers Badge](https://www.codetriage.com/jpush/jmessage-phonegap-plugin/badges/users.svg)](https://www.codetriage.com/jpush/jmessage-phonegap-plugin) [![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1) @@ -9,7 +9,9 @@ 若只需要简单的聊天功能,可优先考虑使用 [JMessage Web SDK](https://docs.jiguang.cn/jmessage/client/im_sdk_js_v2/)。 -注意:从 v3.4.0 开始支持 cordova-android 7.0.0,因 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。如果需要安装之前版本的插件,请先安装 v1.2.0 以下版本的 cordova-plugin-jcore,再安装插件。 +>注意:从 v3.4.0 开始支持 cordova-android 7.0.0,因 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。 +> +>如果需要安装之前版本的插件,请先自行安装 v1.2.0 以下版本(建议安装 v1.1.12,cordova-plugin-jcore 向下兼容)的 cordova-plugin-jcore,再安装插件,否则运行会报错。 ## Full Documentation diff --git a/package.json b/package.json index 5d68fb6..1b4f9e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jmessage-phonegap-plugin", - "version": "3.4.0", + "version": "3.4.4", "description": "JMessage Cordova Plugin.", "cordova": { "id": "jmessage-phonegap-plugin", diff --git a/plugin.xml b/plugin.xml index 8326456..b4ca7ca 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.4.4"> JMessage 集成极光 IM 和推送功能 @@ -158,6 +158,7 @@ + diff --git a/src/android/JsonUtils.java b/src/android/JsonUtils.java index d4f53e9..44cc9b1 100644 --- a/src/android/JsonUtils.java +++ b/src/android/JsonUtils.java @@ -124,12 +124,14 @@ static JSONObject toJson(Message msg) { result.put("id", String.valueOf(msg.getId())); // 本地数据库 id result.put("serverMessageId", String.valueOf(msg.getServerMessageId())); // 服务器端 id result.put("from", toJson(msg.getFromUser())); // 消息发送者 - result.put("isSend", msg.getDirect() == MessageDirect.send); // 消息是否是由当前用户发出 + + boolean isSend = msg.getDirect().equals(MessageDirect.send); + result.put("isSend", isSend); // 消息是否是由当前用户发出 JSONObject targetJson = null; switch (msg.getTargetType()) { case single: - if (msg.getDirect() == MessageDirect.send) { // 消息发送 + if (isSend) { // 消息发送 targetJson = toJson((UserInfo) msg.getTargetInfo()); } else { // 消息接收 targetJson = toJson(JMessageClient.getMyInfo()); @@ -141,6 +143,7 @@ static JSONObject toJson(Message msg) { case chatroom: targetJson = toJson((ChatRoomInfo) msg.getTargetInfo()); break; + default: } result.put("target", targetJson); @@ -186,7 +189,9 @@ static JSONObject toJson(Message msg) { case eventNotification: result.put("type", "event"); List usernameList = ((EventNotificationContent) content).getUserNames(); - result.put("usernames", toJson(usernameList)); + if (usernameList != null) { + result.put("usernames", toJson(usernameList)); + } switch (((EventNotificationContent) content).getEventNotificationType()) { case group_member_added: //群成员加群事件 @@ -200,7 +205,9 @@ static JSONObject toJson(Message msg) { //群成员退群事件 result.put("eventType", "group_member_exit"); break; + default: } + default: } } catch (JSONException e) { e.printStackTrace(); diff --git a/src/ios/Plugins/JMessageHelper.m b/src/ios/Plugins/JMessageHelper.m index 18dc66a..3f37295 100644 --- a/src/ios/Plugins/JMessageHelper.m +++ b/src/ios/Plugins/JMessageHelper.m @@ -217,10 +217,6 @@ - (void)onSyncOfflineMessageConversation:(JMSGConversation *)conversation #pragma mark - Group 回调 -- (void)onGroupInfoChanged:(JMSGGroup *)group{ - [[NSNotificationCenter defaultCenter] postNotificationName:kJJMessageGroupInfoChanged object:[group groupToDictionary]]; -} - @end diff --git a/src/ios/Plugins/JMessagePlugin.m b/src/ios/Plugins/JMessagePlugin.m index 8cbaf24..f8fed94 100644 --- a/src/ios/Plugins/JMessagePlugin.m +++ b/src/ios/Plugins/JMessagePlugin.m @@ -145,11 +145,7 @@ -(void)initNotifications { selector:@selector(didReceiveRetractMessage:) name:kJJMessageRetractMessage object:nil]; - - [defaultCenter addObserver:self - selector:@selector(groupInfoChanged:) - name:kJJMessageGroupInfoChanged - object:nil]; + [defaultCenter addObserver:self selector:@selector(onSyncOfflineMessage:) @@ -422,10 +418,6 @@ - (void)unreadChanged:(NSNotification *)notification{ [self evalFuntionName:@"onUnreadChanged" jsonParm:[notification.object toJsonString]]; } -- (void)groupInfoChanged:(NSNotification *)notification{ - [self evalFuntionName:@"onGroupInfoChanged" jsonParm:[notification.object toJsonString]]; -} - - (void)loginStateChanged:(NSNotification *)notification{ CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"loginStateChanged", @"value": notification.object}]; @@ -987,12 +979,24 @@ - (void)getHistoryMessages:(CDVInvokedUrlCommand *)command { if ([limit isEqualToNumber:@(-1)]) { limit = nil; } + + BOOL isDescend = false; + if (param[@"isDescend"]) { + NSNumber *number = param[@"isDescend"]; + isDescend = [number boolValue]; + } + NSArray *messageList = [conversation messageArrayFromNewestWithOffset:param[@"from"] limit:limit]; NSArray *messageDicArr = [messageList mapObjectsUsingBlock:^id(id obj, NSUInteger idx) { JMSGMessage *message = obj; return [message messageToDictionary]; }]; + + if (isDescend) { + messageDicArr = [[messageDicArr reverseObjectEnumerator] allObjects]; + } + [self handleResultWithArray:messageDicArr command:command error:error]; }]; } diff --git a/www/JMessagePlugin.js b/www/JMessagePlugin.js index 07cc0a9..6f63530 100644 --- a/www/JMessagePlugin.js +++ b/www/JMessagePlugin.js @@ -35,17 +35,17 @@ var JMessagePlugin = { * 是否开启了自定义接收方通知栏功能。 * @type {?boolean} */ - isCustomNotificationEnabled: null, + isCustomNotificationEnabled: undefined, /** * 设置此条消息在接收方通知栏所展示通知的标题。 * @type {?string} */ - notificationTitle: null, + notificationTitle: undefined, /** * 设置此条消息在接收方通知栏所展示通知的内容。 * @type {?string} */ - notificationText: null + notificationText: undefined }, /** * @param {object} params = {