Browse SDKs · iOS
SDKsiOS

Transfer group ownership

Transfer group ownership to another member with the Objective-C API.

Copy

Only the current owner can call transferGroupOwner:newOwner:onSuccess:onFailure:, and the target must be a valid group member. groupID is the target group ID and newOwner is the new owner's user ID; both are non-null NSString * arguments.

[[OIMManager manager] transferGroupOwner:groupID
    newOwner:targetUserID
    onSuccess:^(NSString * _Nullable data) { [self showTransferCompleted]; }
    onFailure:^(NSInteger code, NSString *message) {
        [self showErrorCode:code message:message];
    }];

State changes after the call

A successful callback means that OpenIMServer completed the transfer: the previous owner becomes a regular member and the new owner receives the owner role. Their role changes synchronize incrementally through onGroupMemberInfoChanged:. One transfer may produce two member updates; merge both by groupID:userID.

Do not infer the result solely from the number of delegate calls. To display the current owner and administrators, retrieve a new snapshot with getGroupMemberOwnerAndAdmin:onSuccess:onFailure:. For the complete listener and merge code, see Retrieve group members.

An owner who wants to leave must transfer ownership before calling the leave-group selector. The owner may dismiss a group that is no longer needed, but dismissal affects every member and does not substitute for an ordinary transfer.