Commit dfa6ea76cfcba392ede1815adc129a9e8925281c
1 parent
18c84b08
0.3.1 版本
1.YYkit 依赖修改 2.发送新消息通知 3.收到新消息判断是否携带时间消息
Showing
11 changed files
with
48 additions
and
25 deletions
CNLiveNewIMAManagerKit.podspec
CNLiveNewIMAManagerKit/Classes/Playform/IMAConversationManager.m
| ... | ... | @@ -707,6 +707,8 @@ |
| 707 | 707 | { |
| 708 | 708 | NSLog(@"onNewMessage:%@",msgs); |
| 709 | 709 | |
| 710 | + [[NSNotificationCenter defaultCenter] postNotificationName:@"kIMAMSG_OnNewMessageNotification" object:msgs]; | |
| 711 | + | |
| 710 | 712 | for (TIMMessage *msg in msgs) |
| 711 | 713 | { |
| 712 | 714 | IMAMsg *imamsg = [IMAMsg msgWith:msg]; | ... | ... |
CNLiveNewIMAManagerKit/Classes/PublicHeader/IMANotification.h
| ... | ... | @@ -164,5 +164,7 @@ static NSString *const kIMAMSG_PhotoFixSuccessNotification = @"kIMAMSG_PhotoFixS |
| 164 | 164 | |
| 165 | 165 | #pragma mark 收到商家版申请退款消息通知 |
| 166 | 166 | static NSString *const kIMAMSG_ApplyForRefundNotification = @"kIMAMSG_ApplyForRefundNotification"; |
| 167 | +#pragma mark 收到IM新消息 | |
| 168 | +static NSString *const kIMAMSG_OnNewMessageNotification = @"kIMAMSG_OnNewMessageNotification"; | |
| 167 | 169 | |
| 168 | 170 | #endif /* IMANotification_h */ | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMCategory/IMAMsg+UITableViewCell.m
| ... | ... | @@ -225,7 +225,7 @@ static NSString *const kIMAMsgShowChatAttributedText = @"kIMAMsgShowChatAttribut |
| 225 | 225 | - (NSMutableAttributedString *)attributedStringWithText:(NSString *)text font:(CGFloat)font { |
| 226 | 226 | |
| 227 | 227 | NSMutableAttributedString *ats = [[NSMutableAttributedString alloc] initWithString:text]; |
| 228 | - ats.font = UIFontCNMake(font); | |
| 228 | + ats.yy_font = UIFontCNMake(font); | |
| 229 | 229 | NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; |
| 230 | 230 | paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping; |
| 231 | 231 | [ats addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, ats.length)]; |
| ... | ... | @@ -310,7 +310,7 @@ static NSString *const kIMAMsgShowChatAttributedText = @"kIMAMsgShowChatAttribut |
| 310 | 310 | - (NSAttributedString *)loadShowChatAttributedText |
| 311 | 311 | { |
| 312 | 312 | NSMutableAttributedString *ats = [[NSMutableAttributedString alloc] init]; |
| 313 | - ats.font = UIFontCNMake(15);//[UIFont systemFontOfSize:15]; | |
| 313 | + ats.yy_font = UIFontCNMake(15);//[UIFont systemFontOfSize:15]; | |
| 314 | 314 | NSInteger loc = 0; |
| 315 | 315 | for (int i = 0; i < self.msg.elemCount; i++) |
| 316 | 316 | { | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMCategory/TIMElem+ShowAPIs.m
| ... | ... | @@ -943,7 +943,7 @@ |
| 943 | 943 | - (NSMutableAttributedString *)attributedStringWithText:(NSString *)text font:(CGFloat)font { |
| 944 | 944 | |
| 945 | 945 | NSMutableAttributedString *ats = [[NSMutableAttributedString alloc] initWithString:text]; |
| 946 | - ats.font = UIFontCNMake(font); | |
| 946 | + ats.yy_font = UIFontCNMake(font); | |
| 947 | 947 | NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; |
| 948 | 948 | paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping; |
| 949 | 949 | [ats addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, ats.length)]; | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMFMDBManager/CNGroupListAvaterUtil.h
CNLiveNewIMAManagerKit/Classes/TIMModel/Conversation/IMAConversation.h
| ... | ... | @@ -74,7 +74,10 @@ typedef void (^RemoveMsgBlock)(NSArray *imamsgList, BOOL succ, CommonVoidBlock r |
| 74 | 74 | @property (nonatomic, copy) NSString *strangerIcon; |
| 75 | 75 | |
| 76 | 76 | ///群头像 |
| 77 | -@property (nonatomic, strong)UIImage *groupAvator; | |
| 77 | +@property (nonatomic, strong) UIImage *groupAvator; | |
| 78 | + | |
| 79 | +/// 是否需要创建时间消息,默认为YES | |
| 80 | +@property (nonatomic, assign) BOOL isCreateTimeMsg; | |
| 78 | 81 | |
| 79 | 82 | /// 根据腾讯IM的TIMConversation对象进行初始化 |
| 80 | 83 | /// @param conv IM 原始会话 | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMModel/Conversation/IMAConversation.m
| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | { |
| 25 | 25 | _conversation = conv; |
| 26 | 26 | _msgList = [[CLSafeMutableArray alloc] init]; |
| 27 | - | |
| 27 | + _isCreateTimeMsg = YES; | |
| 28 | 28 | } |
| 29 | 29 | return self; |
| 30 | 30 | } |
| ... | ... | @@ -949,11 +949,9 @@ |
| 949 | 949 | { |
| 950 | 950 | NSMutableArray *array = [NSMutableArray array]; |
| 951 | 951 | |
| 952 | - IMAMsg *timeTip = [self timeTipOnNewMessage:msg]; | |
| 953 | - | |
| 954 | - if (timeTip) | |
| 955 | - { | |
| 956 | - [array addObject:timeTip]; | |
| 952 | + if (self.isCreateTimeMsg) { | |
| 953 | + IMAMsg *timeTip = [self timeTipOnNewMessage:msg]; | |
| 954 | + if (timeTip)[array addObject:timeTip]; | |
| 957 | 955 | } |
| 958 | 956 | |
| 959 | 957 | [array addObject:msg]; | ... | ... |
CNLiveNewIMAManagerKit/Classes/TIMModel/MSG/IMAMsg.m
| ... | ... | @@ -1135,9 +1135,9 @@ |
| 1135 | 1135 | if (![self isWithdrawMsg]) { |
| 1136 | 1136 | IMAUser *sender = [self getSender]; |
| 1137 | 1137 | if (sender) { |
| 1138 | - [nameAtt appendString:[NSString stringWithFormat:@"%@: ",[sender showTitle]]]; | |
| 1138 | + [nameAtt yy_appendString:[NSString stringWithFormat:@"%@: ",[sender showTitle]]]; | |
| 1139 | 1139 | } else { |
| 1140 | - [nameAtt appendString:[NSString stringWithFormat:@"%@: ",[_msg sender]]]; | |
| 1140 | + [nameAtt yy_appendString:[NSString stringWithFormat:@"%@: ",[_msg sender]]]; | |
| 1141 | 1141 | } |
| 1142 | 1142 | if ([nameAtt.string hasPrefix:@"admin"]) { |
| 1143 | 1143 | //处理 是APP管理员发送的消息 |
| ... | ... | @@ -1174,7 +1174,7 @@ |
| 1174 | 1174 | { |
| 1175 | 1175 | if ([conv getUnReadMessageNum] > 1) |
| 1176 | 1176 | { |
| 1177 | - [unReadMsgNumAtt appendString:[NSString stringWithFormat:@"[%d条]",[conv getUnReadMessageNum]]]; | |
| 1177 | + [unReadMsgNumAtt yy_appendString:[NSString stringWithFormat:@"[%d条]",[conv getUnReadMessageNum]]]; | |
| 1178 | 1178 | } |
| 1179 | 1179 | } |
| 1180 | 1180 | } |
| ... | ... | @@ -1189,13 +1189,13 @@ |
| 1189 | 1189 | if (self.type == EIMAMSG_SendGiftSuccess) { |
| 1190 | 1190 | //送礼填写地址成功 送礼者 红字提醒 |
| 1191 | 1191 | NSString *redTipStr = @"Ta填写礼包地址 "; |
| 1192 | - [tipAtt appendString:redTipStr]; | |
| 1192 | + [tipAtt yy_appendString:redTipStr]; | |
| 1193 | 1193 | [tipAtt addAttribute:NSForegroundColorAttributeName value:[UIColor qmui_colorWithHexString:@"#FC1541"] range:NSMakeRange(0, redTipStr.length)]; |
| 1194 | 1194 | } |
| 1195 | 1195 | else if (self.type == EIMAMSG_ReceviedGiftSuccess) { |
| 1196 | 1196 | //送礼填写地址成功 收礼者 红字提醒 |
| 1197 | 1197 | NSString *redTipStr = @"已填写礼包地址 "; |
| 1198 | - [tipAtt appendString:redTipStr]; | |
| 1198 | + [tipAtt yy_appendString:redTipStr]; | |
| 1199 | 1199 | [tipAtt addAttribute:NSForegroundColorAttributeName value:[UIColor qmui_colorWithHexString:@"#FC1541"] range:NSMakeRange(0, redTipStr.length)]; |
| 1200 | 1200 | |
| 1201 | 1201 | } |
| ... | ... | @@ -1228,14 +1228,14 @@ |
| 1228 | 1228 | redTipStr = @"已收礼 "; |
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | - [tipAtt appendString:redTipStr]; | |
| 1231 | + [tipAtt yy_appendString:redTipStr]; | |
| 1232 | 1232 | [tipAtt addAttribute:NSForegroundColorAttributeName value:[UIColor qmui_colorWithHexString:@"#FC1541"] range:NSMakeRange(0, redTipStr.length)]; |
| 1233 | 1233 | } |
| 1234 | 1234 | else if (self.type == EIMAMSG_HaveCoupon && ![_msg isReaded]) |
| 1235 | 1235 | { |
| 1236 | 1236 | //有未领取的优惠券 |
| 1237 | 1237 | NSString *redTipStr = @"[有红包]"; |
| 1238 | - [tipAtt appendString:redTipStr]; | |
| 1238 | + [tipAtt yy_appendString:redTipStr]; | |
| 1239 | 1239 | [tipAtt addAttribute:NSForegroundColorAttributeName value:[UIColor qmui_colorWithHexString:@"#FC1541"] range:NSMakeRange(0, redTipStr.length)]; |
| 1240 | 1240 | |
| 1241 | 1241 | } |
| ... | ... | @@ -1247,7 +1247,7 @@ |
| 1247 | 1247 | NSArray *unreceivedTransferBalanceArray = [[CNTransferBalanceUnreceivedCache cache] objectForKey:[NSString stringWithFormat:@"key_%@_%@",CNUserShareModel.uid,[conv getReceiver]]]; |
| 1248 | 1248 | if (unreceivedTransferBalanceArray && unreceivedTransferBalanceArray.count > 0) { |
| 1249 | 1249 | NSString *redTipStr = @"[转余额]"; |
| 1250 | - [tipAtt appendString:redTipStr]; | |
| 1250 | + [tipAtt yy_appendString:redTipStr]; | |
| 1251 | 1251 | [tipAtt addAttribute:NSForegroundColorAttributeName value:[UIColor qmui_colorWithHexString:@"#FC1541"] range:NSMakeRange(0, redTipStr.length)]; |
| 1252 | 1252 | } |
| 1253 | 1253 | } | ... | ... |
CNLiveNewIMAManagerKit/PCH/CNLiveNewIMAManagerPCH.h
| ... | ... | @@ -21,7 +21,9 @@ |
| 21 | 21 | #import <CNLiveBusinessTools/CNLiveBusinessTools.h> |
| 22 | 22 | #import <SDWebImage/SDWebImage.h> |
| 23 | 23 | #import <CNLivePhotoBrowser/CNLivePhotoBrowserCache.h> |
| 24 | -#import <YYKit/YYKit.h> | |
| 24 | +#import <YYCache/YYCache.h> | |
| 25 | +#import <YYCategories/YYCategories.h> | |
| 26 | +#import <YYText/YYText.h> | |
| 25 | 27 | #import <CNLiveBeeHive/CNLiveBeeHive.h> |
| 26 | 28 | #import <QMUIKit/QMUIKit.h> |
| 27 | 29 | #import <CNLiveRequestBastKit/CNLiveNetworking.h> | ... | ... |
Example/CNLiveNewIMAManagerKit.xcodeproj/project.pbxproj
| ... | ... | @@ -383,8 +383,16 @@ |
| 383 | 383 | "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", |
| 384 | 384 | "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", |
| 385 | 385 | "${PODS_ROOT}/TXIMSDK_iOS/ImSDK.framework", |
| 386 | - "${BUILT_PRODUCTS_DIR}/YBImageBrowser_DSCnliveShop/YBImageBrowser_DSCnliveShop.framework", | |
| 387 | - "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", | |
| 386 | + "${BUILT_PRODUCTS_DIR}/YBImageBrowser/YBImageBrowser.framework", | |
| 387 | + "${BUILT_PRODUCTS_DIR}/YYAsyncLayer/YYAsyncLayer.framework", | |
| 388 | + "${BUILT_PRODUCTS_DIR}/YYCache/YYCache.framework", | |
| 389 | + "${BUILT_PRODUCTS_DIR}/YYCategories/YYCategories.framework", | |
| 390 | + "${BUILT_PRODUCTS_DIR}/YYDispatchQueuePool/YYDispatchQueuePool.framework", | |
| 391 | + "${BUILT_PRODUCTS_DIR}/YYImage/YYImage.framework", | |
| 392 | + "${BUILT_PRODUCTS_DIR}/YYKeyboardManager/YYKeyboardManager.framework", | |
| 393 | + "${BUILT_PRODUCTS_DIR}/YYModel/YYModel.framework", | |
| 394 | + "${BUILT_PRODUCTS_DIR}/YYText/YYText.framework", | |
| 395 | + "${BUILT_PRODUCTS_DIR}/YYWebImage/YYWebImage.framework", | |
| 388 | 396 | ); |
| 389 | 397 | name = "[CP] Embed Pods Frameworks"; |
| 390 | 398 | outputPaths = ( |
| ... | ... | @@ -403,8 +411,16 @@ |
| 403 | 411 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", |
| 404 | 412 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", |
| 405 | 413 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ImSDK.framework", |
| 406 | - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YBImageBrowser_DSCnliveShop.framework", | |
| 407 | - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", | |
| 414 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YBImageBrowser.framework", | |
| 415 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYAsyncLayer.framework", | |
| 416 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYCache.framework", | |
| 417 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYCategories.framework", | |
| 418 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYDispatchQueuePool.framework", | |
| 419 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYImage.framework", | |
| 420 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKeyboardManager.framework", | |
| 421 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYModel.framework", | |
| 422 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYText.framework", | |
| 423 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYWebImage.framework", | |
| 408 | 424 | ); |
| 409 | 425 | runOnlyForDeploymentPostprocessing = 0; |
| 410 | 426 | shellPath = /bin/sh; | ... | ... |