Link Presentation in iOS 13

Add metadata to your links

Ryan NHP
Ryan NHP
Jan 16 · 2 min read
Image source:

Difficulty: Easy | Medium | Hard

When Apple released iOS 10, Apple’s Messages app was updated to a new version that supports rich links in Messages. With iOS 13, Apple supports the use of rich links in our own apps. Here are some steps to help you implement add metadata to your links.

Step 1. Get Your Metadata

LPLinkMetadata is an object that stores metadata about the URL, including the link’s title, icon, image, and video.

Fetch metadata automatically

LPMetadataProvider is an object that retrieves metadata for a URL. After it finishes fetching, it will map the metadata to the LPLinkMetadata object.

LPMetadataProvider supports a function is called startFetchingMetadata.

Below is an example.

Custom metadata

Below is an example for Title (title of the link).

Step 2. Create a View That Contains LPLinkMetadata

LPLinkView is a rich visual representation of a link.

For ease, I want to grab all the necessary functions in one file:

Here’s the result for two cases: automatically (left) and custom (right).

Automatically (left) and Custom (right)

Try It With Video

Here’s the result:

Thanks for reading. I hope this article is useful to you.

Better Programming

Advice for programmers.

Ryan NHP

Written by

Ryan NHP

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade