Skip to content

Commit

Permalink
v2.1.4 update AVOSCloud and AVOSCloudIM SDK to 11.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYilong committed Jun 14, 2018
1 parent af780fe commit c3d3698
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 126 deletions.
6 changes: 3 additions & 3 deletions CYLChatKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CYLChatKit"
s.version = "2.1.3"
s.version = "2.1.4"
s.summary = "An IM App Framework, support sending text, pictures, audio, video, location messaging, managing address book, more interesting features."
s.homepage = "https://github.com/ChenYilong/CYLChatKit"
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand All @@ -13,8 +13,8 @@ Pod::Spec.new do |s|
s.resources = 'ChatKit/Class/Resources/*', 'ChatKit/**/*.xib'

s.requires_arc = true
s.dependency "AVOSCloud" , "~> 8.2.0"
s.dependency "AVOSCloudIM", "~> 8.2.0"
s.dependency "AVOSCloud" , "~> 11.0.0"
s.dependency "AVOSCloudIM", "~> 11.0.0"
s.dependency "MJRefresh" , "~> 3.1.9"
s.dependency "Masonry" , "~> 1.0.1"
s.dependency "SDWebImage" , "~> 3.8.0"
Expand Down
1 change: 1 addition & 0 deletions ChatKit-OC/Example/Class/Module/Main/LCCKUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#else
#import "LCChatKit.h"
#endif

@interface LCCKUtil : NSObject

+ (BOOL)isIPhoneX;
Expand Down
32 changes: 16 additions & 16 deletions ChatKit-OC/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
PODS:
- AVOSCloud (8.2.3)
- AVOSCloudIM (8.2.3):
- AVOSCloud (= 8.2.3)
- AVOSCloudIM/_ARC (= 8.2.3)
- AVOSCloudIM/_NOARC (= 8.2.3)
- AVOSCloudIM/_ARC (8.2.3):
- AVOSCloud (= 8.2.3)
- AVOSCloudIM/_NOARC (= 8.2.3)
- AVOSCloudIM/_NOARC (8.2.3):
- AVOSCloud (= 8.2.3)
- CYLChatKit (2.1.2):
- AVOSCloud (~> 8.2.0)
- AVOSCloudIM (~> 8.2.0)
- AVOSCloud (11.0.0)
- AVOSCloudIM (11.0.0):
- AVOSCloud (= 11.0.0)
- AVOSCloudIM/_ARC (= 11.0.0)
- AVOSCloudIM/_NOARC (= 11.0.0)
- AVOSCloudIM/_ARC (11.0.0):
- AVOSCloud (= 11.0.0)
- AVOSCloudIM/_NOARC (= 11.0.0)
- AVOSCloudIM/_NOARC (11.0.0):
- AVOSCloud (= 11.0.0)
- CYLChatKit (2.1.3):
- AVOSCloud (~> 11.0.0)
- AVOSCloudIM (~> 11.0.0)
- CYLDeallocBlockExecutor (~> 1.2.0)
- DACircularProgress (~> 2.3.1)
- FDStackView (~> 1.0)
Expand Down Expand Up @@ -89,9 +89,9 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
AVOSCloud: 242fe402282677149487e70fb993843d03cc7b86
AVOSCloudIM: 1286d413ec0ed9d237ea9bf0938d13ecf4bb6cc0
CYLChatKit: c6882d499d28d967e189d4ab1f4dfa996dd350c3
AVOSCloud: 8ffa848f5f7391fc7594d3671a29cd6f8a14cc2a
AVOSCloudIM: 465af27feb394e50e1b09a7fd2da4645be340cdb
CYLChatKit: a4563933aae675b5438927f2290a7993dbb215ea
CYLDeallocBlockExecutor: 1f8e904d846b8dadff88b2e5c2817df974cb63a9
CYLTabBarController: b6e0574c2f5592edfbfc71a1b2be8dc0374cf11a
DACircularProgress: 4dd437c0fc3da5161cb289e07ac449493d41db71
Expand Down
17 changes: 17 additions & 0 deletions ChatKit/Class/Model/LCCKCommonUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// LCCKCommonUtils.h
// AVOSCloud
//
// Created by chenyilong on 14/6/2018.
//

#import <Foundation/Foundation.h>
@class AVFile;

@interface LCCKCommonUtils : NSObject

+ (NSString *)getPathFromFile:(AVFile *)file;

+ (BOOL)isCacheDataAvailableForFile:(AVFile *)file;

@end
29 changes: 29 additions & 0 deletions ChatKit/Class/Model/LCCKCommonUtils.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// LCCKCommonUtils.m
// AVOSCloud
//
// Created by chenyilong on 14/6/2018.
//

#import "LCCKCommonUtils.h"
#import <AVOSCloud/AVOSCloud.h>

@implementation LCCKCommonUtils

+ (NSString *)getPathFromFile:(AVFile *)file {
NSString *localPath = [file persistentCachePath];
return localPath;
}

+ (BOOL)isCacheDataAvailableForFile:(AVFile *)file {
NSString *objectId = file.objectId;
NSString *localPath = [self getPathFromFile:file];
localPath = (localPath.length > 0) ? localPath :@"";
BOOL fileExistsAtPath = ([[NSFileManager defaultManager] fileExistsAtPath:localPath]);
if (objectId.length > 0 && fileExistsAtPath) {
return YES;
}
return NO;
}

@end
18 changes: 6 additions & 12 deletions ChatKit/Class/Model/LCCKMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "UIImage+LCCKExtension.h"
//#define LCCKIsDebugging 1
#import "NSObject+LCCKExtension.h"
#import "LCCKCommonUtils.h"

@interface LCCKMessage()

Expand Down Expand Up @@ -304,9 +305,10 @@ + (id)messageWithAVIMTypedMessage:(AVIMTypedMessage *)message {
NSString *duration = [NSString stringWithFormat:@"%.0f", audioMsg.duration];
NSString *voicePath;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pathForFile = audioMsg.file.localPath;
NSString *localPath = [LCCKCommonUtils getPathFromFile:audioMsg.file];
NSString *pathForFile = localPath;
if ([fileManager fileExistsAtPath:pathForFile]){
voicePath = audioMsg.file.localPath;
voicePath = localPath;
} else {
voicePath = audioMsg.file.url;
}
Expand All @@ -325,23 +327,15 @@ + (id)messageWithAVIMTypedMessage:(AVIMTypedMessage *)message {
}
case kAVIMMessageMediaTypeImage: {
AVIMImageMessage *imageMsg = (AVIMImageMessage *)message;
NSString *pathForFile = imageMsg.file.localPath;
NSString *pathForFile = [LCCKCommonUtils getPathFromFile:imageMsg.file];;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *imagePath;
if ([fileManager fileExistsAtPath:pathForFile]){
imagePath = imageMsg.file.localPath;
imagePath = pathForFile;
}
lcckMessage = [[LCCKMessage alloc] initWithPhoto:nil photoWidth:imageMsg.width photoHeight: imageMsg.height thumbnailPhoto:nil photoPath:imagePath thumbnailURL:nil originPhotoURL:[NSURL URLWithString:imageMsg.file.url] senderId:senderId sender:sender timestamp:time serverMessageId:serverMessageId];
break;
}

//#import "AVIMEmotionMessage.h"
// case kAVIMMessageMediaTypeEmotion: {
// AVIMEmotionMessage *emotionMsg = (AVIMEmotionMessage *)message;
// NSString *path = [[NSBundle mainBundle] pathForResource:emotionMsg.emotionPath ofType:@"gif"];
// lcckMessage = [[LCCKMessage alloc] initWithEmotionPath:path sender:sender timestamp:time];
// break;
// }
case kAVIMMessageMediaTypeVideo: {
//TODO:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa

- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
LCCKContactCell *cell = [tableView dequeueReusableCellWithIdentifier:LCCKContactListViewControllerIdentifier forIndexPath:indexPath];
LCCKContactCell *cell = [tableView dequeueReusableCellWithIdentifier:LCCKContactListViewControllerIdentifier];
id contact = [self contactAtIndexPath:indexPath tableView:tableView];
NSURL *avatarURL = nil;
NSString *name = nil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ - (LCCKConversationViewModel *)chatViewModel {
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userWillSendMsgWithoutPower) name:LCCKNotificationRecordNoPower object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recieveNewMsgForLengthOut) name:LCCKNotificationTextLengthOut object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recieveNewMsgForLengthOut) name:LCCKNotificationTextLengthOut object:nil];

__unsafe_unretained __typeof(self) weakSelf = self;
[self cyl_executeAtDealloc:^{
Expand Down Expand Up @@ -273,9 +273,6 @@ - (void)viewDidDisappear:(BOOL)animated {
});
}
//TODO: 群聊人数改变,改群名称
// if (self.conversation.members.count > 2) {
// self.navigationItem.titleView = nil;
// }
!self.viewDidDisappearBlock ?: self.viewDidDisappearBlock(self, animated);
}

Expand Down Expand Up @@ -338,7 +335,7 @@ - (void)sendImageMessageData:(NSData *)imageData {
}

- (void)sendVoiceMessageWithPath:(NSString *)voicePath time:(NSTimeInterval)recordingSeconds {

LCCKMessage *message = [[LCCKMessage alloc] initWithVoicePath:voicePath
voiceURL:nil
voiceDuration:[NSString stringWithFormat:@"%@", @(recordingSeconds)]
Expand All @@ -351,7 +348,7 @@ - (void)sendVoiceMessageWithPath:(NSString *)voicePath time:(NSTimeInterval)reco
}

- (void)sendLocationMessageWithLocationCoordinate:(CLLocationCoordinate2D)locationCoordinate locatioTitle:(NSString *)locationTitle {

LCCKMessage *message = [[LCCKMessage alloc] initWithLocalPositionPhoto:({
NSString *imageName = @"message_sender_location";
UIImage *image = [UIImage lcck_imageNamed:imageName bundleName:@"MessageBubble" bundleForClass:[self class]];
Expand Down Expand Up @@ -564,8 +561,8 @@ - (void)refreshConversation:(AVIMConversation *)aConversation isJoined:(BOOL)isJ
//peer初始化成功时也会对conversation赋值
_conversation = conversation;
[self saveCurrentConversationInfoIfExists];
// if (_conversation) {
// }
// if (_conversation) {
// }
[self callbackCurrentConversationEvenNotExists:conversation callback:^(BOOL succeeded, NSError *error) {
if (succeeded) {
[self handleLoadHistoryMessagesHandlerIfIsJoined:isJoined];
Expand Down Expand Up @@ -840,21 +837,6 @@ - (void)messageCellTappedMessage:(LCCKChatMessageCell *)messageCell {
}
break;
default: {
// //TODO:自定义消息的点击事件
// NSString *formatString = @"\n\n\
// ------ BEGIN NSException Log ---------------\n \
// class name: %@ \n \
// ------line: %@ \n \
// ----reason: %@ \n \
// ------ END -------------------------------- \n\n";
// NSString *reason = [NSString stringWithFormat:formatString,
// @(__PRETTY_FUNCTION__),
// @(__LINE__),
// @"messageCell.messageType not handled"];
// //手动创建一个异常导致的崩溃事件 http://is.gd/EfVfN0
// @throw [NSException exceptionWithName:NSGenericException
// reason:reason
// userInfo:nil];
}
break;
}
Expand Down Expand Up @@ -1009,31 +991,30 @@ - (void)updateStatusView {
self.clientStatusView.hidden = NO;
}
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark - Notification
#pragma mark - Notification

- (void)userWillSendMsgWithoutPower {
[self showWaring:@"需要开启麦克风权限"];
}
- (void)userWillSendMsgWithoutPower {
[self showWaring:@"需要开启麦克风权限"];
}

- (void)recieveNewMsgForLengthOut {
NSString *message = [NSString stringWithFormat:@"每次输入最多%@字~", @(LCCKNotificationTextLengthOutLength)];
[self showWaring:message];
}

- (void)showWaring:(NSString *)message {
// 没有找到Toast 只能用弹框
LCCKAlertController *alert = [LCCKAlertController alertControllerWithTitle:nil
message:message
preferredStyle:LCCKAlertControllerStyleAlert];
NSString *cancelActionTitle = LCCKLocalizedStrings(@"ok");
LCCKAlertAction *cancelAction = [LCCKAlertAction actionWithTitle:cancelActionTitle style:LCCKAlertActionStyleDefault
handler:^(LCCKAlertAction * action) {}];
[alert addAction:cancelAction];
[alert showWithSender:nil controller:self animated:YES completion:NULL];
}
- (void)showWaring:(NSString *)message {
LCCKAlertController *alert = [LCCKAlertController alertControllerWithTitle:nil
message:message
preferredStyle:LCCKAlertControllerStyleAlert];
NSString *cancelActionTitle = LCCKLocalizedStrings(@"ok");
LCCKAlertAction *cancelAction = [LCCKAlertAction actionWithTitle:cancelActionTitle style:LCCKAlertActionStyleDefault
handler:^(LCCKAlertAction * action) {}];
[alert addAction:cancelAction];
[alert showWithSender:nil controller:self animated:YES completion:NULL];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ - (void)sendMessage:(id)aMessage
!success ?: success(succeeded, nil);
}
// cache file type messages even failed
[LCCKConversationService cacheFileTypeMessages:@[avimTypedMessage] callback:nil];
[LCCKConversationService cacheFileTypeMessagesInBackground:@[avimTypedMessage]];
}];

};
Expand Down Expand Up @@ -689,12 +689,13 @@ - (void)queryAndCacheMessagesWithTimestamp:(int64_t)timestamp
!block ?: block(avimTypedMessages, error);
return;
}
[LCCKConversationService cacheFileTypeMessages:avimTypedMessages callback:^(BOOL succeeded, NSError *error) {
[LCCKConversationService cacheFileTypeMessagesInBackground:avimTypedMessages];
dispatch_async(dispatch_get_main_queue(),^{
if (avimTypedMessages.count < kLCCKOnePageSize) {
self.parentConversationViewController.shouldLoadMoreMessagesScrollToTop = NO;
}
!block ?: block(avimTypedMessages, error);
}];
});
}];
}

Expand Down Expand Up @@ -727,7 +728,10 @@ - (void)insertOldMessages:(NSArray *)oldMessages completion:(void (^)())completi
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
NSMutableArray *messages = [NSMutableArray arrayWithArray:oldMessages];
[messages addObjectsFromArray:self.dataArray];
CGSize beforeContentSize = self.parentConversationViewController.tableView.contentSize;
__block CGSize beforeContentSize;
dispatch_async(dispatch_get_main_queue(),^{
beforeContentSize = self.parentConversationViewController.tableView.contentSize;
});
NSMutableArray *indexPaths = [NSMutableArray arrayWithCapacity:oldMessages.count];
[oldMessages enumerateObjectsUsingBlock:^(id message, NSUInteger idx, BOOL *stop) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:idx inSection:0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ - (void)configureCellWithData:(LCCKMessage *)message {
CGSize photoSize = CGSizeMake(message.photoWidth, message.photoHeight);
UIImage *newImage = [image lcck_imageByScalingAspectFillWithOriginSize:photoSize];
self.messageImageView.contentMode = UIViewContentModeScaleAspectFit;

UIEdgeInsets edgeMessageBubbleCustomize;
if (message.ownerType == LCCKMessageOwnerTypeSelf) {
UIEdgeInsets rightEdgeMessageBubbleCustomize = [LCCKSettingService sharedInstance].rightHollowEdgeMessageBubbleCustomize;
Expand All @@ -114,31 +113,29 @@ - (void)configureCellWithData:(LCCKMessage *)message {
make.height.mas_equalTo(newImage.size.height);
make.width.mas_equalTo(newImage.size.width);
}];
}else {
} else {
[self.messageImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.messageContentView).with.insets(edgeMessageBubbleCustomize);
make.height.mas_equalTo(newImage.size.height);
make.width.mas_equalTo(newImage.size.width);
}];
}

[self.messageImageView sd_setImageWithURL:message.originPhotoURL placeholderImage:newImage
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
dispatch_async(dispatch_get_main_queue(),^{
if (image){
message.photo = image;
message.thumbnailPhoto = [image lcck_imageByScalingAspectFillWithOriginSize:photoSize];
if ([self.delegate respondsToSelector:@selector(fileMessageDidDownload:)]) {
[self.delegate fileMessageDidDownload:self];
}
}
});

}
[self.messageImageView sd_setImageWithURL:message.originPhotoURL placeholderImage:newImage
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
dispatch_async(dispatch_get_main_queue(),^{
if (image){
message.photo = image;
message.thumbnailPhoto = [image lcck_imageByScalingAspectFillWithOriginSize:photoSize];
if ([self.delegate respondsToSelector:@selector(fileMessageDidDownload:)]) {
[self.delegate fileMessageDidDownload:self];
}
}
});
}
];
break;
}

} while (NO);
}

Expand Down
2 changes: 1 addition & 1 deletion ChatKit/Class/Tool/Service/LCCKConversationService.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ FOUNDATION_EXTERN NSString *const LCCKConversationServiceErrorDomain;

- (NSArray<LCCKMessage *> *)failedMessagesByMessageIds:(NSArray *)messageIds;

+ (void)cacheFileTypeMessages:(NSArray<AVIMTypedMessage *> *)messages callback:(AVBooleanResultBlock)callback;
+ (void)cacheFileTypeMessagesInBackground:(NSArray<AVIMTypedMessage *> *)messages;

@end

Expand Down
Loading

0 comments on commit c3d3698

Please sign in to comment.