Skip to content

Commit

Permalink
[Update] Add API for rich text messages;
Browse files Browse the repository at this point in the history
Added API for viewing group member information;
Added API for adding members as friends;
Add a new API for withdrawing messages;

Added parameter "Add group method" to "Add group API";
  • Loading branch information
std-s committed Jul 15, 2022
1 parent 6085574 commit 9c7c99d
Show file tree
Hide file tree
Showing 23 changed files with 518 additions and 68 deletions.
80 changes: 40 additions & 40 deletions Example/OpenIMSDKiOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

82 changes: 81 additions & 1 deletion Example/OpenIMSDKiOS/OPENIMSDKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ - (void)viewDidLoad
@{OIM_LIST_CELL_TITLE: @"设置群昵称", OIM_LIST_CELL_FUNC: @"setGroupMemberNickname",},
@{OIM_LIST_CELL_TITLE: @"设置群成员级别", OIM_LIST_CELL_FUNC: @"setGroupMemberRoleLevel",},
@{OIM_LIST_CELL_TITLE: @"根据加入时间分页获取组成员列表", OIM_LIST_CELL_FUNC: @"getGroupMemberListByJoinTimeFilter",},
@{OIM_LIST_CELL_TITLE: @"设置进群方式", OIM_LIST_CELL_FUNC: @"setGroupVerification",}
@{OIM_LIST_CELL_TITLE: @"设置进群方式", OIM_LIST_CELL_FUNC: @"setGroupVerification",},
@{OIM_LIST_CELL_TITLE: @"获取群主和管理员", OIM_LIST_CELL_FUNC: @"getGroupMemberOwnerAndAdmin",},
@{OIM_LIST_CELL_TITLE: @"群成员间是否可加好友", OIM_LIST_CELL_FUNC: @"setGroupApplyMemberFriend",},
@{OIM_LIST_CELL_TITLE: @"群成员间是否可查看信息", OIM_LIST_CELL_FUNC: @"setGroupLookMemberInfo",},
],

@[@{OIM_LIST_CELL_TITLE: @"发送消息", OIM_LIST_CELL_FUNC: @"sendMessage"},
Expand Down Expand Up @@ -311,6 +314,8 @@ - (void)callback {
NSLog(@"onRecvGroupReadReceipt:%@", msgReceiptList);
} onRecvNewMessage:^(OIMMessageInfo * _Nullable message) {

} onNewRecvMessageRevoked:^(NSArray<OIMMessageRevoked *> * _Nullable msgRovoked) {

}];
}

Expand Down Expand Up @@ -1008,6 +1013,47 @@ - (void)setGroupVerification {
}];
}

- (void)getGroupMemberOwnerAndAdmin {
[self operate:_cmd
todo:^(void (^callback)(NSNumber *code, NSString *msg)) {

[OIMManager.manager getGroupMemberOwnerAndAdmin:GROUP_ID
onSuccess:^(NSArray<OIMGroupMemberInfo *> * _Nullable groupMembersInfo) {
callback(nil, nil);
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];
}];
}

- (void)setGroupApplyMemberFriend {
[self operate:_cmd
todo:^(void (^callback)(NSNumber *code, NSString *msg)) {

[OIMManager.manager setGroupApplyMemberFriend:GROUP_ID
rule:0
onSuccess:^(NSString * _Nullable data) {
callback(nil, nil);
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];
}];
}

- (void)setGroupLookMemberInfo {
[self operate:_cmd
todo:^(void (^callback)(NSNumber *code, NSString *msg)) {

[OIMManager.manager setGroupLookMemberInfo:GROUP_ID
rule:0
onSuccess:^(NSString * _Nullable data) {
callback(nil, nil);
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];
}];
}

#pragma mark -
#pragma mark - Message

Expand Down Expand Up @@ -1051,6 +1097,33 @@ - (void)sendMessage {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];

/* 不使用sdk的文件上传
OIMPictureInfo *pic = [OIMPictureInfo new];
pic.url = @"xxx";
self.testMessage = [OIMMessageInfo createImageMessageByURL:pic bigPicture:pic snapshotPicture:pic];
self.testMessage = [OIMMessageInfo createSoundMessageByURL:@"xxx"
duration:10
size:100];
self.testMessage = [OIMMessageInfo createVideoMessageByURL:@"xxx"
videoType:@"mp4"
duration:10
size:100
snapshot:@"https://c-ssl.duitang.com/uploads/item/202105/29/20210529001057_aSeLB.jpeg"];
[OIMManager.manager sendMessageNotOss:self.testMessage
recvID:OTHER_USER_ID
groupID:GROUP_ID
offlinePushInfo:nil
onSuccess:^(OIMMessageInfo * _Nullable message) {
self.testMessage = message;
callback(nil, nil);
} onProgress:^(NSInteger number) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];
*/
}];
}

Expand Down Expand Up @@ -1114,6 +1187,13 @@ - (void)revokeMessage {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];

[OIMManager.manager newRevokeMessage:self.testMessage
onSuccess:^(NSString * _Nullable data) {
callback(nil, nil);
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
callback(@(code), msg);
}];
}];
}

Expand Down
5 changes: 5 additions & 0 deletions Example/OpenIMSDKiOS/OpenIMSDKiOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
5 changes: 3 additions & 2 deletions OpenIMSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'OpenIMSDK'
s.version = '2.2.0'
s.version = '2.3.0'
s.summary = 'Open-IM-SDK'

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -73,6 +73,7 @@ Pod::Spec.new do |s|


s.static_framework = true
s.dependency 'OpenIMSDKCore', '2.2.0'

s.dependency 'OpenIMSDKCore', '2.3.0'
s.dependency 'MJExtension'
end
6 changes: 6 additions & 0 deletions OpenIMSDK/Callbacker/OIMCallbacker+Closure.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ NS_ASSUME_NONNULL_BEGIN
onRecvGroupReadReceipt:(OIMReceiptCallback)onRecvGroupReadReceipt
onRecvNewMessage:(OIMMessageInfoCallback)onRecvNewMessage;

- (void)setAdvancedMsgListenerWithOnRecvMessageRevoked:(nullable OIMStringCallback)onRecvMessageRevoked
onRecvC2CReadReceipt:(OIMReceiptCallback)onRecvC2CReadReceipt
onRecvGroupReadReceipt:(OIMReceiptCallback)onRecvGroupReadReceipt
onRecvNewMessage:(OIMMessageInfoCallback)onRecvNewMessage
onNewRecvMessageRevoked:(OIMRevokedCallback)onNewRecvMessageRevoked;

/*
* 用户信息监听
*
Expand Down
14 changes: 13 additions & 1 deletion OpenIMSDK/Callbacker/OIMCallbacker+Closure.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,19 @@ - (void)setAdvancedMsgListenerWithOnRecvMessageRevoked:(OIMStringCallback)onRecv
self.onRecvMessageRevoked = onRecvMessageRevoked;
self.onRecvC2CReadReceipt = onRecvC2CReadReceipt;
self.onRecvGroupReadReceipt = onRecvGroupReadReceipt;
self.onRecvNewMessage = onRecvNewMessage;
}

- (void)setAdvancedMsgListenerWithOnRecvMessageRevoked:(OIMStringCallback)onRecvMessageRevoked
onRecvC2CReadReceipt:(OIMReceiptCallback)onRecvC2CReadReceipt
onRecvGroupReadReceipt:(OIMReceiptCallback)onRecvGroupReadReceipt
onRecvNewMessage:(OIMMessageInfoCallback)onRecvNewMessage
onNewRecvMessageRevoked:(OIMRevokedCallback)onNewRecvMessageRevoked {

self.onRecvMessageRevoked = onRecvMessageRevoked;
self.onRecvC2CReadReceipt = onRecvC2CReadReceipt;
self.onRecvGroupReadReceipt = onRecvGroupReadReceipt;
self.onNewRecvMessageRevoked = onNewRecvMessageRevoked;

}

- (void)setSelfUserInfoUpdateListener:(OIMUserInfoCallback)onUserInfoUpdate {
Expand Down
4 changes: 4 additions & 0 deletions OpenIMSDK/Callbacker/OIMCallbacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef void (^OIMMessagesInfoCallback)(NSArray <OIMMessageInfo *> * _Nullable m
typedef void (^OIMMessageSearchCallback)(OIMSearchResultInfo * _Nullable result);

typedef void (^OIMReceiptCallback)(NSArray <OIMReceiptInfo *> * _Nullable msgReceiptList);
typedef void (^OIMRevokedCallback)(NSArray <OIMMessageRevoked *> * _Nullable msgRovoked);

typedef void (^OIMSignalingInvitationCallback)(OIMSignalingInfo * _Nullable result);
typedef void (^OIMSignalingResultCallback)(OIMInvitationResultInfo * _Nullable result);
Expand Down Expand Up @@ -269,6 +270,8 @@ typedef void (^OIMMomentsInfoCallback)(NSArray <OIMMomentsInfo *> * _Nullable it
*/
- (void)onRecvMessageRevoked:(NSString *)msgID;

- (void)onNewRecvMessageRevoked:(NSString *)messageRevoked;

@end

/// 音视频监听器
Expand Down Expand Up @@ -445,6 +448,7 @@ Open_im_sdk_callbackOnWorkMomentsListener
@property (nonatomic, nullable, copy) OIMReceiptCallback onRecvC2CReadReceipt;
@property (nonatomic, nullable, copy) OIMReceiptCallback onRecvGroupReadReceipt;
@property (nonatomic, nullable, copy) OIMStringCallback onRecvMessageRevoked;
@property (nonatomic, nullable, copy) OIMRevokedCallback onNewRecvMessageRevoked;

/*
* 添加高级消息的事件监听器
Expand Down
13 changes: 13 additions & 0 deletions OpenIMSDK/Callbacker/OIMCallbacker.m
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,19 @@ - (void)onRecvMessageRevoked:(NSString * _Nullable)msgId {
}];
}

- (void)onNewRecvMessageRevoked:(NSString *)messageRevoked {

OIMMessageRevoked *revoked = [OIMMessageRevoked mj_objectWithKeyValues:messageRevoked];

[self dispatchMainThread:^{
if (self.onNewRecvMessageRevoked) {
self.onNewRecvMessageRevoked(revoked);
}

[self.advancedMsgListeners onNewRecvMessageRevoked:revoked];
}];
}

- (void)onRecvNewMessage:(NSString * _Nullable)message {
OIMMessageInfo *msg = [OIMMessageInfo mj_objectWithKeyValues:message];

Expand Down
43 changes: 42 additions & 1 deletion OpenIMSDK/Interface/OIMManager+Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ NS_ASSUME_NONNULL_BEGIN
- (void)joinGroup:(NSString *)gid
reqMsg:(NSString * _Nullable)reqMsg
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
onFailure:(nullable OIMFailureCallback)onFailure DEPRECATED_MSG_ATTRIBUTE("Use [joinGroup:reqMsg:joinSource]");

/*
* 申请加入群组
*
* @param gid 群组ID
* @param reqMsg 进群申请消息
* @param joinSource 进群方式
*/
- (void)joinGroup:(NSString *)gid
reqMsg:(NSString *)reqMsg
joinSource:(OIMJoinType)joinSource
onSuccess:(OIMSuccessCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure;

/*
* 退群
Expand Down Expand Up @@ -247,6 +260,34 @@ NS_ASSUME_NONNULL_BEGIN
needVerification:(OIMGroupVerificationType)needVerification
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

/**
获取管理者和拥有者
@param groupID 群ID
*/
- (void)getGroupMemberOwnerAndAdmin:(NSString *)groupID
onSuccess:(nullable OIMGroupMembersInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

/**
群成员之间是否可添加好友
@param groupID 群ID
@param rule 0: 默认可行 1: 不可行
*/
- (void)setGroupApplyMemberFriend:(NSString *)groupID
rule:(int32_t)rule
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

/**
查看群成员信息
@param groupID 群ID
@param rule 0: 默认可行 1: 不可行
*/
- (void)setGroupLookMemberInfo:(NSString *)groupID
rule:(int32_t)rule
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
@end

NS_ASSUME_NONNULL_END
47 changes: 44 additions & 3 deletions OpenIMSDK/Interface/OIMManager+Group.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@ - (void)joinGroup:(NSString *)gid
onFailure:(OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:onSuccess onFailure:onFailure];

Open_im_sdkJoinGroup(callback, [self operationId], gid, reqMsg ?: @"");
Open_im_sdkJoinGroup(callback, [self operationId], gid, reqMsg ?: @"", OIMJoinTypeSearch);
}

- (void)joinGroup:(NSString *)gid
reqMsg:(NSString *)reqMsg
joinSource:(OIMJoinType)joinSource
onSuccess:(OIMSuccessCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:onSuccess onFailure:onFailure];

Open_im_sdkJoinGroup(callback, [self operationId], gid, reqMsg ?: @"", joinSource);
}

- (void)quitGroup:(NSString *)gid
Expand Down Expand Up @@ -69,7 +79,7 @@ - (void)setGroupInfo:(NSString *)gid
onSuccess:(OIMSuccessCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:onSuccess onFailure:onFailure];

Open_im_sdkSetGroupInfo(callback, [self operationId], gid, info.mj_JSONString);
}

Expand Down Expand Up @@ -141,7 +151,7 @@ - (void)inviteUserToGroup:(NSString *)groupId
}

- (void)getGroupApplicationListWithOnSuccess:(OIMGroupsApplicationCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {
onFailure:(OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:^(NSString * _Nullable data) {
if (onSuccess) {
onSuccess([OIMGroupApplicationInfo mj_objectArrayWithKeyValuesArray:data]);
Expand Down Expand Up @@ -268,4 +278,35 @@ - (void)setGroupVerification:(NSString *)groupID
Open_im_sdkSetGroupVerification(callback, [self operationId], groupID, (int32_t)needVerification);
}

- (void)getGroupMemberOwnerAndAdmin:(NSString *)groupID
onSuccess:(OIMGroupMembersInfoCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {

CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:^(NSString * _Nullable data) {
if (onSuccess) {
onSuccess([OIMGroupMemberInfo mj_objectArrayWithKeyValuesArray:data]);
}
} onFailure:onFailure];

Open_im_sdkGetGroupMemberOwnerAndAdmin(callback, [self operationId], groupID);
}

- (void)setGroupApplyMemberFriend:(NSString *)groupID
rule:(int32_t)rule
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure {

CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:onSuccess onFailure:onFailure];

Open_im_sdkSetGroupApplyMemberFriend(callback, [self operationId], groupID, rule);
}

- (void)setGroupLookMemberInfo:(NSString *)groupID
rule:(int32_t)rule
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:onSuccess onFailure:onFailure];

Open_im_sdkSetGroupLookMemberInfo(callback, [self operationId], groupID, rule);
}
@end
Loading

0 comments on commit 9c7c99d

Please sign in to comment.