Profile module

All the contact related operation will be found below.

ProfileDetails#

Every single chat contact has been modelled after ProfileDetails class. It holds the data of a user name, display picture, whether you blocked them or not etc. Refer this doc to know more about ProfileDetails Class

Get User profile data#

To get the profile data of a user(not a group) call the below method.

    try? ContactManager.shared.getUserProfile(USER_JID,FETCH_FROM_SERVER,SAVE_AS_FRIEND){ isSuccess, flyError, flyData in
    var data = flyData
    if isSuccess {
    let profileDetail = data.getData() as! [ProfileDetails]
    } else{
    print(flyError!.localizedDescription)
    }
    }
    ArgumentTypeDescription
    USER_JIDStringJid of the user
    FETCH_FROM_SERVERBooltrue to fetch from server false will fetch from local database
    SAVE_AS_FRIENDBoolif true the user will be saved as friend and will be available in list of contacts to chat
    CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

    Update your profile info#

    To update your profile call the below method.

      ContactManager.shared.updateMyProfile(PROFILE_OBJECT){ isSuccess, flyError, flyData in
      if isSuccess {
      // Profile updated successfully update the UI
      } else{
      print(flyError!.localizedDescription)
      }
      }
      info

      In profile object for image property set the absolute file path of a file if a image file needs to be uploaded or else set it to profile image id.

      ArgumentDescriptionData type
      PROFILE_OBJECTProfileProfile object which the updated value
      CALLBACKFlyCallbackFlyCallback implemented as as lambda expression

      Update profile image#

      To update your profile image call the below method.

        ContactManager.shared.updateMyProfileImage(IMAGE){ isSuccess, flyError, flyData in
        if isSuccess {
        // Profile Image updated successfully update the UI
        } else{
        print(flyError!.localizedDescription)
        }
        }
        ArgumentTypeDescription
        IMAGEStringImageURL of the profile image
        CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

        Remove Profile Image#

        To remove your profile image call the below method.

          ContactManager.shared.removeProfileImage(){ isSuccess, flyError, flyData in
          if isSuccess {
          // Profile Image removed successfully update the UI
          } else{
          print(flyError!.localizedDescription)
          }
          }
          ArgumentTypeDescription
          CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

          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

                ArgumentDescriptionData type
                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

                  ArgumentDescriptionData type
                  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 current User busy status#

                  User can get their current user busy status using the below method.

                    let myBusyStatus: BusyStatus = ChatManager.shared.getMyBusyStatus()

                    Refer this doc to know more about BusyStatus Class

                    Set User Busy status#

                    User can set the busy status message for their one to one chat conversation using the below method.

                      ChatManager.shared.setMyBusyStatus(BUSY_STATUS_TEXT, completion: @escaping FlyCompletionHandler)
                      ArgumentTypeDescription
                      BUSY_STATUS_TEXTStringbusy status text cannot be longer than 140 characters
                      COMPLETIONFlyCompletionHandlerFlyCompletionHandler used as completion Handler

                      Enable/Disable User Busy status#

                      User can enable and disable their busy status using the below method.

                        ChatManager.shared.enableDisableBusyStatus(ENABLE_BUSY_STATUS, completion: @escaping FlyCompletionHandler)
                        ArgumentTypeDescription
                        ENABLE_BUSY_STATUSBooltrue enables busy status and false disables busy status
                        COMPLETIONFlyCompletionHandlerFlyCompletionHandler used as completion Handler

                        Check User Busy status is enabled#

                        User can check whether their busy status is enabled or disabled.

                          let isMyBusyStatusEnabled: Bool = ChatManager.shared.isBusyStatusEnabled()

                          Get the list of User saved busy statuses#

                          User can get their list of previously saved user busy statuses by calling the below method.

                            let myBusyStatusList: [BusyStatus] = ChatManager.shared.getBusyStatusList()
                            info

                            This list also contains some pre defined values.

                            Delete a user Busy Status#

                            User can delete their busy status by calling the below method.

                              ChatManager.shared.deleteBusyStatus(statusId: STATUS_ID);
                              ArgumentTypeDescription
                              STATUS_IDStringObject of the user busy status that has to be deleted
                              caution

                              User cannot delete a busy status which is currently selected.

                              Enable disable hide seen status#

                              Hide Last seen status enables the user's last logged in time unavailable to their friends. To enable or disable the hide last seen status of the user call the below method.

                                ChatManager.enableDisableHideLastSeen( EnableLastSeen: lastSeen) { isSuccess, flyError, flyData in
                                var data = flyData
                                if isSuccess {
                                print(data.getMessage() as! String )
                                } else{
                                print(data.getMessage() as! String )
                                }
                                }
                                ArgumentTypeDescription
                                EnableLastSeenBooltrue enables the last seen available to friends false disables it
                                CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

                                Check last seen status#

                                To check whether last seen status is available to friends or not, call the below method.

                                  var lastSeenStatus: Bool = ChatManager.isLastSeenEnabled()

                                  Get last seen status#

                                  To get whether last seen status is available to friends or not, call the below method.

                                    ChatManager.getUserLastSeen( for: JID_STRING) { isSuccess, flyError, flyData in
                                    var data = flyData
                                    if isSuccess {
                                    print(data.getMessage() as! String )
                                    print(data.getData() as! String )
                                    } else{
                                    print(data.getMessage() as! String )
                                    }
                                    }
                                    ArgumentTypeDescription
                                    JID_TO_GETLASTSEENStringJID of the user
                                    CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

                                    Note: If response is 0 on getdata then its user is in online or will receive timestamp.

                                    Delete My Account#

                                    To delete your chat account call the below method. This will clear your profile,login information and messages(including media files) in the server as well as in your device. No information will be retained after account deletion. And if registration is made again with the same account it will be treated as a new account.

                                      ContactManager.shared.deleteMyAccountRequest(REASON, FEEDBACK) { isSuccess, flyError, flyData in
                                      var data = flyData
                                      print(data.getMessage() as! String )
                                      if isSuccess {
                                      // Clear necessary data and redirect to login page
                                      } else{
                                      // Show error in UI
                                      }
                                      }
                                      ArgumentTypeDescription
                                      REASONStringReason for the account deletion
                                      FEEDBACKStringFeedback for tha app if any
                                      CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler
                                      caution

                                      Once account is deleted the user will be removed from every group in which is he/her is a participant.

                                      Get the list of User saved profile statuses#

                                      User can get their list of previously saved user statuses by calling the below method.

                                        var getAllStatus: [ProfileStatus] = ChatManager.getAllStatus()
                                        info

                                        This list contains some pre defined values. ProfileStatus reference document

                                        Create user profile status#

                                        User can create the status for their profile using the below method.

                                          ChatManager.saveProfileStatus(STATUSTEXT,CURRENTSTATUS)
                                          ArgumentTypeDescription
                                          STATUSTEXTStringstatusText of the current status
                                          CURRENTSTATUSBoolcurrentStatus of the selected status

                                          Update user profile status#

                                          User can set the status for their profile using the below method.

                                            let (status, statusMessage) = ChatManager.updateStatus(STATUSID,STATUSTEXT,CURRENTSTATUS)
                                            ArgumentTypeDescription
                                            STATUSIDStringstatusId of the status
                                            STATUSTEXTStringstatusText of the current status
                                            CURRENTSTATUSBoolcurrentStatus of the selected status