Class LPLinkMetadata

  • All Implemented Interfaces:
    NSCoding, NSCopying, NSSecureCoding, NSObject

    public class LPLinkMetadata
    extends NSObject
    implements NSCopying, NSSecureCoding
    An object that contains metadata about a URL. Use ``LPLinkMetadata`` to store the metadata about a URL, including its title, icon, images and video. Fetch metadata using ``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`` is serializable with . For local file URLs, the 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``. 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`` yourself. Create an ``LPLinkMetadata`` object, and fill in at least the ``LPLinkMetadata/originalURL`` and ``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`` 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 , 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. API-Since: 13.0
    • Constructor Detail

      • LPLinkMetadata

        protected LPLinkMetadata​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • URL

        @Nullable
        public @Nullable NSURL URL()
        The URL that returned the metadata, taking server-side redirects into account. The URL that returns the metadata may differ from the ``LPLinkMetadata/originalURL`` to which you sent the metadata request. This can happen if the server redirects the request, for example, when a resource has moved, or when the original URL is a domain alias.
      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

        public static LPLinkMetadata allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull org.moe.natj.objc.Class classForKeyedUnarchiver()
      • copyWithZone

        @NotNull
        public @NotNull java.lang.Object copyWithZone​(@Nullable
                                                      @Nullable org.moe.natj.general.ptr.VoidPtr zone)
        Specified by:
        copyWithZone in interface NSCopying
      • debugDescription_static

        public static java.lang.String debugDescription_static()
      • description_static

        public static java.lang.String description_static()
      • hash_static

        public static long hash_static()
      • iconProvider

        @Nullable
        public @Nullable NSItemProvider iconProvider()
        An object that retrieves data corresponding to a representative icon for the URL.
      • imageProvider

        @Nullable
        public @Nullable NSItemProvider imageProvider()
        An object that retrieves data corresponding to a representative image for the URL.
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
      • keyPathsForValuesAffectingValueForKey

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • originalURL

        @Nullable
        public @Nullable NSURL originalURL()
        The original URL of the metadata request.
      • remoteVideoURL

        @Nullable
        public @Nullable NSURL remoteVideoURL()
        A remote URL corresponding to a representative video for the URL. This may reference a remote video file that can stream, or a YouTube video URL.
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
      • setIconProvider

        public void setIconProvider​(@Nullable
                                    @Nullable NSItemProvider value)
        An object that retrieves data corresponding to a representative icon for the URL.
      • setImageProvider

        public void setImageProvider​(@Nullable
                                     @Nullable NSItemProvider value)
        An object that retrieves data corresponding to a representative image for the URL.
      • setOriginalURL

        public void setOriginalURL​(@Nullable
                                   @Nullable NSURL value)
        The original URL of the metadata request.
      • setRemoteVideoURL

        public void setRemoteVideoURL​(@Nullable
                                      @Nullable NSURL value)
        A remote URL corresponding to a representative video for the URL. This may reference a remote video file that can stream, or a YouTube video URL.
      • setTitle

        public void setTitle​(@Nullable
                             @Nullable java.lang.String value)
        A representative title for the URL.
      • setURL

        public void setURL​(@Nullable
                           @Nullable NSURL value)
        The URL that returned the metadata, taking server-side redirects into account. The URL that returns the metadata may differ from the ``LPLinkMetadata/originalURL`` to which you sent the metadata request. This can happen if the server redirects the request, for example, when a resource has moved, or when the original URL is a domain alias.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • setVideoProvider

        public void setVideoProvider​(@Nullable
                                     @Nullable NSItemProvider value)
        An object that retrieves data corresponding to a representative video for the URL. The item provider returns a video that can play.
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
      • supportsSecureCoding

        public static boolean supportsSecureCoding()
      • _supportsSecureCoding

        public boolean _supportsSecureCoding()
        Description copied from interface: NSSecureCoding
        This property must return YES on all classes that allow secure coding. Subclasses of classes that adopt NSSecureCoding and override initWithCoder: must also override this method and return YES. The Secure Coding Guide should be consulted when writing methods that decode data.
        Specified by:
        _supportsSecureCoding in interface NSSecureCoding
      • title

        @Nullable
        public @Nullable java.lang.String title()
        A representative title for the URL.
      • version_static

        public static long version_static()
      • videoProvider

        @Nullable
        public @Nullable NSItemProvider videoProvider()
        An object that retrieves data corresponding to a representative video for the URL. The item provider returns a video that can play.
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.