Commit f329a46379bb9e9f6509fddf82d9900163d6b38b
1 parent
c70f9371
0.5.7 版本 添加企业端逻辑
Showing
9 changed files
with
182 additions
and
53 deletions
CNLiveNewIMAManagerKit.podspec
CNLiveNewIMAManagerKit/Classes/Playform/IMAConversationManager.m
| ... | ... | @@ -697,6 +697,10 @@ |
| 697 | 697 | |
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | + case IMPlatformTypeA: | |
| 701 | + { | |
| 702 | + return _toIndex; | |
| 703 | + } | |
| 700 | 704 | default: |
| 701 | 705 | break; |
| 702 | 706 | } |
| ... | ... | @@ -1382,6 +1386,7 @@ |
| 1382 | 1386 | if ([imaconv.receiver hasPrefix:@"sys_"]) { |
| 1383 | 1387 | switch ([IMAPlatform sharedInstance].platformType) { |
| 1384 | 1388 | case IMPlatformTypeB: |
| 1389 | + case IMPlatformTypeA: | |
| 1385 | 1390 | { |
| 1386 | 1391 | if (![imaconv.receiver isEqualToString:CNWithSystemMessage]) |
| 1387 | 1392 | { | ... | ... |
CNLiveNewIMAManagerKit/Classes/Playform/IMAPlatform.h
CNLiveNewIMAManagerKit/Classes/TIMModel/Conversation/IMAConversation.h
| ... | ... | @@ -99,11 +99,24 @@ typedef void (^RemoveMsgBlock)(NSArray *imamsgList, BOOL succ, CommonVoidBlock r |
| 99 | 99 | - (void)releaseConversation; |
| 100 | 100 | |
| 101 | 101 | /// 切换到本会话前,先加载本地的最后count条聊天的的数据 |
| 102 | +/// @param count 获取的历史消息数 | |
| 103 | +/// @param isShowTime 是否显示时间消息 | |
| 104 | +/// @param block 消息回调 | |
| 102 | 105 | - (void)asyncLoadRecentMessage:(NSInteger)count isShowTime:(BOOL)isShowTime completion:(HandleMsgBlock)block; |
| 103 | 106 | |
| 107 | +/// 企业端获取历史消息方法 | |
| 108 | +- (void)asyncBLiveLoadRecentMessage:(NSInteger)count completion:(HandleMsgBlock)block; | |
| 109 | + | |
| 104 | 110 | /// 用于顶部下拉加载更多历史消息 |
| 111 | +/// @param count 获取的历史消息数 | |
| 112 | +/// @param msg 从那个消息开始获取历史消息记录 | |
| 113 | +/// @param isShowTime 是否显示时间消息 | |
| 114 | +/// @param block 消息回调 | |
| 105 | 115 | - (void)asyncLoadRecentMessage:(NSInteger)count from:(IMAMsg *)msg isShowTime:(BOOL)isShowTime completion:(HandleMsgBlock)block; |
| 106 | 116 | |
| 117 | +/// 企业端获取历史消息方法 | |
| 118 | +- (void)asyncBLiveLoadRecentMessage:(NSInteger)count from:(IMAMsg *)msg completion:(HandleMsgBlock)block; | |
| 119 | + | |
| 107 | 120 | /// 获取未读消息 |
| 108 | 121 | - (void)asynUnreadMessage:(HandleMsgBlock)block; |
| 109 | 122 | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMModel/Conversation/IMAConversation.m
| ... | ... | @@ -137,6 +137,7 @@ |
| 137 | 137 | { |
| 138 | 138 | switch ([IMAPlatform sharedInstance].platformType) { |
| 139 | 139 | case IMPlatformTypeB: |
| 140 | + case IMPlatformTypeA: | |
| 140 | 141 | { |
| 141 | 142 | [IMAPlatform sharedInstance].conversationMgr.unReadMessageCount -= [_conversation getUnReadMessageNum]; |
| 142 | 143 | } |
| ... | ... | @@ -391,57 +392,135 @@ |
| 391 | 392 | |
| 392 | 393 | } |
| 393 | 394 | |
| 394 | -// [_conversation getMessage:(int)count last:msg.msg succ:^(NSArray *array) { | |
| 395 | -// | |
| 396 | -// NSArray *recentIMAMsg = [ws onLoadRecentMessageSucc:array]; | |
| 397 | -// if (block) | |
| 398 | -// { | |
| 399 | -// block(recentIMAMsg, recentIMAMsg.count != 0); | |
| 400 | -// } | |
| 401 | -// } fail:^(int code, NSString *err) { | |
| 402 | -// DebugLog(@"未取到最后一条消息"); | |
| 403 | -// if (block) | |
| 404 | -// { | |
| 405 | -// block(nil, NO); | |
| 406 | -// } | |
| 407 | -// }]; | |
| 408 | 395 | } |
| 409 | -// 过滤未知消息 | |
| 410 | -//- (NSArray *)removeUnknownMsg:(NSArray *)msgs | |
| 411 | -//{ | |
| 412 | -// NSMutableArray *arrayMsg = [NSMutableArray new]; | |
| 413 | -// for (TIMMessage *msg in msgs) { | |
| 414 | -// if ([[msg getElem:0] isKindOfClass:[TIMCustomElem class]]) { | |
| 415 | -// TIMCustomElem *customElem = (TIMCustomElem *)[msg getElem:0]; | |
| 416 | -// NSError *err; | |
| 417 | -// NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:customElem.data | |
| 418 | -// options:NSJSONReadingMutableContainers | |
| 419 | -// error:&err]; | |
| 420 | -// if([[dic objectForKey:@"type"] integerValue] == CustomMsgTypeConfirm | |
| 421 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeCnee | |
| 422 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeOrderStatus | |
| 423 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeFriendshipVerify | |
| 424 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeAddFriend | |
| 425 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeRefreshFriendCircle | |
| 426 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeAddFriendSucc | |
| 427 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeFriendSendSucc | |
| 428 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeAite | |
| 429 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeWithdrawMessage | |
| 430 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeDissolveGroup | |
| 431 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypePayment | |
| 432 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeReceipt | |
| 433 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeGroupPaySuccess | |
| 434 | -// || [[dic objectForKey:@"type"] integerValue] == CustomMsgTypeShareLink) | |
| 435 | -// { | |
| 436 | -// [arrayMsg addObject:msg]; | |
| 437 | -// | |
| 438 | -// } | |
| 439 | -// } | |
| 440 | -// else | |
| 441 | -// [arrayMsg addObject:msg]; | |
| 442 | -// } | |
| 443 | -// return arrayMsg; | |
| 444 | -//} | |
| 396 | +/// 企业端获取历史消息 | |
| 397 | +- (void)asyncBLiveLoadRecentMessage:(NSInteger)count completion:(HandleMsgBlock)block; | |
| 398 | +{ | |
| 399 | + IMAMsg *top = [_msgList.safeArray lastObject]; | |
| 400 | + [self asyncBLiveLoadRecentMessage:count from:top completion:block]; | |
| 401 | +} | |
| 402 | +// 企业端获取历史消息 | |
| 403 | +- (void)asyncBLiveLoadRecentMessage:(NSInteger)count from:(IMAMsg *)msg completion:(HandleMsgBlock)block; | |
| 404 | +{ | |
| 405 | + __weak IMAConversation *ws = self; | |
| 406 | + | |
| 407 | + //zl__如果是群聊获取漫游消息,单聊获取本地消息 | |
| 408 | + if ([_conversation getType] == TIM_GROUP) { | |
| 409 | + | |
| 410 | + [_conversation getMessage:(int)count last:msg.msg succ:^(NSArray *msgs) { | |
| 411 | + | |
| 412 | + | |
| 413 | + NSArray *recentIMAMsg = [ws onBLiveLoadRecentMessageSucc:msgs]; | |
| 414 | + if (block) | |
| 415 | + { | |
| 416 | + block(recentIMAMsg, recentIMAMsg.count != 0); | |
| 417 | + } | |
| 418 | + | |
| 419 | + } fail:^(int code, NSString *msg) { | |
| 420 | + | |
| 421 | + DebugLog(@"未取到最后一条消息"); | |
| 422 | + if (block) | |
| 423 | + { | |
| 424 | + block(nil, NO); | |
| 425 | + } | |
| 426 | + | |
| 427 | + }]; | |
| 428 | + | |
| 429 | + | |
| 430 | + } else { | |
| 431 | + if ([TIMTools connectedToNetwork]) { | |
| 432 | + //联网,拿漫游消息 | |
| 433 | + [_conversation getMessage:(int)count last:msg.msg succ:^(NSArray *msgs) { | |
| 434 | + | |
| 435 | + NSArray *recentIMAMsg = [ws onBLiveLoadRecentMessageSucc:msgs]; | |
| 436 | + if (block) | |
| 437 | + { | |
| 438 | + block(recentIMAMsg, recentIMAMsg.count != 0); | |
| 439 | + } | |
| 440 | + | |
| 441 | + } fail:^(int code, NSString *msg) { | |
| 442 | + | |
| 443 | + DebugLog(@"未取到最后一条消息"); | |
| 444 | + if (block) | |
| 445 | + { | |
| 446 | + block(nil, NO); | |
| 447 | + } | |
| 448 | + | |
| 449 | + }]; | |
| 450 | + } | |
| 451 | + else | |
| 452 | + { | |
| 453 | + //未联网,拿本地历史消息 | |
| 454 | + [_conversation getLocalMessage:(int)count last:msg.msg succ:^(NSArray *msgs) { | |
| 455 | + | |
| 456 | + NSArray *recentIMAMsg = [ws onBLiveLoadRecentMessageSucc:msgs]; | |
| 457 | + if (block) | |
| 458 | + { | |
| 459 | + block(recentIMAMsg, recentIMAMsg.count != 0); | |
| 460 | + } | |
| 461 | + | |
| 462 | + } fail:^(int code, NSString *msg) { | |
| 463 | + | |
| 464 | + DebugLog(@"未取到最后一条消息"); | |
| 465 | + if (block) | |
| 466 | + { | |
| 467 | + block(nil, NO); | |
| 468 | + } | |
| 469 | + | |
| 470 | + }]; | |
| 471 | + } | |
| 472 | + | |
| 473 | + | |
| 474 | + } | |
| 475 | +} | |
| 476 | +/// 根据 TIMMessage 生成 IMAMsg 消息 | |
| 477 | +- (NSArray *)onBLiveLoadRecentMessageSucc:(NSArray *)timmsgList | |
| 478 | +{ | |
| 479 | + if (timmsgList.count > 0) | |
| 480 | + { | |
| 481 | + NSMutableArray *array = [NSMutableArray array]; | |
| 482 | + | |
| 483 | + for (TIMMessage *msg in timmsgList) { | |
| 484 | + if (msg.status == TIM_MSG_STATUS_HAS_DELETED) | |
| 485 | + { | |
| 486 | + continue; | |
| 487 | + } | |
| 488 | + if ([msg getElem:0] == nil) { | |
| 489 | + continue; | |
| 490 | + } | |
| 491 | + | |
| 492 | + if ([[msg getElem:0] isKindOfClass:[TIMCustomElem class]]) | |
| 493 | + { | |
| 494 | + //过滤不需要展示的自定义消息 | |
| 495 | + TIMCustomElem *customElem = (TIMCustomElem *)[msg getElem:0]; | |
| 496 | + NSError *err; | |
| 497 | + NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:customElem.data | |
| 498 | + options:NSJSONReadingMutableContainers | |
| 499 | + error:&err]; | |
| 500 | + if ([[dic objectForKey:@"type"] integerValue] == CustomMsgTypeSenderInvitationReceiver) { | |
| 501 | + continue; | |
| 502 | + } | |
| 503 | + } | |
| 504 | + | |
| 505 | + NSDate *date = [msg timestamp]; | |
| 506 | + | |
| 507 | + | |
| 508 | + IMAMsg *timeMsg = [IMAMsg msgWithDate:date]; | |
| 509 | + [array addObject:timeMsg]; | |
| 510 | + //niu | |
| 511 | + IMAMsg *imamsg = [IMAMsg msgWith:msg]; | |
| 512 | + if (imamsg) | |
| 513 | + { | |
| 514 | + [array addObject:imamsg]; | |
| 515 | + } | |
| 516 | + } | |
| 517 | + | |
| 518 | + [_msgList addObjectsFromArray:array]; | |
| 519 | + return array; | |
| 520 | + } | |
| 521 | + | |
| 522 | + return nil; | |
| 523 | +} | |
| 445 | 524 | - (TIMConversationType)type |
| 446 | 525 | { |
| 447 | 526 | if (_convType) { | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMModel/MSG/IMAMsg.h
| ... | ... | @@ -127,6 +127,12 @@ typedef NS_ENUM(NSInteger, IMAMSGType) { |
| 127 | 127 | EIMAMSG_OrederReminder , //推单 |
| 128 | 128 | EIMAMSG_NewOrderRemind , //新订单提醒 |
| 129 | 129 | |
| 130 | +#pragma mark 网家家企业端消息相关 | |
| 131 | + EIMAMSG_Illegal , //违规 | |
| 132 | + EIMAMSG_PersonageCerSuccess , //个人认证成功 | |
| 133 | + EIMAMSG_PersonageCerFail , //个人认证失败 | |
| 134 | + EIMAMSG_OrganizationCerSuccess , //机构认证成功 | |
| 135 | + EIMAMSG_OrganizationCerFail , //机构认证失败 | |
| 130 | 136 | |
| 131 | 137 | }; |
| 132 | 138 | |
| ... | ... | @@ -257,7 +263,12 @@ typedef NS_ENUM(NSUInteger, CustomMsgType) { |
| 257 | 263 | CustomMsgTypeApplyForRefund = 3111, //申请退款消息 |
| 258 | 264 | CustomMsgTypeReminder = 3222, //催单 |
| 259 | 265 | CustomMsgTypeNewOrderRemind = 3333, //新订单提醒 |
| 260 | - | |
| 266 | +#pragma mark 网家家企业端消息相关 | |
| 267 | + CustomMsgTypeIllegal = 12001, //违规 | |
| 268 | + CustomMsgTypePersonageCerSuccess = 12002, //个人认证成功 | |
| 269 | + CustomMsgTypePersonageCerFail = 12003, //个人认证失败 | |
| 270 | + CustomMsgTypeOrganizationCerSuccess = 12004, //机构认证成功 | |
| 271 | + CustomMsgTypeOrganizationCerFail = 12005, //机构认证失败 | |
| 261 | 272 | }; |
| 262 | 273 | |
| 263 | 274 | /** | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMModel/MSG/IMAMsg.m
| ... | ... | @@ -651,6 +651,26 @@ |
| 651 | 651 | { |
| 652 | 652 | type = EIMAMSG_ShareCoupon; |
| 653 | 653 | } |
| 654 | + else if ([dic[@"type"] integerValue] == CustomMsgTypeIllegal) | |
| 655 | + { | |
| 656 | + type = EIMAMSG_Illegal; | |
| 657 | + } | |
| 658 | + else if ([dic[@"type"] integerValue] == CustomMsgTypePersonageCerSuccess) | |
| 659 | + { | |
| 660 | + type = EIMAMSG_PersonageCerSuccess; | |
| 661 | + } | |
| 662 | + else if ([dic[@"type"] integerValue] == CustomMsgTypePersonageCerFail) | |
| 663 | + { | |
| 664 | + type = EIMAMSG_PersonageCerFail; | |
| 665 | + } | |
| 666 | + else if ([dic[@"type"] integerValue] == CustomMsgTypeOrganizationCerSuccess) | |
| 667 | + { | |
| 668 | + type = EIMAMSG_OrganizationCerSuccess; | |
| 669 | + } | |
| 670 | + else if ([dic[@"type"] integerValue] == CustomMsgTypeOrganizationCerFail) | |
| 671 | + { | |
| 672 | + type = EIMAMSG_OrganizationCerFail; | |
| 673 | + } | |
| 654 | 674 | else { |
| 655 | 675 | type = EIMAMSG_Unknown; |
| 656 | 676 | } | ... | ... |
Example/CNLiveNewIMAManagerKit.xcodeproj/project.pbxproj
| ... | ... | @@ -66,7 +66,7 @@ |
| 66 | 66 | 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; |
| 67 | 67 | B1B0CD978751C2CCDC120169 /* CNLiveNewIMAManagerKit.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CNLiveNewIMAManagerKit.podspec; path = ../CNLiveNewIMAManagerKit.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; |
| 68 | 68 | D8838AF786E7DE0BB63DB209 /* Pods-CNLiveNewIMAManagerKit_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CNLiveNewIMAManagerKit_Tests.debug.xcconfig"; path = "Target Support Files/Pods-CNLiveNewIMAManagerKit_Tests/Pods-CNLiveNewIMAManagerKit_Tests.debug.xcconfig"; sourceTree = "<group>"; }; |
| 69 | - EC92F43F4F228E3A82D9B9C3 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; }; | |
| 69 | + EC92F43F4F228E3A82D9B9C3 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; }; | |
| 70 | 70 | /* End PBXFileReference section */ |
| 71 | 71 | |
| 72 | 72 | /* Begin PBXFrameworksBuildPhase section */ | ... | ... |
LICENSE renamed to Example/LICENSE