Skip to content

Commit bb42ca4

Browse files
author
Hevin
committed
Merge branch 'dev'
2 parents 3f93923 + 3461d70 commit bb42ca4

File tree

8 files changed

+60
-57
lines changed

8 files changed

+60
-57
lines changed

README.md

Lines changed: 1 addition & 3 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.1.7-blue.svg)](https://github.com/jpush/jmessage-phonegap-plugin/releases)
3+
[![release](https://img.shields.io/badge/release-3.2.0-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,8 +9,6 @@
99

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

12-
**目前重构了 3.0.0+ 版本,Android, iOS 完全统一接口和对象字段,优化了 API 调用方式,不兼容老版本,升级时请注意。**
13-
1412
## Full Documentation
1513

1614
完整文档请查阅 [wiki](https://github.com/jpush/jmessage-phonegap-plugin/wiki),包括[安装指南](https://github.com/jpush/jmessage-phonegap-plugin/wiki/Installation-Guide)[API 说明](https://github.com/jpush/jmessage-phonegap-plugin/wiki/APIs)等。

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.1.7",
3+
"version": "3.2.0",
44
"description": "JMessage Cordova Plugin.",
55
"cordova": {
66
"id": "jmessage-phonegap-plugin",

plugin.xml

Lines changed: 1 addition & 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.1.7">
5+
version="3.2.0">
66

77
<name>JMessage</name>
88
<description>集成极光 IM 和推送功能</description>

src/android/JsonUtils.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,23 @@ static JSONObject toJson(Message msg) {
127127
result.put("from", toJson(msg.getFromUser())); // 消息发送者
128128
result.put("isSend", msg.getDirect() == MessageDirect.send); // 消息是否是由当前用户发出
129129

130-
if (msg.getDirect() == MessageDirect.send) { // 消息发送
131-
if (msg.getTargetType() == ConversationType.single) { // 消息发送对象的类型
132-
result.put("target", toJson((UserInfo) msg.getTargetInfo()));
133-
} else if (msg.getTargetType() == ConversationType.group) {
134-
result.put("target", toJson((GroupInfo) msg.getTargetInfo()));
135-
}
136-
137-
} else if (msg.getDirect() == MessageDirect.receive) { // 消息接收
138-
if (msg.getTargetType() == ConversationType.single) {
139-
result.put("target", toJson(JMessageClient.getMyInfo()));
140-
} else if (msg.getTargetType() == ConversationType.group) {
141-
result.put("target", toJson((GroupInfo) msg.getTargetInfo()));
142-
}
130+
JSONObject targetJson = null;
131+
switch (msg.getTargetType()) {
132+
case single:
133+
if (msg.getDirect() == MessageDirect.send) { // 消息发送
134+
targetJson = toJson((UserInfo) msg.getTargetInfo());
135+
} else { // 消息接收
136+
targetJson = toJson(JMessageClient.getMyInfo());
137+
}
138+
break;
139+
case group:
140+
targetJson = toJson((GroupInfo) msg.getTargetInfo());
141+
break;
142+
case chatroom:
143+
targetJson = toJson((ChatRoomInfo) msg.getTargetInfo());
144+
break;
143145
}
146+
result.put("target", targetJson);
144147

145148
MessageContent content = msg.getContent();
146149
if (content.getStringExtras() != null) {

src/ios/Plugins/JMessageHelper.m

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -419,63 +419,63 @@ - (NSMutableDictionary *)messageToDictionary {
419419

420420
switch (eventContent.eventType) {
421421
case kJMSGEventNotificationAcceptedFriendInvitation: {
422-
dict[@"evenType"] = @"acceptedFriendInvitation";
422+
dict[@"eventType"] = @"acceptedFriendInvitation";
423423
break;
424424
}
425425
case kJMSGEventNotificationAddGroupMembers: {
426-
dict[@"evenType"] = @"group_member_added";
426+
dict[@"eventType"] = @"group_member_added";
427427
break;
428428
}
429429
case kJMSGEventNotificationCreateGroup: {
430-
dict[@"evenType"] = @"createGroup";
430+
dict[@"eventType"] = @"createGroup";
431431
break;
432432
}
433433
case kJMSGEventNotificationCurrentUserInfoChange: {
434-
dict[@"evenType"] = @"currentUserInfoChange";
434+
dict[@"eventType"] = @"currentUserInfoChange";
435435
break;
436436
}
437437
case kJMSGEventNotificationDeclinedFriendInvitation: {
438-
dict[@"evenType"] = @"declinedFriendInvitation";
438+
dict[@"eventType"] = @"declinedFriendInvitation";
439439
break;
440440
}
441441
case kJMSGEventNotificationDeletedFriend: {
442-
dict[@"evenType"] = @"deletedFriend";
442+
dict[@"eventType"] = @"deletedFriend";
443443
break;
444444
}
445445
case kJMSGEventNotificationExitGroup: {
446-
dict[@"evenType"] = @"group_member_exit";
446+
dict[@"eventType"] = @"group_member_exit";
447447
break;
448448
}
449449
case kJMSGEventNotificationLoginKicked: {
450-
dict[@"evenType"] = @"loginKicked";
450+
dict[@"eventType"] = @"loginKicked";
451451
break;
452452
}
453453
case kJMSGEventNotificationMessageRetract: {
454-
dict[@"evenType"] = @"messageRetract";
454+
dict[@"eventType"] = @"messageRetract";
455455
break;
456456
}
457457
case kJMSGEventNotificationReceiveFriendInvitation: {
458-
dict[@"evenType"] = @"receiveFriendInvitation";
458+
dict[@"eventType"] = @"receiveFriendInvitation";
459459
break;
460460
}
461461
case kJMSGEventNotificationReceiveServerFriendUpdate: {
462-
dict[@"evenType"] = @"receiveServerFriendUpdate";
462+
dict[@"eventType"] = @"receiveServerFriendUpdate";
463463
break;
464464
}
465465
case kJMSGEventNotificationRemoveGroupMembers: {
466-
dict[@"evenType"] = @"group_member_removed";
466+
dict[@"eventType"] = @"group_member_removed";
467467
break;
468468
}
469469
case kJMSGEventNotificationServerAlterPassword: {
470-
dict[@"evenType"] = @"serverAlterPassword";
470+
dict[@"eventType"] = @"serverAlterPassword";
471471
break;
472472
}
473473
case kJMSGEventNotificationUpdateGroupInfo: {
474-
dict[@"evenType"] = @"updateGroupInfo";
474+
dict[@"eventType"] = @"updateGroupInfo";
475475
break;
476476
}
477477
case kJMSGEventNotificationUserLoginStatusUnexpected: {
478-
dict[@"evenType"] = @"userLoginStatusUnexpected";
478+
dict[@"eventType"] = @"userLoginStatusUnexpected";
479479
break;
480480
}
481481
default:

src/ios/Plugins/JMessagePlugin.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@
7171
- (void)setConversationExtras:(CDVInvokedUrlCommand *)command;
7272

7373
// 聊天室 API
74-
- (void)getChatroomInfoListOfApp:(CDVInvokedUrlCommand *)command;
75-
- (void)getChatroomInfoListOfUser:(CDVInvokedUrlCommand *)command;
76-
- (void)getChatroomInfoListById:(CDVInvokedUrlCommand *)command;
77-
- (void)enterChatroom:(CDVInvokedUrlCommand *)command;
78-
- (void)exitChatroom:(CDVInvokedUrlCommand *)command;
79-
- (void)getChatroomConversation:(CDVInvokedUrlCommand *)command;
80-
- (void)getChatroomConversationList:(CDVInvokedUrlCommand *)command;
81-
- (void)getChatroomOwner:(CDVInvokedUrlCommand *)command;
74+
- (void)getChatRoomInfoListOfApp:(CDVInvokedUrlCommand *)command;
75+
- (void)getChatRoomInfoListOfUser:(CDVInvokedUrlCommand *)command;
76+
- (void)getChatRoomInfoListById:(CDVInvokedUrlCommand *)command;
77+
- (void)enterChatRoom:(CDVInvokedUrlCommand *)command;
78+
- (void)exitChatRoom:(CDVInvokedUrlCommand *)command;
79+
- (void)getChatRoomConversation:(CDVInvokedUrlCommand *)command;
80+
- (void)getChatRoomConversationList:(CDVInvokedUrlCommand *)command;
81+
- (void)getChatRoomOwner:(CDVInvokedUrlCommand *)command;
8282

8383
@end

src/ios/Plugins/JMessagePlugin.m

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ -(void)initNotifications {
112112
name:kJJMessageReceiveMessage
113113
object:nil];
114114
[defaultCenter addObserver:self
115-
selector:@selector(didReceiveJMessageChatroomMessage:)
115+
selector:@selector(didReceiveJMessageChatRoomMessage:)
116116
name:kJJMessageReceiveChatroomMessage
117117
object:nil];
118118

@@ -451,8 +451,8 @@ - (void)didReceiveJMessageMessage:(NSNotification *)notification {
451451
[self.commandDelegate sendPluginResult:result callbackId:self.callBack.callbackId];
452452
}
453453

454-
- (void)didReceiveJMessageChatroomMessage:(NSNotification *)notification {
455-
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"receiveChatroomMessage", @"value": notification.object}];
454+
- (void)didReceiveJMessageChatRoomMessage:(NSNotification *)notification {
455+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"eventName": @"receiveChatRoomMessage", @"value": notification.object}];
456456
[result setKeepCallback:@(true)];
457457

458458
[self.commandDelegate sendPluginResult:result callbackId:self.callBack.callbackId];
@@ -2156,22 +2156,23 @@ - (void)deleteMessageById:(CDVInvokedUrlCommand *)command {
21562156
}];
21572157
}
21582158

2159-
- (void)getChatroomInfoListOfApp:(CDVInvokedUrlCommand *)command {
2159+
- (void)getChatRoomInfoListOfApp:(CDVInvokedUrlCommand *)command {
21602160
NSDictionary * param = [command argumentAtIndex:0];
21612161
NSNumber *start = nil;
21622162
NSNumber *count = nil;
2163-
if (!param[@"start"]) {
2163+
if (param[@"start"]) {
21642164
[self returnParamError:command];
2165-
start = param[@"start"];
21662165
return;
21672166
}
21682167

2169-
if (!param[@"count"]) {
2168+
if (param[@"count"]) {
21702169
[self returnParamError:command];
2171-
count = param[@"count"];
21722170
return;
21732171
}
21742172

2173+
start = param[@"start"];
2174+
count = param[@"count"];
2175+
21752176
NSString *appKey = nil;
21762177
if (param[@"appKey"]) {
21772178
appKey = param[@"appKey"];
@@ -2194,7 +2195,7 @@ - (void)getChatroomInfoListOfApp:(CDVInvokedUrlCommand *)command {
21942195
}];
21952196
}
21962197

2197-
- (void)getChatroomInfoListOfUser:(CDVInvokedUrlCommand *)command {
2198+
- (void)getChatRoomInfoListOfUser:(CDVInvokedUrlCommand *)command {
21982199
[JMSGChatRoom getMyChatRoomListCompletionHandler:^(id resultObject, NSError *error) {
21992200
if (error) {
22002201
[self handleResultWithDictionary: nil command: command error: error];
@@ -2211,7 +2212,7 @@ - (void)getChatroomInfoListOfUser:(CDVInvokedUrlCommand *)command {
22112212
}];
22122213
}
22132214

2214-
- (void)getChatroomInfoListById:(CDVInvokedUrlCommand *)command {
2215+
- (void)getChatRoomInfoListById:(CDVInvokedUrlCommand *)command {
22152216
NSDictionary * param = [command argumentAtIndex:0];
22162217

22172218
if (!param[@"roomIds"]) {
@@ -2235,7 +2236,7 @@ - (void)getChatroomInfoListById:(CDVInvokedUrlCommand *)command {
22352236
}];
22362237
}
22372238

2238-
- (void)enterChatroom:(CDVInvokedUrlCommand *)command {
2239+
- (void)enterChatRoom:(CDVInvokedUrlCommand *)command {
22392240
NSDictionary * param = [command argumentAtIndex:0];
22402241

22412242
if (!param[@"roomId"]) {
@@ -2255,7 +2256,7 @@ - (void)enterChatroom:(CDVInvokedUrlCommand *)command {
22552256
}];
22562257
}
22572258

2258-
- (void)exitChatroom:(CDVInvokedUrlCommand *)command {
2259+
- (void)exitChatRoom:(CDVInvokedUrlCommand *)command {
22592260
NSDictionary * param = [command argumentAtIndex:0];
22602261

22612262
if (!param[@"roomId"]) {
@@ -2272,7 +2273,7 @@ - (void)exitChatroom:(CDVInvokedUrlCommand *)command {
22722273
}];
22732274
}
22742275

2275-
- (void)getChatroomConversation:(CDVInvokedUrlCommand *)command {
2276+
- (void)getChatRoomConversation:(CDVInvokedUrlCommand *)command {
22762277
NSDictionary * param = [command argumentAtIndex:0];
22772278

22782279
if (!param[@"roomId"]) {
@@ -2291,7 +2292,7 @@ - (void)getChatroomConversation:(CDVInvokedUrlCommand *)command {
22912292
[self handleResultWithDictionary:[chatRoomConversation conversationToDictionary] command:command error: error];
22922293
}
22932294

2294-
- (void)getChatroomConversationList:(CDVInvokedUrlCommand *)command {
2295+
- (void)getChatRoomConversationList:(CDVInvokedUrlCommand *)command {
22952296

22962297
[JMSGConversation allChatRoomConversation:^(id resultObject, NSError *error) {
22972298
if (error) {
@@ -2309,7 +2310,7 @@ - (void)getChatroomConversationList:(CDVInvokedUrlCommand *)command {
23092310
}];
23102311
}
23112312

2312-
- (void)getChatroomOwner:(CDVInvokedUrlCommand *)command {
2313+
- (void)getChatRoomOwner:(CDVInvokedUrlCommand *)command {
23132314
NSDictionary * param = [command argumentAtIndex:0];
23142315

23152316
if (!param[@"roomId"]) {

www/JMessagePlugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ var JMessagePlugin = {
823823
ChatRoom: {
824824
/**
825825
* 获取当前应用所属聊天室的信息。
826+
*
826827
* @param {object} params = {
827828
* start: number, // 索引起始位置,从 0 开始。
828829
* count: number // 查询个数。
@@ -888,7 +889,7 @@ var JMessagePlugin = {
888889
exec(success, error, PLUGIN_NAME, 'exitChatRoom', [params])
889890
},
890891
/**
891-
* 获取聊天室会话信息。如果无法返回
892+
* 获取聊天室会话信息。
892893
*
893894
* @param {object} params = { roomId: String }
894895
* @param {function} success = function (conversation) {}

0 commit comments

Comments
 (0)