Class LPMetadataProvider

  • All Implemented Interfaces:
    NSObject

    public class LPMetadataProvider
    extends NSObject
    An object that retrieves metadata for a URL. Use ``LPMetadataProvider`` to fetch metadata for a URL, including its title, icon, and image or video links. All properties on the resulting ``LPLinkMetadata`` instance are optional. - Note: To enable macOS clients to fetch metadata for remote URLs, add the entitlement. ## Fetch link metadata from a URL For each metadata request, create an instance of ``LPMetadataProvider`` and call ``LPMetadataProvider/startFetchingMetadataForURL:completionHandler:``. In the completion handler, check the error. If your user doesn’t have a network connection, the fetch can fail. If the server doesn’t respond or is too slow, the fetch can time out. Alternatively, the app may cancel the request, or an unknown error may occur. Otherwise, use the metadata however you want, for example, to populate the title for a table view cell. ```swift let metadataProvider = LPMetadataProvider() let url = URL(string: "https://www.apple.com/ipad")! metadataProvider.startFetchingMetadata(for: url) { metadata, error in if error != nil { // The fetch failed; handle the error. return } // Make use of fetched metadata. } ``` For more information about handling errors, see ``LinkPresentation/LPError``. API-Since: 13.0
    • Constructor Detail

      • LPMetadataProvider

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

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • allocWithZone

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

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

        public void cancel()
        Cancels a metadata request. This method invokes the completion handler with the error code ``LPErrorCode/LPErrorMetadataFetchCancelled`` if the request hasn’t already completed.
      • 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()
      • 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()
      • 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)
      • resolveClassMethod

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

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

        public void setShouldFetchSubresources​(boolean value)
        A Boolean value indicating whether to download subresources specified by the metadata. Subresources include the icon, image, or video. When set to `false`, the returned ``LPLinkMetadata`` object consists only of metadata retrieved from the main resource identified by the url passed to ``LPMetadataProvider/startFetchingMetadataForURL:completionHandler:``. The default value is `true`.
      • setTimeout

        public void setTimeout​(double value)
        The time interval after which the request automatically fails if it hasn’t already completed. The default timeout interval is 30 seconds. If a metadata fetch takes longer than the timeout interval, the completion handler is called with the error code ``LPErrorCode/LPErrorMetadataFetchTimedOut``.
      • setVersion_static

        public static void setVersion_static​(long aVersion)
      • shouldFetchSubresources

        public boolean shouldFetchSubresources()
        A Boolean value indicating whether to download subresources specified by the metadata. Subresources include the icon, image, or video. When set to `false`, the returned ``LPLinkMetadata`` object consists only of metadata retrieved from the main resource identified by the url passed to ``LPMetadataProvider/startFetchingMetadataForURL:completionHandler:``. The default value is `true`.
      • startFetchingMetadataForURLCompletionHandler

        public void startFetchingMetadataForURLCompletionHandler​(@NotNull
                                                                 @NotNull NSURL URL,
                                                                 @NotNull
                                                                 @NotNull LPMetadataProvider.Block_startFetchingMetadataForURLCompletionHandler completionHandler)
        Fetches metadata for the given URL. Call this method once per ``LPMetadataProvider`` instance. If you attempt to fetch metadata multiple times on a single ``LPMetadataProvider`` instance, it throws an error. The completion handler executes on a background queue. Dispatch any necessary UI updates back to the main queue. When the completion handler returns, it deletes any file URLs returned in the resulting ``LPLinkMetadata``. > Concurrency Note: You can call this method from synchronous code using a completion handler, > as shown on this page, or you can call it as an asynchronous method that has the > following declaration: > > ```swift > func startFetchingMetadata(for url: URL) async throws -> LPLinkMetadata > ``` > > For information about concurrency and asynchronous code in Swift, see .
      • superclass_static

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

        public double timeout()
        The time interval after which the request automatically fails if it hasn’t already completed. The default timeout interval is 30 seconds. If a metadata fetch takes longer than the timeout interval, the completion handler is called with the error code ``LPErrorCode/LPErrorMetadataFetchTimedOut``.
      • version_static

        public static long version_static()
      • startFetchingMetadataForRequestCompletionHandler

        public void startFetchingMetadataForRequestCompletionHandler​(@NotNull
                                                                     @NotNull NSURLRequest request,
                                                                     @NotNull
                                                                     @NotNull LPMetadataProvider.Block_startFetchingMetadataForRequestCompletionHandler completionHandler)
        Fetches metadata for the given ``NSURLRequest``. Call this method once per ``LPMetadataProvider`` instance. If you attempt to fetch metadata multiple times on a single ``LPMetadataProvider`` instance, it throws an error. The completion handler executes on a background queue. Dispatch any necessary UI updates back to the main queue. When the completion handler returns, it deletes any file URLs returned in the resulting ``LPLinkMetadata``. > Concurrency Note: You can call this method from synchronous code using a completion handler, > as shown on this page, or you can call it as an asynchronous method that has the > following declaration: > > ```swift > func startFetchingMetadata(for request: URLRequest) async throws -> LPLinkMetadata > ``` > > For information about concurrency and asynchronous code in Swift, see . API-Since: 15.0
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.