<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIActivityItemSource/activityViewControllerLinkMetadata(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIActivityItemSource(im)activityViewControllerLinkMetadata:"
  },
  "title" : "activityViewControllerLinkMetadata(_:)"
}
-->

# activityViewControllerLinkMetadata(_:)

Returns metadata to display in the preview header of the share sheet.

```
optional func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata?
```

## Parameters

`activityViewController`

The [`UIActivityViewController`](/documentation/UIKit/UIActivityViewController) object requesting information about the item that the user wants to share.

## Return Value

The <doc://com.apple.documentation/documentation/LinkPresentation/LPLinkMetadata> object that contains the metadata about a URL, including its title, icon, images, and video.

## Discussion

Using the <doc://com.apple.documentation/documentation/LinkPresentation> framework, you can display rich previews of web links inside your app. For instance, if your app already has a database of links, with titles and images that weren’t fetched by <doc://com.apple.documentation/documentation/LinkPresentation/LPMetadataProvider>, you don’t have to fetch new metadata from the internet. Use this method instead and avoid downloading it again.

In your implementation, create an <doc://com.apple.documentation/documentation/LinkPresentation/LPLinkMetadata> object, and fill in at least the <doc://com.apple.documentation/documentation/LinkPresentation/LPLinkMetadata/originalURL> and <doc://com.apple.documentation/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
}
```

To learn more about presenting rich links and accelerating the share sheet, see <doc://com.apple.documentation/documentation/LinkPresentation> and <doc://com.apple.documentation/documentation/LinkPresentation/LPMetadataProvider>, or watch the WWDC 2019 session [262: Embedding and Sharing Visually Rich Links](https://developer.apple.com/videos/play/wwdc2019/262/).

---

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)