Manage a Group

Get user list to add to a group#

To get the list of users who are eligible to add to a group while creating or to a old group call one of the the below method.

    GroupManager.shared.getUsersListToAddMembersInExistingGroup(groupJid: groupId)
    ArgumentTypeDescription
    groupJidStringJid of a group
    warning

    Those above method are available only if contact sync is enabled.

    Add Participants to a group#

    To add participants to a group, call below method

      try GroupManager.shared.addParticipantToGroup(groupId: groupId, newUserJidList: selectedItemArray) { isSuccess, flyError, flyData in
      if isSuccess {
      // Update the UI
      } else{
      // failure cases
      }
      ArgumentTypeDescription
      groupJidStringJid of a group
      newUserJidList[String]array of jid list to be added in group (jid list should not contain jid, which is already exiting in same group)
      completionHandlerFlyCompletionHandlercallback to get success or failure response. implemented as closure expression
      info

      if addParticipantToGroup is success, func didAddNewMemeberToGroup(groupJid : String, newMemberJid : String, addedByMemberJid : String) method will be called, which is defined in GroupEventsDelegate.

      Remove a Participant from a group#

      To remove a participant from a group, call below method

        try GroupManager.shared.removeParticipantFromGroup(groupId: groupId, removeGroupMemberJid: userJid) { isSuccess, flyError, flyData in
        if isSuccess {
        // Update UI
        } else{
        // failure cases
        }
        }
        ArgumentTypeDescription
        groupJidStringJid of a group
        removeGroupMemberJidStringjid of participant to be removed from group, who is member of this group)
        completionHandlerFlyCompletionHandlercallback to get success or failure response. implemented as closure expression
        info

        if removeParticipantFromGroup is success, func didRemoveMemberFromGroup(groupJid : String, removedMemberJid : String, removedByMemberJid : String) method will be called, which is defined in GroupEventsDelegate.

        Make a participant as Admin#

        To make a participant as admin, call below method. Admin only can make a participant as admin.

          try GroupManager.shared.makeAdmin(groupJid: groupId, userJid: userJid, completionHandler: { isSuccess, flyError, flyData in
          if isSuccess {
          // update UI
          } else{
          // failure case
          }
          })
          ArgumentTypeDescription
          groupJidStringJid of a group
          userJidStringjid of the participant, to make as admin
          completionHandlerFlyCompletionHandlerimplemented as closure expression
          info

          func didMakeMemberAsAdmin(groupJid: String, newAdminMemberJid : String, madeByMemberJid : String) and func didGroupInfoUpdatedWithId(groupJid: String) method will be called, these are defined in GroupEventsDelegate.

          Revoke Admin Access#

          Users with admin privileges can revoke a participant's admin access within the group. Only group admins can be perform this action using the below method.

            try! GroupManager.shared.revokeAdmin(groupJid: groupID, revokeAdminJid: userJid, completionHandler: { isSuccess, flyError, flyData in
            if isSuccess {
            // update UI
            } else{
            // failure case
            }
            })
            ArgumentTypeDescription
            groupJidStringjid of the group
            revokeAdminJidStringjid of the participant, to remove from admin
            completionHandlerFlyCompletionHandlerimplemented as closure expression

            Exit from a Group#

            To exit from a group, call below method

              try GroupManager.shared.leaveFromGroup(groupJid: groupId, userJid: userJid, completionHandler: { isSuccess, flyError, flyData in
              if isSuccess {
              // update UI
              } else{
              // failure case
              }
              })
              ArgumentTypeDescription
              groupJidStringJid of a group
              userJidStringjid of the participant, to exit from the group
              completionHandlerFlyCompletionHandlerimplemented as closure expression
              info

              func didLeftFromGroup(groupJid: String, leftUserJid: String) method will be called, these are defined in GroupEventsDelegate.