Skip to content

🏷 Open Graph data parser used to generate link previews

License

Notifications You must be signed in to change notification settings

johnxnguyen/wire-ios-link-preview

 
 

Repository files navigation

Wire™

Wire logo

Build Status codecov

This repository is part of the source code of Wire. You can find more information at wire.com or by contacting [email protected].

You can find the published source code at github.com/wireapp/wire.

For licensing information, see the attached LICENSE file and the list of third-party licenses at wire.com/legal/licenses/.

WireLinkPreview

This framework is part of Wire iOS. Additional documentation is available in the Wire iOS wiki.

WireLinkPreview is a Swift framework that can be used to fetch and parse Open Graph data that is present on most webpages (see http:https://ogp.me/ for more information and https://developers.facebook.com/tools/debug/sharing to debug open graph data).

How to build

This framework is using Carthage to manage its dependencies. To pull the dependencies binaries, run carthage bootstrap --platform ios.

You can now open the Xcode project and build.

Usage:

Consumers of this framework should mostly interact with the LinkPreviewDetector type, it can be used to check if a given text contains a link using the containsLink:inText method and if it does it can be used to download the previews asynchronously using downloadLinkPreviews:inText:completion.

let text = "Text containing a link to your awesome tweet"
let detector = LinkPreviewDetector(resultsQueue: .main)

guard detector.containsLink(inText: text) else { return }
detector.downloadLinkPreviews(inText: text) { previews in
    // Do something with the previews
}

A call to this method will also download the images specified in the Open Graph data. The completion returns an array of LinkPreview objects which currently are either of type ArticleMetadata or TwitterStatusMetadata, while the count of elements in the array is also limited to one at for now. Note, use the delegate LinkPreviewDetectorDelegate to control which which detected links will have their preview generated.

About

🏷 Open Graph data parser used to generate link previews

https://wire.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.8%
  • Shell 1.6%
  • Objective-C 0.6%