<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "LinkPresentation",
  "identifier" : "/documentation/LinkPresentation/LPLinkMetadata",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Link Presentation"
    ],
    "preciseIdentifier" : "c:objc(cs)LPLinkMetadata"
  },
  "title" : "LPLinkMetadata"
}
-->

# LPLinkMetadata

An object that contains metadata about a URL.

```
class LPLinkMetadata
```

## Overview

Use [`LPLinkMetadata`](/documentation/LinkPresentation/LPLinkMetadata) to store the metadata about a URL, including its
title, icon, images and video.

Fetch metadata using [`LPMetadataProvider`](/documentation/LinkPresentation/LPMetadataProvider). For remote URLs, cache the
metadata locally to avoid the data and performance cost of fetching it from
the internet every time you present it. [`LPLinkMetadata`](/documentation/LinkPresentation/LPLinkMetadata) is serializable
with
<doc://com.apple.documentation/documentation/Foundation/NSSecureCoding>.

For local file URLs, the
<doc://com.apple.documentation/documentation/QuickLookThumbnailing> API
retrieves a representative thumbnail for the file, if possible.

## Provide custom metadata

Say your app already has a database of links, with titles and images that
weren’t fetched by [`LPMetadataProvider`](/documentation/LinkPresentation/LPMetadataProvider). You don’t have to fetch new
metadata from the internet in order to accelerate the share sheet or to
present a rich link. Instead, you can fill in the fields of
[`LPLinkMetadata`](/documentation/LinkPresentation/LPLinkMetadata) yourself.

Create an [`LPLinkMetadata`](/documentation/LinkPresentation/LPLinkMetadata) object, and fill in at least the
[`originalURL`](/documentation/LinkPresentation/LPLinkMetadata/originalURL) and [`url`](/documentation/LinkPresentation/LPLinkMetadata/url) fields, plus
whatever additional information you have.

```swift
func activityViewControllerLinkMetadata(_: UIActivityViewController) -> LPLinkMetadata? {
    let metadata = LPLinkMetadata()
    metadata.originalURL = URL(string: "https://www.example.com/apple-pie")
    metadata.url = metadata.originalURL
    metadata.title = "The Greatest Apple Pie In The World"
    metadata.imageProvider = NSItemProvider.init(contentsOf:
        Bundle.main.url(forResource: "apple-pie", withExtension: "jpg"))
    return metadata
}
```

## Accelerate the share sheet preview

For existing apps that share URLs, the share sheet automatically presents a
preview of the link. The preview first shows a placeholder link icon
alongside the base URL while fetching the link’s metadata over the network.
The preview updates once the link’s icon and title become available.

If you already have an [`LPLinkMetadata`](/documentation/LinkPresentation/LPLinkMetadata) object for a URL, pass it to the
share sheet to present the preview instantly, without fetching data over the
network. In your implementation of
<doc://com.apple.documentation/documentation/UIKit/UIActivityItemSource/activityViewControllerLinkMetadata(_:)>,
return the metadata object.

```swift
func activityViewControllerLinkMetadata(_:
UIActivityViewController) -> LPLinkMetadata? {
    return self.metadata
}
```

If the user chooses to share to Messages, the same metadata passes directly
through, providing a smooth and seamless experience with no unnecessary
loading.

## Topics

### Identifying the link

[`url`](/documentation/LinkPresentation/LPLinkMetadata/url)

The URL that returned the metadata, taking server-side redirects into
account.

[`originalURL`](/documentation/LinkPresentation/LPLinkMetadata/originalURL)

The original URL of the metadata request.

### Getting the link’s title

[`title`](/documentation/LinkPresentation/LPLinkMetadata/title)

A representative title for the URL.

### Getting the link’s images

[`iconProvider`](/documentation/LinkPresentation/LPLinkMetadata/iconProvider)

An object that retrieves data corresponding to a representative icon for the
URL.

[`imageProvider`](/documentation/LinkPresentation/LPLinkMetadata/imageProvider)

An object that retrieves data corresponding to a representative image for
the URL.

### Getting the link’s video

[`remoteVideoURL`](/documentation/LinkPresentation/LPLinkMetadata/remoteVideoURL)

A remote URL corresponding to a representative video for the URL.

[`videoProvider`](/documentation/LinkPresentation/LPLinkMetadata/videoProvider)

An object that retrieves data corresponding to a representative video for
the URL.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)