Skip to content
This repository was archived by the owner on Oct 9, 2021. It is now read-only.

Commit

Permalink
Release SealTalk Demo version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RongRobot committed May 9, 2017
1 parent 0ebf401 commit 4eb3ba2
Show file tree
Hide file tree
Showing 28 changed files with 215 additions and 117 deletions.
75 changes: 41 additions & 34 deletions ios-rongimdemo/RCDCreateGroupViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,40 +300,46 @@ - (IBAction)ClickDoneBtn:(id)sender {
.currentUserInfo.userId
ImageData:data
success:^(NSString *url) {
RCGroup *groupInfo = [RCGroup new];
groupInfo.portraitUri = url;
groupInfo.groupId = groupId;
groupInfo.groupName = nameStr;
dispatch_async(dispatch_get_main_queue(), ^{
[RCDHTTPTOOL
setGroupPortraitUri:url
groupId:groupId
complete:^(BOOL result) {
[[RCIM sharedRCIM]
refreshGroupInfoCache:
groupInfo
withGroupId:
groupId];
if (result == YES) {
[self gotoChatView:groupInfo.groupId groupName:groupInfo.groupName];
//关闭HUD
[hud hide:YES];
[RCDHTTPTOOL getGroupByID:groupInfo.groupId
successCompletion:^(RCDGroupInfo *group) {
[[RCDataBaseManager shareInstance] insertGroupToDB:group];
}];
}
if (result == NO) {
self.navigationItem
.rightBarButtonItem
.enabled =
YES; //关闭HUD
[hud hide:YES];
[self Alert:@"创建群组失败,请检查你的网络设置。"];
}
}];
});

if (url) {
RCGroup *groupInfo = [RCGroup new];
groupInfo.portraitUri = url;
groupInfo.groupId = groupId;
groupInfo.groupName = nameStr;
dispatch_async(dispatch_get_main_queue(), ^{
[RCDHTTPTOOL
setGroupPortraitUri:url
groupId:groupId
complete:^(BOOL result) {
[[RCIM sharedRCIM]
refreshGroupInfoCache:
groupInfo
withGroupId:
groupId];
if (result == YES) {
[self gotoChatView:groupInfo.groupId groupName:groupInfo.groupName];
//关闭HUD
[hud hide:YES];
[RCDHTTPTOOL getGroupByID:groupInfo.groupId
successCompletion:^(RCDGroupInfo *group) {
[[RCDataBaseManager shareInstance] insertGroupToDB:group];
}];
}
if (result == NO) {
self.navigationItem
.rightBarButtonItem
.enabled =
YES; //关闭HUD
[hud hide:YES];
[self Alert:@"创建群组失败,请检查你的网络设置。"];
}
}];
});
}else{
[self gotoChatView:groupId groupName:nameStr];
//关闭HUD
[hud hide:YES];
}

}
failure:^(NSError *err) {
self.navigationItem.rightBarButtonItem
Expand Down Expand Up @@ -459,6 +465,7 @@ -(UIImage*)getSubImage:(UIImage *)originImage Rect:(CGRect)rect imageOrientation
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, smallBounds, subImageRef);
UIImage* smallImage = [UIImage imageWithCGImage:subImageRef scale:1.f orientation:imageOrientation];
CGImageRelease(subImageRef);
UIGraphicsEndImageContext();
return smallImage;
}
Expand Down
71 changes: 42 additions & 29 deletions ios-rongimdemo/RCDGroupSettingsTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -416,35 +416,47 @@ - (void)imagePickerController:(UIImagePickerController *)picker
weakSelf.Group.portraitUri = url;
[[RCIM sharedRCIM] refreshGroupInfoCache:groupInfo
withGroupId:groupInfo.groupId];
[RCDHTTPTOOL setGroupPortraitUri:url
groupId:weakSelf.Group.groupId
complete:^(BOOL result) {
if (result == YES) {
dispatch_async(dispatch_get_main_queue(), ^{
RCDBaseSettingTableViewCell *cell =
(RCDBaseSettingTableViewCell *)
[self.tableView viewWithTag:1000];
[cell.rightImageView sd_setImageWithURL:[NSURL URLWithString:self.Group.portraitUri]];
//在修改群组头像成功后,更新本地数据库。
[[RCDataBaseManager shareInstance] insertGroupToDB:self.Group];
// cell.PortraitImg.image = image;
//关闭HUD
[hud hide:YES];
});
}
if (result == NO) {
//关闭HUD
[hud hide:YES];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:nil
message:@"上传头像失败"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
}
}];

if (url) {
[RCDHTTPTOOL setGroupPortraitUri:url
groupId:weakSelf.Group.groupId
complete:^(BOOL result) {
if (result == YES) {
dispatch_async(dispatch_get_main_queue(), ^{
RCDBaseSettingTableViewCell *cell =
(RCDBaseSettingTableViewCell *)
[self.tableView viewWithTag:1000];
[cell.rightImageView sd_setImageWithURL:[NSURL URLWithString:self.Group.portraitUri]];
//在修改群组头像成功后,更新本地数据库。
[[RCDataBaseManager shareInstance] insertGroupToDB:self.Group];
// cell.PortraitImg.image = image;
//关闭HUD
[hud hide:YES];
});
}
if (result == NO) {
//关闭HUD
[hud hide:YES];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:nil
message:@"上传头像失败"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
}
}];

}else{
//关闭HUD
[hud hide:YES];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:nil
message:@"上传头像失败"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
[alert show];
}
}
failure:^(NSError *err) {
//关闭HUD
Expand Down Expand Up @@ -474,6 +486,7 @@ -(UIImage*)getSubImage:(UIImage *)originImage Rect:(CGRect)rect imageOrientation
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextDrawImage(context, smallBounds, subImageRef);
UIImage* smallImage = [UIImage imageWithCGImage:subImageRef scale:1.f orientation:imageOrientation];
CGImageRelease(subImageRef);
UIGraphicsEndImageContext();
return smallImage;
}
Expand Down
23 changes: 21 additions & 2 deletions ios-rongimdemo/RCDHttpTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,32 @@ - (void)uploadImageToQiNiu:(NSString *)userId
[AFHttpTool uploadFile:image
userId:userId
success:^(id response) {
NSString* imageUrl = nil;
if ([response[@"key"] length] > 0) {
NSString *key = response[@"key"];
NSString *QiNiuDomai = [DEFAULTS objectForKey:@"QiNiuDomain"];
NSString *imageUrl =
imageUrl =
[NSString stringWithFormat:@"http://%@/%@", QiNiuDomai, key];
success(imageUrl);
}
else{
NSDictionary *downloadInfo = response[@"rc_url"];
if (downloadInfo) {
NSString* fileInfo = downloadInfo[@"path"];
if ([downloadInfo[@"type"] intValue] == 0) {
NSString *url = response[@"domain"];
if ([url hasSuffix:@"/"]) {
url = [url substringToIndex:url.length - 1];
}
if ([fileInfo hasPrefix:@"/"]) {
imageUrl = [url stringByAppendingString:fileInfo];
}
else{
imageUrl = [url stringByAppendingPathComponent:fileInfo];
}
}
}
}
success(imageUrl);
}
failure:^(NSError *err) {
failure(err);
Expand Down
2 changes: 1 addition & 1 deletion ios-rongimdemo/RCDSettingServerUrlViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ - (void)forgetPswEvent {
- (IBAction)btnDoneClicked:(id)sender {
if (![self checkContent])
return;

RCNetworkStatus status =
[[RCIMClient sharedRCIMClient] getCurrentNetworkStatus];

Expand Down
21 changes: 19 additions & 2 deletions ios-rongimdemo/RCloudMessage/AFHttpTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ + (void)uploadFile:(NSData *)fileData
if ([response[@"code"] integerValue] == 200) {
NSDictionary *result = response[@"result"];
NSString *defaultDomain = result[@"domain"];
NSString *uploadUrl = result[@"upload_url"];
if (uploadUrl.length > 0 && ![uploadUrl hasPrefix:@"http"]) {
uploadUrl = [NSString stringWithFormat:@"http://%@",uploadUrl];
}
[DEFAULTS setObject:defaultDomain forKey:@"QiNiuDomain"];
[DEFAULTS synchronize];

Expand Down Expand Up @@ -382,12 +386,17 @@ + (void)uploadFile:(NSData *)fileData
NSMutableDictionary *ret = [NSMutableDictionary dictionary];
[params addEntriesFromDictionary:ret];

NSString *url = @"https://up.qbox.me";
NSString *url = uploadUrl.length > 0 ? uploadUrl : @"https://up.qbox.me";

NSData *imageData = fileData;

AFHTTPRequestOperationManager *manager =
[AFHTTPRequestOperationManager manager];
if (uploadUrl.length > 0) {
NSMutableSet *contentTypes = [[NSMutableSet alloc] initWithSet:manager.responseSerializer.acceptableContentTypes];
[contentTypes addObject:@"text/html"];
manager.responseSerializer.acceptableContentTypes = [contentTypes copy];
}
[manager POST:url
parameters:params
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
Expand All @@ -397,7 +406,15 @@ + (void)uploadFile:(NSData *)fileData
mimeType:@"application/octet-stream"];
}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
success(responseObject);
if (uploadUrl.length > 0) {
NSMutableDictionary* responseDic = [[NSMutableDictionary alloc] initWithDictionary:responseObject];
[responseDic setValue:defaultDomain forKey:@"domain"];
success([responseDic copy]);
}
else{
success(responseObject);
}

}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"请求失败");
Expand Down
6 changes: 3 additions & 3 deletions ios-rongimdemo/RCloudMessage/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.8.10 Dev</string>
<string>2.8.11 Stable</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -42,7 +42,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>201704191439</string>
<string>201705091856</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down Expand Up @@ -126,7 +126,7 @@
<key>NSPhotoLibraryUsageDescription</key>
<string>访问相册</string>
<key>SealTalk Version</key>
<string>1.2.0</string>
<string>1.2.1</string>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
Expand Down
2 changes: 1 addition & 1 deletion ios-rongimdemo/RCloudMessage/RCDChatViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ - (void)viewWillAppear:(BOOL)animated {
}

[self refreshTitle];
[self.chatSessionInputBarControl updateStatus:self.chatSessionInputBarControl.currentBottomBarStatus animated:NO];
// [self.chatSessionInputBarControl updateStatus:self.chatSessionInputBarControl.currentBottomBarStatus animated:NO];
}

- (void)viewWillDisappear:(BOOL)animated {
Expand Down
Loading

0 comments on commit 4eb3ba2

Please sign in to comment.