SDKsiOS
Transfer group ownership
Transfer group ownership to another member with the Objective-C API.
Invoke transferGroupOwner:newOwner:onSuccess:onFailure: to transfer group ownership to another existing member (only the current group owner has permission to perform this action):
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
groupID | NSString * | Yes | Target group ID. |
newOwner | NSString * | Yes | User ID of the new group owner. |
Code example
[[OIMManager manager] transferGroupOwner:@"group_1001"
newOwner:@"user_002"
onSuccess:^(NSString * _Nullable data) {
NSLog(@"transferGroupOwner success");
}
onFailure:^(NSInteger code, NSString *message) {
NSLog(@"transferGroupOwner failed: %ld %@", (long)code, message);
}];Return value
The onSuccess callback returns confirmation when the server completes the ownership transfer.
State changes after the call
- Role transition: The former owner is demoted to a regular member, while the designated member is promoted to group owner. Both role updates broadcast via
onGroupMemberInfoChanged:. - Local state merge: Merge updated roles for both affected users using
groupID:userID. To refresh the management list immediately, call Retrieve the group owner and administrators. - Leaving the group: A group owner wishing to exit must transfer ownership before calling Leave a group, or dissolve the group with Dismiss a group.
Was this page helpful?