wireapp/wire-ios-link-preview

Name: wire-ios-link-preview

Owner: Wire Swiss GmbH

Description: ? Open Graph data parser used to generate link previews

Created: 2016-07-21 09:40:14.0

Updated: 2018-05-15 16:16:40.0

Pushed: 2018-05-15 16:16:39.0

Homepage: https://wire.com

Size: 312

Language: Swift

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Wire?

Wire logo

CircleCI codecov

This repository is part of the source code of Wire. You can find more information at wire.com or by contacting opensource@wire.com.

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://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.

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

d detector.containsLink(inText: text) else { return }
ctor.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 Article or TwitterStatus, 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.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.