Skip to content

Commit

Permalink
fix: Bug fixes and performance enhancements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brett committed Jul 28, 2024
1 parent 968f29e commit fbe644c
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 49 deletions.
4 changes: 4 additions & 0 deletions Example/OpenIMSDKiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
06E322500E6F29AE7E3406B9 /* Pods_OpenIMSDKiOS_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EC002E155A37FC7CD6D16335 /* Pods_OpenIMSDKiOS_Example.framework */; };
173F10BA2B3EDD49002826B9 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 173F10B92B3EDD49002826B9 /* libresolv.tbd */; };
17918D0727BC8F380040C924 /* OPENIMSDKTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 17918D0627BC8F380040C924 /* OPENIMSDKTableViewCell.m */; };
17CADD2727C7227F0069C80E /* photo_test.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = 17CADD2527C7227F0069C80E /* photo_test.jpeg */; };
17CADD2827C7227F0069C80E /* voice_test.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 17CADD2627C7227F0069C80E /* voice_test.m4a */; };
Expand Down Expand Up @@ -42,6 +43,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
173F10B92B3EDD49002826B9 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
17918D0527BC8F380040C924 /* OPENIMSDKTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OPENIMSDKTableViewCell.h; sourceTree = "<group>"; };
17918D0627BC8F380040C924 /* OPENIMSDKTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OPENIMSDKTableViewCell.m; sourceTree = "<group>"; };
17CADD2527C7227F0069C80E /* photo_test.jpeg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = photo_test.jpeg; sourceTree = "<group>"; };
Expand Down Expand Up @@ -82,6 +84,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
173F10BA2B3EDD49002826B9 /* libresolv.tbd in Frameworks */,
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */,
6003F592195388D20070C39A /* UIKit.framework in Frameworks */,
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */,
Expand Down Expand Up @@ -137,6 +140,7 @@
6003F58C195388D20070C39A /* Frameworks */ = {
isa = PBXGroup;
children = (
173F10B92B3EDD49002826B9 /* libresolv.tbd */,
6003F58D195388D20070C39A /* Foundation.framework */,
6003F58F195388D20070C39A /* CoreGraphics.framework */,
6003F591195388D20070C39A /* UIKit.framework */,
Expand Down
19 changes: 7 additions & 12 deletions Example/OpenIMSDKiOS/OPENIMSDKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ - (void)viewDidLoad
@[@{OIM_LIST_CELL_TITLE: @"Login", OIM_LIST_CELL_FUNC: @"login"},
@{OIM_LIST_CELL_TITLE: @"Login Status", OIM_LIST_CELL_FUNC: @"loginStatus"},
@{OIM_LIST_CELL_TITLE: @"Logout", OIM_LIST_CELL_FUNC: @"logout"},
@{OIM_LIST_CELL_TITLE: @"Set Heartbeat", OIM_LIST_CELL_FUNC: @"setHeartbeatInterval"},
],

@[@{OIM_LIST_CELL_TITLE: @"Get User Info", OIM_LIST_CELL_FUNC: @"getSelfInfo"},
Expand Down Expand Up @@ -245,11 +244,13 @@ - (void)callback {

}];

[OIMManager.callbacker setConversationListenerWithOnSyncServerStart:^{
[OIMManager.callbacker setConversationListenerWithOnSyncServerStart:^(BOOL result) {

} onSyncServerFinish:^{
} onSyncServerFinish:^(BOOL result) {

} onSyncServerFailed:^{
} onSyncServerFailed:^(BOOL result) {

} onSyncServerProgress:^(NSInteger number) {

} onConversationChanged:^(NSArray<OIMConversationInfo *> * _Nullable conversations) {

Expand Down Expand Up @@ -307,6 +308,8 @@ - (void)initSDK {

} onUserTokenExpired:^{

} onUserTokenInvalid:^(NSString * _Nullable item) {

}];
}

Expand Down Expand Up @@ -386,14 +389,6 @@ - (void)getUsersInfo {
}];
}

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

[OIMManager.manager setHeartbeatInterval:30];
}];
}

#pragma mark -
#pragma mark - Friend

Expand Down
4 changes: 2 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 = '3.5.1+1'
s.version = '3.8.0-rc.16'
s.summary = 'Open-IM-SDK'

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

s.static_framework = true

s.dependency 'OpenIMSDKCore', '3.5.1'
s.dependency 'OpenIMSDKCore', '3.8.0-rc.16'
s.dependency 'MJExtension'
end
7 changes: 4 additions & 3 deletions OpenIMSDK/Callbacker/OIMCallbacker+Closure.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ NS_ASSUME_NONNULL_BEGIN
*
* Actively fetch conversation records at app startup, and later refresh data based on listener callbacks for conversation changes.
*/
- (void)setConversationListenerWithOnSyncServerStart:(OIMVoidCallback)onSyncServerStart
onSyncServerFinish:(OIMVoidCallback)onSyncServerFinish
onSyncServerFailed:(OIMVoidCallback)onSyncServerFailed
- (void)setConversationListenerWithOnSyncServerStart:(OIMBoolCallback)onSyncServerStart
onSyncServerFinish:(OIMBoolCallback)onSyncServerFinish
onSyncServerFailed:(OIMBoolCallback)onSyncServerFailed
onSyncServerProgress:(OIMNumberCallback)onSyncServerProgress
onConversationChanged:(OIMConversationsInfoCallback)onConversationChanged
onNewConversation:(OIMConversationsInfoCallback)onNewConversation
onTotalUnreadMessageCountChanged:(OIMNumberCallback)onTotalUnreadMessageCountChanged;
Expand Down
12 changes: 6 additions & 6 deletions OpenIMSDK/Callbacker/OIMCallbacker+Closure.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

@implementation OIMCallbacker (Closure)

- (void)setConversationListenerWithOnSyncServerStart:(OIMVoidCallback)onSyncServerStart
onSyncServerFinish:(OIMVoidCallback)onSyncServerFinish
onSyncServerFailed:(OIMVoidCallback)onSyncServerFailed
onConversationChanged:(OIMConversationsInfoCallback)onConversationChanged
onNewConversation:(OIMConversationsInfoCallback)onNewConversation
onTotalUnreadMessageCountChanged:(OIMNumberCallback)onTotalUnreadMessageCountChanged {
- (void)setConversationListenerWithOnSyncServerStart:(OIMBoolCallback)onSyncServerStart
onSyncServerFinish:(OIMBoolCallback)onSyncServerFinish
onSyncServerFailed:(OIMBoolCallback)onSyncServerFailed
onSyncServerProgress:(OIMNumberCallback)onSyncServerProgress
onConversationChanged:(OIMConversationsInfoCallback)onConversationChanged onNewConversation:(OIMConversationsInfoCallback)onNewConversation onTotalUnreadMessageCountChanged:(OIMNumberCallback)onTotalUnreadMessageCountChanged{
self.syncServerStart = onSyncServerStart;
self.syncServerFinish = onSyncServerFinish;
self.syncServerFailed = onSyncServerFailed;
self.syncServerProgress = onSyncServerProgress;
self.onConversationChanged = onConversationChanged;
self.onNewConversation = onNewConversation;
self.onTotalUnreadMessageCountChanged = onTotalUnreadMessageCountChanged;
Expand Down
18 changes: 12 additions & 6 deletions OpenIMSDK/Callbacker/OIMCallbacker.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ typedef void (^OIMGetAdvancedHistoryMessageListCallback)(OIMGetAdvancedHistoryMe
*/
- (void)onUserTokenExpired;

- (void)onUserTokenInvalid:(NSString *)errMsg;

@end

/// User Status Callbacks
Expand Down Expand Up @@ -232,17 +234,19 @@ typedef void (^OIMGetAdvancedHistoryMessageListCallback)(OIMGetAdvancedHistoryMe
/**
* Synchronization with the server has started for conversations.
*/
- (void)onSyncServerStart;
- (void)onSyncServerStart:(BOOL)reInstall;

- (void)onSyncServerProgress:(NSInteger)progress;

/**
* Synchronization with the server for conversations has completed.
*/
- (void)onSyncServerFinish;
- (void)onSyncServerFinish:(BOOL)reInstall;

/**
* Synchronization with the server for conversations has failed.
*/
- (void)onSyncServerFailed;
- (void)onSyncServerFailed:(BOOL)reInstall;

/**
* New conversations have been added.
Expand Down Expand Up @@ -319,6 +323,7 @@ Open_im_sdk_callbackOnCustomBusinessListener
@property (nonatomic, nullable, copy) OIMVoidCallback connectSuccess;
@property (nonatomic, nullable, copy) OIMVoidCallback kickedOffline;
@property (nonatomic, nullable, copy) OIMVoidCallback userTokenExpired;
@property (nonatomic, nullable, copy) OIMStringCallback userTokenInvalid;

/**
* Add IM SDK listener.
Expand Down Expand Up @@ -393,9 +398,10 @@ Open_im_sdk_callbackOnCustomBusinessListener

/// Conversation Listener
/// Set after a successful InitSDK and before Login, called when conversation-related information changes.
@property (nonatomic, nullable, copy) OIMVoidCallback syncServerStart;
@property (nonatomic, nullable, copy) OIMVoidCallback syncServerFinish;
@property (nonatomic, nullable, copy) OIMVoidCallback syncServerFailed;
@property (nonatomic, nullable, copy) OIMBoolCallback syncServerStart;
@property (nonatomic, nullable, copy) OIMBoolCallback syncServerFinish;
@property (nonatomic, nullable, copy) OIMBoolCallback syncServerFailed;
@property (nonatomic, nullable, copy) OIMNumberCallback syncServerProgress;
@property (nonatomic, nullable, copy) OIMConversationsInfoCallback onNewConversation;
@property (nonatomic, nullable, copy) OIMConversationsInfoCallback onConversationChanged;
@property (nonatomic, nullable, copy) OIMNumberCallback onTotalUnreadMessageCountChanged;
Expand Down
38 changes: 29 additions & 9 deletions OpenIMSDK/Callbacker/OIMCallbacker.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ - (void)onUserTokenExpired {
}];
}

- (void)onUserTokenInvalid:(NSString *)errMsg {
[self dispatchMainThread:^{
if (self.userTokenInvalid) {
self.userTokenInvalid(errMsg);
}

[self.sdkListeners onUserTokenInvalid:errMsg];
}];
}

#pragma mark -
#pragma mark - User

Expand Down Expand Up @@ -585,33 +595,43 @@ - (void)onNewConversation:(NSString * _Nullable)conversationList {
}];
}

- (void)onSyncServerFailed {
- (void)onSyncServerFailed:(BOOL)reinstalled {
[self dispatchMainThread:^{
if (self.syncServerFailed) {
self.syncServerFailed();
self.syncServerFailed(reinstalled);
}

[self.conversationListeners onSyncServerFailed];
[self.conversationListeners onSyncServerFailed:reinstalled];
}];
}

- (void)onSyncServerFinish {
- (void)onSyncServerFinish:(BOOL)reinstalled {
[self dispatchMainThread:^{
if (self.syncServerFinish) {
self.syncServerFinish();
self.syncServerFinish(reinstalled);
}

[self.conversationListeners onSyncServerFinish];
[self.conversationListeners onSyncServerFinish:reinstalled];
}];
}

- (void)onSyncServerStart:(BOOL)reinstalled {
[self dispatchMainThread:^{
if (self.syncServerStart) {
self.syncServerStart(reinstalled);
}

[self.conversationListeners onSyncServerStart:reinstalled];
}];
}

- (void)onSyncServerStart {
- (void)onSyncServerProgress:(long)progress {
[self dispatchMainThread:^{
if (self.syncServerStart) {
self.syncServerStart();
self.syncServerStart(progress);
}

[self.conversationListeners onSyncServerStart];
[self.conversationListeners onSyncServerProgress:progress];
}];
}

Expand Down
8 changes: 2 additions & 6 deletions OpenIMSDK/Interface/OIMManager+Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
onConnectFailure:(OIMFailureCallback)onConnectFailure
onConnectSuccess:(OIMVoidCallback)onConnectSuccess
onKickedOffline:(OIMVoidCallback)onKickedOffline
onUserTokenExpired:(OIMVoidCallback)onUserTokenExpired;

/**
* Set heartbeat interval
*/
- (void)setHeartbeatInterval:(NSInteger)heartbeatInterval;
onUserTokenExpired:(OIMVoidCallback)onUserTokenExpired
onUserTokenInvalid:(OIMStringCallback)onUserTokenInvalid;

- (void)unInitSDK;

Expand Down
8 changes: 3 additions & 5 deletions OpenIMSDK/Interface/OIMManager+Connection.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ - (BOOL)initSDKWithConfig:(OIMInitConfig *)config
onConnectFailure:(OIMFailureCallback)onConnectFailure
onConnectSuccess:(OIMVoidCallback)onConnectSuccess
onKickedOffline:(OIMVoidCallback)onKickedOffline
onUserTokenExpired:(OIMVoidCallback)onUserTokenExpired {
onUserTokenExpired:(OIMVoidCallback)onUserTokenExpired
onUserTokenInvalid:(OIMStringCallback)onUserTokenInvalid {

[self class].callbacker.connecting = onConnecting;
[self class].callbacker.connectFailure = onConnectFailure;
[self class].callbacker.connectSuccess = onConnectSuccess;
[self class].callbacker.kickedOffline = onKickedOffline;
[self class].callbacker.userTokenExpired = onUserTokenExpired;
[self class].callbacker.userTokenInvalid = onUserTokenInvalid;

NSMutableDictionary *param = [NSMutableDictionary new];

Expand All @@ -57,10 +59,6 @@ - (BOOL)initSDKWithConfig:(OIMInitConfig *)config
return Open_im_sdkInitSDK([self class].callbacker, [self operationId], param.mj_JSONString);
}

- (void)setHeartbeatInterval:(NSInteger)heartbeatInterval {
Open_im_sdkSetHeartbeatInterval(heartbeatInterval);
}

- (void)unInitSDK {
Open_im_sdkUnInitSDK([self operationId]);
}
Expand Down
5 changes: 5 additions & 0 deletions OpenIMSDK/Interface/OIMManager+Friend.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getFriendListWithOnSuccess:(nullable OIMFullUsersInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

- (void)getFriendListPageWithOffset:(NSInteger)offset
count:(NSInteger)count
onSuccess:(nullable OIMFullUsersInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

/**
* Check if there is a friend relationship, i.e., if the user is in the friend list of the logged-in user. Note: Friendship is a two-way relationship.
* A result of 1 means the user is a friend (and not in the blacklist).
Expand Down
13 changes: 13 additions & 0 deletions OpenIMSDK/Interface/OIMManager+Friend.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ - (void)getFriendListWithOnSuccess:(OIMFullUsersInfoCallback)onSuccess
Open_im_sdkGetFriendList(callback, [self operationId]);
}

- (void)getFriendListPageWithOffset:(NSInteger)offset
count:(NSInteger)count
onSuccess:(OIMFullUsersInfoCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:^(NSString * _Nullable data) {
if (onSuccess) {
onSuccess([OIMFullUserInfo mj_objectArrayWithKeyValuesArray:data]);
}
} onFailure:onFailure];

Open_im_sdkGetFriendListPage(callback, [self operationId], (int32_t)offset, (int32_t)count);
}

- (void)checkFriend:(NSArray<NSString *> *)usersID
onSuccess:(OIMSimpleResultsCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {
Expand Down
10 changes: 10 additions & 0 deletions OpenIMSDK/Interface/OIMManager+Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)getJoinedGroupListWithOnSuccess:(nullable OIMGroupsInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

- (void)getJoinedGroupListPageWithOffset:(NSInteger)offset
count:(NSInteger)count
onSuccess:(nullable OIMGroupsInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

/**
* Batch get group information
*
Expand Down Expand Up @@ -296,6 +301,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)isJoinedGroup:(NSString *)groupID
onSuccess:(nullable OIMBoolCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;

- (void)getUsersInGroup:(NSString *)groupID
userIDs:(NSArray<NSString *> *)userIDs
onSuccess:(nullable OIMStringArrayCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
@end

NS_ASSUME_NONNULL_END
Expand Down
28 changes: 28 additions & 0 deletions OpenIMSDK/Interface/OIMManager+Group.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ - (void)getJoinedGroupListWithOnSuccess:(OIMGroupsInfoCallback)onSuccess
Open_im_sdkGetJoinedGroupList(callback, [self operationId]);
}

- (void)getJoinedGroupListPageWithOffset:(NSInteger)offset
count:(NSInteger)count
onSuccess:(OIMGroupsInfoCallback)onSuccess
onFailure:(OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:^(NSString * _Nullable data) {
if (onSuccess) {
onSuccess([OIMGroupInfo mj_objectArrayWithKeyValuesArray:data]);
}
} onFailure:onFailure];

Open_im_sdkGetJoinedGroupListPage(callback, [self operationId], (int32_t)offset, (int32_t)count);
}

- (void)getSpecifiedGroupsInfo:(NSArray <NSString *> *)groupsID
onSuccess:(nullable OIMGroupsInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure {
Expand Down Expand Up @@ -332,4 +345,19 @@ - (void)isJoinedGroup:(NSString *)groupID

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

- (void)getUsersInGroup:(NSString *)groupID
userIDs:(NSArray<NSString *> *)userIDs
onSuccess:(nullable OIMStringArrayCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure {
CallbackProxy *callback = [[CallbackProxy alloc]initWithOnSuccess:^(NSString * _Nullable data) {
if (onSuccess) {
NSArray<NSString *> *users = data.mj_JSONObject;
onSuccess(nil, users);
}
} onFailure:onFailure];

Open_im_sdkGetUsersInGroup(callback, [self operationId], groupID, userIDs.mj_JSONString);
}

@end

0 comments on commit fbe644c

Please sign in to comment.