The Chat SDK supports the URL link preview for both open channels and group channels when a message text contains the URL of a web page. This feature is turned on by default for Sendbird applications. If this isn't available for your Sendbird application, see this page and contact us on the Sendbird Dashboard to enable the feature.
Note: The above image shows a chat view completed with our UIKit components. Your client app's channel view may look different depending on channel type and UI settings.
BaseMessage object includes a valid URL of a website, the object can contain
OGMetaData, a class that holds OG metadata information such as title, URL, description, and default image of an OG object.
Note: Some websites don’t provide the OG metadata. In that case, even though the OG protocol states them as requirements, all of the four properties can be
The title of the OG object as it should appear within the graph. The value can be
The canonical URL of the object that can be used as its permanent ID in the graph. The value can be set to
The description of the object. The value can be set to
OGImage instance holds image-related data for an
OGImage can also have six optional structured properties of URL, secure URL, type, width, height, and alt. Except for width and height, other fields such as URL, secure URL, type, and alt can be set to
nil. If the target website doesn’t provide width and height data, the value of those two fields are set to
The URL of an image object within the Open Graph. The value can be set to
An alternative URL to use if the webpage requires
A media type or MIME type of this image. The value can be set to
The number of pixels horizontal. When the value is unavailable, this method returns
The number of pixels vertical. When the value is unavailable, this method returns
The description of what is in the image, not a caption of the image. The alt attribute is designed to provide a fuller context of the
If a user sends a message with a web page URL and the linked web page possesses Open Graph (OG) tags, or OG metadata, Sendbird server parses the message content, extracts the URL in the message, gets the OG metadata from it, and creates an OG metadata object for the message. Then message recipients will get the parsed message with its OG metadata through the
channel(_:didReceive:) method in the channel event delegate of the SDK. On the other hand, the message sender will do the same through
Displaying an OG metadata object is available for two subtypes of
AdminMessage. If the content of either a
AdminMessage object includes a web page URL containing OG metadata, the
channel(_:didReceive:) method returns
If Sendbird server doesn’t have cache memory of the OG metadata of the given URL,
ogMetaData can be
nil due to the time it takes to fetch the OG metadata from a remote web page. In the meantime, the message text containing the URL will be delivered first to message recipients’ client app through the
channel(_:didReceive:) method. When the server completes fetching, the
channel(_:didUpdate:) method will be called and the message with its
OGMetaData object will be delivered to the recipients’ client app. However, if Sendbird server has already cached the OG metadata of the URL,
ogMetaData returns the message and its
OGMetaData object instantly and the
channel(_:didUpdate:) method won’t be called.