All Projects → marty-suzuki → Urlembeddedview

marty-suzuki / Urlembeddedview

Licence: mit
URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Urlembeddedview

Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+92.1%)
Mutual labels:  url, tvos, cocoapods, carthage
Sablurimageview
You can use blur effect and it's animation easily to call only two methods.
Stars: ✭ 538 (-15.01%)
Mutual labels:  tvos, cocoapods, carthage
Gradientview
Easily use gradients in UIKit for iOS & tvOS
Stars: ✭ 610 (-3.63%)
Mutual labels:  tvos, cocoapods, carthage
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (-16.75%)
Mutual labels:  tvos, cocoapods, carthage
Theanimation
Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.
Stars: ✭ 214 (-66.19%)
Mutual labels:  tvos, cocoapods, carthage
Amplitude Ios
Native iOS/tvOS/macOS SDK
Stars: ✭ 216 (-65.88%)
Mutual labels:  tvos, cocoapods, carthage
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: ✭ 254 (-59.87%)
Mutual labels:  tvos, cocoapods, carthage
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (-52.29%)
Mutual labels:  tvos, cocoapods, carthage
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-53.4%)
Mutual labels:  tvos, cocoapods, carthage
Jgprogresshud
An elegant and simple progress HUD for iOS and tvOS, compatible with Swift and ObjC.
Stars: ✭ 3,110 (+391.31%)
Mutual labels:  tvos, cocoapods, carthage
Anim
Swift animation library for iOS, tvOS and macOS.
Stars: ✭ 520 (-17.85%)
Mutual labels:  tvos, cocoapods, carthage
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+486.1%)
Mutual labels:  tvos, cocoapods, carthage
Iso8601
ISO8601 date parser and writer
Stars: ✭ 213 (-66.35%)
Mutual labels:  tvos, cocoapods, carthage
Appz
📱 Launch external apps, and deeplink, with ease using Swift!
Stars: ✭ 1,092 (+72.51%)
Mutual labels:  url, cocoapods, carthage
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-72.04%)
Mutual labels:  tvos, cocoapods, carthage
Cocoalumberjack
A fast & simple, yet powerful & flexible logging framework for Mac and iOS
Stars: ✭ 12,584 (+1887.99%)
Mutual labels:  tvos, cocoapods, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-75.04%)
Mutual labels:  tvos, cocoapods, carthage
Svprogresshud
A clean and lightweight progress HUD for your iOS and tvOS app.
Stars: ✭ 12,339 (+1849.29%)
Mutual labels:  tvos, cocoapods, carthage
Audioindicatorbars
AIB indicates for your app users which audio is playing. Just like the Podcasts app.
Stars: ✭ 279 (-55.92%)
Mutual labels:  tvos, cocoapods, carthage
Misterfusion
MisterFusion is Swift DSL for AutoLayout. It is the extremely clear, but concise syntax, in addition, can be used in both Swift and Objective-C. Support Safe Area and Size Class.
Stars: ✭ 314 (-50.39%)
Mutual labels:  tvos, cocoapods, carthage

URLEmbeddedView

Platform Language Carthage compatible Version License

Features

  • [x] Simple interface for fetching Open Graph Data
  • [x] Be able to display Open Graph Data
  • [x] Automatically caching Open Graph Data
  • [x] Automatically caching Open Graph Image
  • [x] Tap handleable
  • [x] Clearable image cache
  • [x] Clearable data cache
  • [x] Support Swift3.2 (until 0.11.x)
  • [x] Supprot Swift4.x (until 0.17.1)
  • [x] Support Swift5 (since 0.18.0)
  • [x] Support Carthage since 0.11.1
  • [x] Support tvOS since 0.16.0
  • [x] Custom implementation of OGData cache

Usage

To run the example project, clone the repo, and run carthage update from the Example directory first.

let embeddedView = URLEmbeddedView()
embeddedView.loadURL(urlString)

Layouts

  • Default
  • No Image
  • No response

Customization

embeddedView.textProvider[.Title].font = .boldSystemFontOfSize(18)
embeddedView.textProvider[.Title].fontColor = .lightGrayColor()
embeddedView.textProvider[.Title].numberOfLines = 2
//You can use ".Title", ".Description", ".Domain" and ".NoDataTitle"

Data and Image Cache

You can get Open Graph Data with OGDataProvider.

OGDataProvider.shared.fetchOGData(urlString: String, completion: ((OpenGraph.Data, Error?) -> Void)? = nil) -> String?
OGDataProvider.shared.deleteOGData(urlString: String, completion: ((Error?) -> Void)? = nil)
OGDataProvider.shared.deleteOGData(_ ogData: OpenGraph.Data, completion: ((Error?) -> Void)? = nil)

You can configure time interval for next updating of OGData. Default is 10 days.

OGDataProvider.shared.updateInterval = 10.days

You can get UIImage with OGImageProvider.

OGImageProvider.shared.loadImage(urlString: String, completion: ((UIImage?, Error?) -> Void)? = nil) -> NSURLSessionDataTask?
OGImageProvider.shared.clearMemoryCache()
OGImageProvider.shared.clearAllCache()

Custom Data Cache implementation

Default cache feature is using Core Data. If you want to use other cache features, please implement cache manager with OGDataCacheManagerProtocol. For example, URLEmbeddedView has OGDataNoCacheManager that feature is not using cache. If you want to use that feature, you can use like this.

OGDataProvider.shared.cacheManager = OGDataNoCacheManager()

You can implement custom cache feature and use it like this.

class MemoryCacheManager: OGDataCacheManagerProtocol {
    // implementation of required methods
}

OGDataProvider.shared.cacheManager = MemoryCacheManager()

OpenGraph.Data Properties

public let imageUrl: URL?
public let pageDescription: String?
public let pageTitle: String?
public let pageType: String?
public let siteName: String?
public let sourceUrl: URL?
public let url: URL?

OpenGraphDataDownloader

You can only use download feature of OGData with OpenGraphDataDownloader like this.

let urlString = ...
OpenGraphDataDownloader.shared.fetchOGData(urlString: urlString) { result in
    switch result {
    case let .success(data, isExpired):
        // do something
    case let .failure(error, isExpired):
        // do something
    }
}

If you use OGDataProvider with OGDataNoCacheManager, it is almost same process.

OGDataProvider.shared.cacheManager = OGDataNoCacheManager()
let urlString = ...
OGDataProvider.shared.fetchOGData(urlString: urlString) { ogData, error in
    // do something
}

Installation

CocoaPods

URLEmbeddedView is available through CocoaPods. To install it, simply add the following line to your Podfile:

# Uncomment the next line to define a global platform for your project
# platform :ios, '8.0'

target 'Your Project Name' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for URLEmbeddedViewSample
  pod "URLEmbeddedView"
end

Carthage

If you’re using Carthage, simply add NoticeObserveKit to your Cartfile:

github "marty-suzuki/URLEmbeddedView"

Use in Objective-C

#import <URLEmbeddedView/URLEmbeddedView-Swift.h>

- (void)viewDidLoad {
    [super viewDidLoad];
    URLEmbeddedView *embeddedView = [[URLEmbeddedView alloc] init];
    [self.view addSubView:embeddedView];
    [embeddedView loadURL:@"https://github.com/" completion:nil];
}

- (void)setUpdateInterval {
  [OGDataProvider sharedInstance].updateInterval = [NSNumber days:10];
}

- (void)fetchOpenGraphData {
  [[OGDataProvider sharedInstance] fetchOGDataWithUrlString:self.textView.text
                                            completion:^(OpenGraphData *data, NSError *error) {
      NSLog(@"OpenGraphData = %@", data);
  }];
}

Here is Objective-C sample.

Special Thanks

Requirements

  • Xcode 10.2 or greater
  • iOS 8.0 or greater
  • tvOS 10.0 or greater
  • UIKit
  • CoreData
  • CoreGraphics

Other

Author

Taiki Suzuki, [email protected]

License

URLEmbeddedView is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].