takeSnapshot(using:for:completionHandler:)
Called to capture a snapshot of the current webpage as an image.
Declaration
optional func takeSnapshot(using configuration: WKSnapshotConfiguration, for context: WKWebExtensionContext, completionHandler: @escaping (UIImage?, (any Error)?) -> Void)optional func snapshot(using configuration: WKSnapshotConfiguration, for context: WKWebExtensionContext) async throws -> UIImage?optional func takeSnapshot(using configuration: WKSnapshotConfiguration, for context: WKWebExtensionContext, completionHandler: @escaping (NSImage?, (any Error)?) -> Void)optional func snapshot(using configuration: WKSnapshotConfiguration, for context: WKWebExtensionContext) async throws -> NSImage?Parameters
- configuration:
An object that specifies how the snapshot is configured.
- context:
The context in which the web extension is running.
- completionHandler:
A block that must be called upon completion. The block takes two arguments: the captured image of the webpage (or
nilif capturing failed) and an error, which should be provided if any errors occurred.
Discussion
Defaults to capturing the visible area of the tab’s web view if not implemented.