Send a Message

Text message#

Text is a basic form of communication between users. sdk provides methods to send the text message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the text message for a user, you can utilise the below method.

To send your text message, you need to pass the TextMessage object as an argument to the parameter in the sendTextMessage() method.

    var textMessage = TextMessage()
    textMessage.toId = TO_JID
    textMessage.messageText = MESSAGE
    textMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
    textMessage.mentionedUsersIds = MENTION_IDS // Optional
    textMessage.metaData = META_DATA // Optional
    textMessage.topicID = TOPIC_ID // Optional
    FlyMessenger.sendTextMessage(messageParams: textMessage) { isSuccess, error, chatMessage in
    if (isSuccess) {
    //you can add this message object to your arraylist,
    //then you can notify the tableview
    }
    }
    ArgumentTypeDescription
    MESSAGE_PARAMSTextMessageObject to hold the parameters of the text message
    CALLBACKFlySendMessageListenercallback to observe the action status

    Image message#

    To send image as a message call the below method. Calling the below method will upload the image file to the server provided during sdk initialization then send the message

    To send your image message, you need to pass the FileMessage object with FileMessageParams set as an argument to the parameter in the sendMediaFileMessage() method.

      var fileMessageParams = FileMessageParams()
      fileMessageParams.fileUrl = FILE_URL
      fileMessageParams.fileName = FILE_NAME
      fileMessageParams.fileSize = FILE_SIZE
      fileMessageParams.thumbImage = THUMB_IMAGE
      fileMessageParams.caption = CAPTION
      fileMessageParams.fileKey = FILE_KEY
      var fileMessage = FileMessage()
      fileMessage.toId = TO_JID
      fileMessage.messageType = MessageType.image
      fileMessage.fileMessage = fileMessageParams
      fileMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
      fileMessage.mentionedUsersIds = MENTION_IDS // Optional
      fileMessage.metaData = META_DATA // Optional
      fileMessage.topicID = TOPIC_ID // Optional
      FlyMessenger.sendMediaFileMessage(messageParams: fileMessage){ isSuccess,error,message in
      if (isSuccess) {
      //you can add this message object to your arraylist,
      //then you can notify the tableview
      }
      }
      ArgumentTypeDescription
      MESSAGE_PARAMSFileMessageObject to hold the parameters of the image message
      CALLBACKFlySendMessageListenercallback to observe the action status

      To get the metadata of an image file for sending images make use of the utility methods MediaUtils.getAssetsImageInfo() and MediaUtils.compressImageFile()

      caution

      If Image attachment feature unavailable for your plan then it will throw 403 exception.

      FlyMessenger.sendFileMessage(messageParams: fileMessage){ isSuccess,error,message in
      if (isSuccess) {
      //you can add this message object to your arraylist,
      //then you can notify the tableview
      }
      }
      caution

      FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future releases, migrate to FlyMessenger.sendMediaFileMessage() method to send Image files.

      Video message#

      Video sharing is very useful communication between users. sdk provides methods to send the video message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the video message for a user, you can utilise the below method.

      To send your video message, you need to pass the FileMessage object with FileMessageParams set as an argument to the parameter in the sendMediaFileMessage() method.

        var fileMessageParams = FileMessageParams()
        fileMessageParams.fileUrl = FILE_URL
        fileMessageParams.fileName = FILE_NAME
        fileMessageParams.fileSize = FILE_SIZE
        fileMessageParams.duration = DURATION
        fileMessageParams.thumbImage = THUMB_IMAGE
        fileMessageParams.caption = CAPTION
        fileMessageParams.fileKey = FILE_KEY
        var fileMessage = FileMessage()
        fileMessage.toId = TO_JID
        fileMessage.messageType = MessageType.video
        fileMessage.fileMessage = fileMessageParams
        fileMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
        fileMessage.mentionedUsersIds = MENTION_IDS // Optional
        fileMessage.metaData = META_DATA // Optional
        fileMessage.topicID = TOPIC_ID // Optional
        FlyMessenger.sendMediaFileMessage(messageParams: fileMessage){ isSuccess,error,message in
        if (isSuccess) {
        //you can add this message object to your arraylist,
        //then you can notify the tableview
        }
        }
        ArgumentTypeDescription
        MESSAGE_PARAMSFileMessageObject to hold the parameters of the video message
        LISTENERFlySendMessageListenercallback to observe the action status

        To get the metadata of a video file for sending videos make use of the utility methods MediaUtils.processVideo() and MediaUtils.compressVideoFile()

        caution

        If Video attachment feature unavailable for your plan then it will throw 403 exception.

        FlyMessenger.sendFileMessage(messageParams: fileMessage){ isSuccess,error,message in
        if (isSuccess) {
        //you can add this message object to your arraylist,
        //then you can notify the tableview
        }
        }
        caution

        FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future releases, migrate to FlyMessenger.sendMediaFileMessage() method to send Video files.

        Audio message#

        To send audio as a message call the below method. Calling the below method will upload the audio file to the server provided during sdk initialization then send the message

        To send your audio message, you need to pass the FileMessage object with FileMessageParams set as an argument to the parameter in the sendMediaFileMessage() method.

          var fileMessageParams = FileMessageParams()
          fileMessageParams.fileUrl = FILE_URL
          fileMessageParams.fileName = FILE_NAME
          fileMessageParams.fileSize = FILE_SIZE
          fileMessageParams.thumbImage = THUMB_IMAGE
          fileMessageParams.duration = DURATION
          fileMessageParams.caption = CAPTION
          fileMessageParams.fileKey = FILE_KEY
          var fileMessage = FileMessage()
          fileMessage.toId = TO_JID
          fileMessage.messageType = MessageType.audio
          fileMessage.fileMessage = fileMessageParams
          fileMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
          fileMessage.mentionedUsersIds = MENTION_IDS // Optional
          fileMessage.metaData = META_DATA // Optional
          fileMessage.topicID = TOPIC_ID // Optional
          FlyMessenger.sendMediaFileMessage(messageParams: fileMessage){ isSuccess,error,message in
          if (isSuccess) {
          //you can add this message object to your arraylist,
          //then you can notify the tableview
          }
          }
          ArgumentTypeDescription
          MESSAGE_PARAMSFileMessageObject to hold the parameters of the audio message
          listenerFlySendMessageListenercallback to observe the action status

          To get the metadata of an audio file for sending audio make use of the utility method MediaUtils.processAudioFile()

          caution

          If Audio attachment feature unavailable for your plan then it will throw 403 exception.

          FlyMessenger.sendFileMessage(messageParams: fileMessage){ isSuccess,error,message in
          if (isSuccess) {
          //you can add this message object to your arraylist,
          //then you can notify the tableview
          }
          }
          caution

          FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future releases, migrate toFlyMessenger.sendMediaFileMessage() method to send Audio files.

          Document message#

          Document sharing is very useful communication between users. sdk provides methods to send the document message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the document message for a user, you can utilise the below method.

          To send your document message, you need to pass the FileMessage object with FileMessageParams set as an argument to the parameter in the sendMediaFileMessage() method.

            var fileMessageParams = FileMessageParams()
            fileMessageParams.fileUrl = FILE_URL
            fileMessageParams.fileName = FILE_NAME
            var fileMessage = FileMessage()
            fileMessage.toId = TO_JID
            fileMessage.messageType = MessageType.document
            fileMessage.fileMessage = fileMessageParams
            fileMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
            fileMessage.mentionedUsersIds = MENTION_IDS // Optional
            fileMessage.metaData = META_DATA // Optional
            fileMessage.topicID = TOPIC_ID // Optional
            FlyMessenger.sendMediaFileMessage(messageParams: fileMessage){ isSuccess,error,message in
            if (isSuccess) {
            //you can add this message object to your arraylist,
            //then you can notify the tableview
            }
            }
            ArgumentTypeDescription
            MESSAGE_PARAMSFileMessageObject to hold the parameters of the document message
            CALLBACKFlySendMessageListenercallback to observe the action status
            caution

            If Document attachment feature unavailable for your plan then it will throw 403 exception.

            FlyMessenger.sendFileMessage(messageParams: fileMessage){ isSuccess,error,message in
            if (isSuccess) {
            //you can add this message object to your arraylist,
            //then you can notify the tableview
            }
            }
            caution

            FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future releases, migrate to FlyMessenger.sendMediaFileMessage() method to send Document files.

            Location message#

            Location sharing is a famous communication between users. sdk provides methods to send the location message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the location message for a user, you can utilise the below method.

            To send your location message, you need to pass the FileMessage object with LocationMessageParams set as an argument to the parameter in the sendMediaFileMessage() method.

              var locationMessageParams = LocationMessageParams()
              locationMessageParams.latitude = LATITUDE
              locationMessageParams.longitude = LONGITUDE
              var fileMessage = FileMessage()
              fileMessage.toId = TO_JID
              fileMessage.messageType = MessageType.location
              fileMessage.locationMessage = locationMessageParams
              fileMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
              fileMessage.mentionedUsersIds = MENTION_IDS // Optional
              fileMessage.metaData = META_DATA // Optional
              fileMessage.topicID = TOPIC_ID // Optional
              FlyMessenger.sendMediaFileMessage(messageParams: fileMessage){ isSuccess,error,message in
              if (isSuccess) {
              //you can add this message object to your arraylist,
              //then you can notify the tableview
              }
              }
              ArgumentTypeDescription
              MESSAGE_PARAMSFileMessageObject to hold the parameters of the location message
              CALLBACKFlySendMessageListenercallback to observe the action status
              caution

              If Location attachment feature unavailable for your plan then it will throw 403 exception.

              FlyMessenger.sendFileMessage(messageParams: fileMessage){ isSuccess,error,message in
              if (isSuccess) {
              //you can add this message object to your arraylist,
              //then you can notify the tableview
              }
              }
              caution

              FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future releases, migrate to FlyMessenger.sendMediaFileMessage() method to send Location message.

              Contact message#

              Contact sharing is very useful communication between users. sdk provides methods to send the contact message to the end users. once the user has sent message via sdk, it will give callback with status. if you want send the contact message for a user, you can utilise the below method.

              To send your contact message, you need to pass the FileMessage object with ContactMessageParams set as an argument to the parameter in the sendMediaFileMessage() method.

                var contactMessageParam = ContactMessageParams()
                contactMessageParam.name = CONTACT_NAME
                contactMessageParam.numbers = CONTACT_NUMBERS
                var fileMessage = FileMessage()
                fileMessage.toId = TO_JID
                fileMessage.messageType = MessageType.contact
                fileMessage.contactMessage = contactMessageParam
                fileMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
                fileMessage.mentionedUsersIds = MENTION_IDS // Optional
                fileMessage.metaData = META_DATA // Optional
                fileMessage.topicID = TOPIC_ID // Optional
                FlyMessenger.sendMediaFileMessage(messageParams: fileMessage){ isSuccess,error,message in
                if (isSuccess) {
                //you can add this message object to your arraylist,
                //then you can notify the tableview
                }
                }
                ArgumentTypeDescription
                MESSAGE_PARAMSFileMessageObject to hold the parameters of the contact message
                CALLBACKFlySendMessageListenercallback to observe the action status
                caution

                If Contact attachment feature unavailable for your plan then it will throw 403 exception.

                FlyMessenger.sendFileMessage(messageParams: fileMessage){ isSuccess,error,message in
                if (isSuccess) {
                //you can add this message object to your arraylist,
                //then you can notify the tableview
                }
                }
                caution

                FlyMessenger.sendFileMessage() method was deprecated and will be removed in the future releases, migrate to FlyMessenger.sendMediaFileMessage() method to send Contact message.

                Meet message#

                A meet message typically refers to a message or communication related to scheduling or planning a meeting. These messages can include information about the Scheduled date,time and meet link.

                Create Meet link#

                Before you send the meet message, you need to create the meet link using the createMeetLink method. Once the meet link has been created successfully, you can send the Meet message.

                  CallManager.createMeetLink { [weak self] (isSuccess , error, data) in
                  if isSuccess {
                  // The data dictionary will contain the nelwy generated unique meet id
                  // let meetId = data['data'] as! String
                  }
                  }

                  To send your Meet message, you need to pass the MeetMessage as an argument to the parameter in the sendMeetMessage() method.

                    var meetMessage = MeetMessage()
                    meetMessage.toId = TO_JID
                    meetMessage.link = MEET_LINK
                    meetMessage.scheduledDateTime = SCHEDULED_TIME
                    meetMessage.title = TITLE // Optional
                    meetMessage.replyMessageId = REPLY_MESSAGE_ID // Optional
                    meetMessage.mentionedUsersIds = MENTION_IDS // Optional
                    meetMessage.metaData = META_DATA // Optional
                    meetMessage.topicID = TOPIC_ID // Optional
                    FlyMessenger.sendMeetMessage(messageParams: meetMessage){ isSuccess,error,message in
                    if (isSuccess) {
                    //you can add this message object to your arraylist,
                    //then you can notify the tableview
                    }
                    }
                    ArgumentTypeDescription
                    MESSAGE_PARAMSMeetMessageObject to hold the parameters of the meet message
                    CALLBACKFlySendMessageListenercallback to observe the action status
                    caution

                    If Group call feature is unavailable for your plan, then it will throw 403 exception