Moderation

Block a User#

To block a user call the below method.

    try ContactManager.shared.blockUser(for: JID_TO_BLOCK){ isSuccess, flyError, flyData in
    if isSuccess {
    //User is blocked update the UI
    } else{
    print(flyError!.localizedDescription)
    }
    }
    caution

    If block user feature unavailable for your plan then below methods will throw 403 exception.

    ArgumentTypeDescription
    JID_TO_BLOCKStringJID of the user
    CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

    Unblock a user#

    To unblock a user who is blocked already call the below method.

      try ContactManager.shared.unblockUser(for: JID_TO_UNBLOCK){ isSuccess, flyError, flyData in
      if isSuccess {
      //User is unblocked update the UI
      } else{
      print(flyError!.localizedDescription)
      }
      }
      caution

      If unblock user feature unavailable for your plan then below methods will throw 403 exception.

      ArgumentTypeDescription
      JID_TO_UNBLOCKStringJID of the user
      CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler
      caution

      Blocking and Unblocking valid for Single chat user only not for Group/Broadcast.

      Get user profiles that you blocked#

      To get the list of chat user profiles that you blocked call the below method.

        ContactManager.shared.getUsersIBlocked(FETCH_FROM_SERVER){ isSuccess, flyError, flyData in
        var data = flyData
        if isSuccess {
        let blockedprofileDetailsArray = data.getData() as! [ProfileDetails]
        } else{
        print(flyError!.localizedDescription)
        }
        }
        caution

        If block user feature unavailable for your plan then below methods will throw 403 exception.

        Refer Class documentation to know about ProfileDetails Class

        ArgumentTypeDescription
        FETCH_FROM_SERVERtrue to fetch from server false will fetch from local databaseBool
        CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

        Note : To make server call internet connection is required

        Get user profiles that blocked you#

        To get the list of single chat user that blocked you call the below method.

          ContactManager.shared.getUsersWhoBlockedMe(FETCH_FROM_SERVER){ isSuccess, flyError, flyData in
          var data = flyData
          if isSuccess {
          let blockedprofileDetailsArray = data.getData() as! [ProfileDetails]
          } else{
          print(flyError!.localizedDescription)
          }
          }
          caution

          If block user feature unavailable for your plan then below methods will throw 403 exception.

          Refer Class documentation to know about ProfileDetails Class

          ArgumentTypeDescription
          FETCH_FROM_SERVERtrue to fetch from server false will fetch from local databaseBool
          CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

          Note : To make server call internet connection is required

          Mute user/Group#

          If you want to mute the notifications for the chat of a user or a group, you can utilise the below method.

            ChatManager.updateChatMuteStatus(jid: jid, muteStatus: muteStatus)
            ArgumentTypeDescription
            JIDStringBool
            MUTE_STATUSBooltrue, if you want to mute notifications for the chat

            Media File Encryption#

            Media files can be encrypted before uploading them to the server by calling the below method.By default media file encryption is disabled.

              ChatManager.setMediaEncryption(isEnable: "ENABLE")
              ArgumentTypeDescription
              ENABLEBoolif true media files will be encrypted

              Report a user or group or message#

              Reporting is a feature which allows users to report a user or group or message.

              Getting Messgages To report by user Jid#

                let reportMessage : ReportMessage? = ChatManager.getMessagesForReporting(chatUserJid: chatUserJid, messagesCount: 5)
                caution

                If report message feature unavailable for your plan then below methods will throw 403 exception.

                ArgumentTypeDescription
                chatUserJidStringjid of a user or groupJid
                messagesCountIntcount of messages to be reported
                RetrunTypeDescription
                ReportMessageReportMessage structReportMessage is a model to be passed while reporting messages

                Getting Messgages To report from selected message#

                  let reportMessage : ReportMessage? = ChatManager.getMessagesForReporting(message: message, messagesCount: 5)
                  caution

                  If report message feature unavailable for your plan then below methods will throw 403 exception.

                  ArgumentTypeDescription
                  messageChatMessageselected ChatMessage
                  messagesCountIntcount of messages to be reported from selected message
                  RetrunTypeDescription
                  ReportMessageReportMessage structReportMessage is a model to be passed while reporting messages

                  Reporting#

                  To report call below method.

                    ChatManager.reportMessage(reportMessage: reportMessage) { isSent in
                    completionHandler(isSent)
                    }
                    caution

                    If report message feature unavailable for your plan then below methods will throw 403 exception.

                    ArgumentTypeDescription
                    reportMessageReportMessageReportMessage modle to be passed to report
                    resultTypeDescription
                    isSentBooltrue if success. false if failure

                    Handling Banned User/Group#

                    Banning a user or group is a feature. A user or group can be blocked or unblocked from console. This is applicable to logged in user, contacts of logged in user and groups

                    Note: Xmpp must be connected

                    Current / Logged in user#

                    To get blocking/unblocking event of current/logged in user, confirm viewcontroller or Appdelegate to below protocol.

                    AdminBlockCurrentUserDelegate

                      FlyDefaults.isBlockedByAdmin
                      // This will return true or false to check current user is blocked or unblocked.
                      // It can be used, while coming from background or opening the app or wherever
                        let adminEmail = "mirroflyadminsupport@gmail.com"
                        // support email is defined in StringConstants File.

                        In Appdelegate#

                          func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
                          ChatManager.shared.adminBlockCurrentUserDelegate = self
                          return true
                          }
                          extension AppDelegate : AdminBlockCurrentUserDelegate {
                          func didBlockOrUnblockCurrentUser(userJid: String, isBlocked: Bool) {
                          if isBlocked {
                          // if logged in user is being blocked this coditon will execute
                          // do your UI stuffs here
                          } else {
                          // if logged in user is unblocked this coditon will execute
                          // do your UI stuffs here
                          }
                          }
                          func didBlockOrUnblockGroup(groupJid : String, isBlocked : Bool) {
                          }
                          func didBlockOrUnblockContact(userJid : String, isBlocked : Bool) {
                          }
                          }

                          In ViewController#

                            override func viewDidAppear(_ animated: Bool) {
                            super.viewDidAppear(animated)
                            ChatManager.shared.adminBlockCurrentUserDelegate = self
                            }
                            override func viewWillDisappear(_ animated: Bool) {
                            super.viewWillDisappear(animated)
                            ChatManager.shared.adminBlockCurrentUserDelegate = nil
                            }
                            extension <View Controller Name> : AdminBlockCurrentUserDelegate {
                            func didBlockOrUnblockCurrentUser(userJid: String, isBlocked: Bool) {
                            if isBlocked {
                            // if logged in user is being blocked this coditon will execute
                            // do your UI stuff here
                            } else {
                            // if logged in user is unblocked this coditon will execute
                            // do your UI stuff here
                            }
                            }
                            func didBlockOrUnblockGroup(groupJid : String, isBlocked : Bool) {
                            }
                            func didBlockOrUnblockContact(userJid : String, isBlocked : Bool) {
                            }
                            }
                            ArgumentTypeDescription
                            userJidStringjid of the current user
                            isBlockedBooltrue, if current user is being blocked. false, if current user is unblocked

                            Contacts of current user and group#

                            To get blocking/unblocking event of Contacts of current user and group, confirm viewcontroller to below protocol.

                            AdminBlockDelegate

                            In ViewController#

                              override func viewDidAppear(_ animated: Bool) {
                              super.viewDidAppear(animated)
                              ChatManager.shared.adminBlockDelegate = self
                              }
                              override func viewWillDisappear(_ animated: Bool) {
                              super.viewWillDisappear(animated)
                              ChatManager.shared.adminBlockDelegate = nil
                              }
                              extension <ViewController Name> : AdminBlockDelegate {
                              func didBlockOrUnblockContact(userJid: String, isBlocked: Bool) {
                              // If a contact is blocked/unblocked, this function will be triggered
                              // do your UI stuff here
                              }
                              func didBlockOrUnblockSelf(userJid: String, isBlocked: Bool) {
                              // If a current user is blocked/unblocked, this function will be triggered
                              // do your UI stuff here
                              }
                              func didBlockOrUnblockGroup(groupJid: String, isBlocked: Bool) {
                              // If a group is blocked/unblocked, this function will be triggered
                              // do your UI stuff here
                              }
                              }
                              ArgumentTypeDescription
                              userJidStringjid of the user
                              isBlockedBooltrue, if user is being blocked. false, if user is unblocked
                              groupJidStringjid of the group