Desk SDKs iOS v1
Desk SDKs iOS
Desk SDKs
Version 1

When a customer sends a message from a client app that includes a link, Link preview enables to provide a preview text or a thumbnail image of the URL. In this way, a sender and a receiver of the message can be aware of what they're going to see before they open the link.

To provide a link preview by updating a message, every user message sent from a client app should be checked if it includes any URLs through the detector.

Implement the code to parse the HTML source of a URL in a customer's message and extract the OpenGraph metadata of the URL. Then, set the extracted OG metadata as a JSON object and stringify the object to pass it as an argument to a data property in the UserMessageUpdateParams class which is used as a parameter in the GroupChannel updateUserMessage(messageId:params:data:completionHandler:) method.

Note: There are various methods to extract OG metadata from the HTML body. You can refer to our GitHub repository for the method we're using.

A sender can add a link preview to the original message through update(messageId:params:completionHandler:) in GroupChannel. Then the channel(_:didUpdate:) delegate method in BaseChannelDelegate will be called for the receiver with a preview of the link on the app or web.