LinkPreviewCustomAction
Custom iOS 9 preview actions for link previews in iOS webviews
Install / Use
/learn @Instapaper/LinkPreviewCustomActionREADME
LinkPreviewCustomActions
In iOS 9, UIWebView and WKWebView can support 3D touches on links to preview the linked URL with SFSafariViewController by setting the allowsLinkPreview to YES on the web view. However, there isn't currently a way to provide a set of custom actions to SFSafariViewController and, as such, the UIPreviewActionItem list is always "Open", "Add to Reading List", and "Copy".
This project is a proof-of-concept to provide custom UIPreviewActionItems to link previews using SFSafariViewController. The approach is somewhat convoluted because the hooks for previewing the link are within the web views, and the developer is never given hooks to provide their own data. The solution is to create a category on SFSafariViewController, override - (NSArray<id<UIPreviewActionItem>> *)previewActionItems instance method, and pull the URL from the SFSafariViewController's delegate. The SFSafariViewControllerDelegate is an instance of DDURLPreviewAction, which responds to @selector(url). The code is written in such a way to not use private APIs, and fail gracefully should the internal workings change in a future release.
Here's a screenshot of the result:

Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
