Viewing Messages
Text Message
The following method will return a live object of a specific AmityMessage
based on messageId
. Since it is a live object, remember to observe its changes on top of the token.
The getMessage(messageId)
method will get a single message with the specified messageId
. To get a collection of messages in a channel, refer to Querying Messages.
Image Message
Images in messages are not downloaded automatically when the client receives a message. In order to save bandwidth, images should be downloaded only when they're about to be displayed. A typical implementation to trigger the download would be in the tableView:cellForRowAtIndexPath:
method. You can download an image using downloadImage:
or downloadImageAsData:
method from the AmityFileRepository
class. You need to pass the String
instance and the method provides the appropriate image url depending upon the sync state of message.
Please use the appropriate image size depending on your use-case in order to save bandwidth.
small
is used for image thumbnails, with a maximum image size of 160 pixels per dimension. For example, this should be used for small previews in an image gallery that displays a large amount of images in a grid.medium
is used for standard image display, with a maximum image size of 600 pixels per dimension. It's sized to take up about half of a mobile phone's screen size.large
is used for full screen image display, with a maximum image size of 1500 pixels per dimension.full
is used to get the original image. This size is only valid if the image is uploaded with the propertyfullImage
set toYES
. If a full sized image is not available, alarge
sized image will be returned instead.
The SDK do not cache image.
File/Audio Message
AmityFileRepository
provides downloadFile:
and downloadFileAsData:
method to download the file from URL. The same method can be used to download the audio.
Last updated