{"id":1756,"url":"https://github.com/marty-suzuki/URLEmbeddedView","last_synced_at":"2025-08-06T16:31:04.413Z","repository":{"id":42596828,"uuid":"53236277","full_name":"marty-suzuki/URLEmbeddedView","owner":"marty-suzuki","description":"URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.","archived":false,"fork":false,"pushed_at":"2020-01-11T05:30:03.000Z","size":7840,"stargazers_count":650,"open_issues_count":12,"forks_count":71,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-12-05T23:42:05.436Z","etag":null,"topics":["carthage","cocoapods","embedded","ios","ogp","swift","thumbnail","tvos","url"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marty-suzuki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-06T03:45:39.000Z","updated_at":"2024-07-14T05:00:24.000Z","dependencies_parsed_at":"2022-09-22T14:26:06.880Z","dependency_job_id":null,"html_url":"https://github.com/marty-suzuki/URLEmbeddedView","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FURLEmbeddedView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FURLEmbeddedView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FURLEmbeddedView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marty-suzuki%2FURLEmbeddedView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marty-suzuki","download_url":"https://codeload.github.com/marty-suzuki/URLEmbeddedView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923680,"owners_count":17992566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carthage","cocoapods","embedded","ios","ogp","swift","thumbnail","tvos","url"],"created_at":"2024-01-05T20:15:55.051Z","updated_at":"2024-12-09T16:30:58.897Z","avatar_url":"https://github.com/marty-suzuki.png","language":"Swift","funding_links":[],"categories":["Parsing","Libs","TableView","UI [🔝](#readme)"],"sub_categories":["Other Parsing","UI","Other free courses"],"readme":"# URLEmbeddedView\n\n[![Platform](http://img.shields.io/badge/platform-iOS%20|%20tvOS-blue.svg?style=flat)](https://developer.apple.com/iphone/index.action)\n[![Language](http://img.shields.io/badge/swift-5-orange.svg?style=flat)](https://developer.apple.com/swift)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Version](https://img.shields.io/cocoapods/v/URLEmbeddedView.svg?style=flat)](http://cocoapods.org/pods/URLEmbeddedView)\n[![License](https://img.shields.io/cocoapods/l/URLEmbeddedView.svg?style=flat)](http://cocoapods.org/pods/URLEmbeddedView)\n\n![](./Images/sample2.gif) ![](./Images/sample.gif)\n\n\n## Features\n\n- [x] Simple interface for fetching Open Graph Data\n- [x] Be able to display Open Graph Data\n- [x] Automatically caching Open Graph Data\n- [x] Automatically caching Open Graph Image\n- [x] Tap handleable\n- [x] Clearable image cache\n- [x] Clearable data cache\n- [x] Support Swift3.2 (until 0.11.x)\n- [x] Supprot Swift4.x (until 0.17.1)\n- [x] Support Swift5 (since 0.18.0)\n- [x] Support Carthage since 0.11.1\n- [x] Support tvOS since 0.16.0\n- [x] Custom implementation of OGData cache\n\n## Usage\n\nTo run the example project, clone the repo, and run `carthage update` from the Example directory first.\n\n```swift\nlet embeddedView = URLEmbeddedView()\nembeddedView.loadURL(urlString)\n```\n\n## Layouts\n\n- Default\n\n\u003cimg src=\"Images/sample01.png\" width=\"320\"\u003e\n\n- No Image\n\n\u003cimg src=\"Images/sample03.png\" width=\"320\"\u003e\n\n- No response\n\n\u003cimg src=\"Images/sample02.png\" width=\"320\"\u003e\n\n## Customization\n\n```swift\nembeddedView.textProvider[.Title].font = .boldSystemFontOfSize(18)\nembeddedView.textProvider[.Title].fontColor = .lightGrayColor()\nembeddedView.textProvider[.Title].numberOfLines = 2\n//You can use \".Title\", \".Description\", \".Domain\" and \".NoDataTitle\"\n```\n\n## Data and Image Cache\n\nYou can get Open Graph Data with `OGDataProvider`.\n\n```swift\nOGDataProvider.shared.fetchOGData(urlString: String, completion: ((OpenGraph.Data, Error?) -\u003e Void)? = nil) -\u003e String?\nOGDataProvider.shared.deleteOGData(urlString: String, completion: ((Error?) -\u003e Void)? = nil)\nOGDataProvider.shared.deleteOGData(_ ogData: OpenGraph.Data, completion: ((Error?) -\u003e Void)? = nil)\n```\n\nYou can configure time interval for next updating of OGData.\nDefault is 10 days.\n\n```swift\nOGDataProvider.shared.updateInterval = 10.days\n```\n\nYou can get UIImage with `OGImageProvider`.\n\n```swift\nOGImageProvider.shared.loadImage(urlString: String, completion: ((UIImage?, Error?) -\u003e Void)? = nil) -\u003e NSURLSessionDataTask?\nOGImageProvider.shared.clearMemoryCache()\nOGImageProvider.shared.clearAllCache()\n```\n\n### Custom Data Cache implementation\n\nDefault cache feature is using Core Data.\nIf you want to use other cache features, please implement cache manager with `OGDataCacheManagerProtocol`.\nFor example, URLEmbeddedView has `OGDataNoCacheManager` that feature is not using cache.\nIf you want to use that feature, you can use like this.\n\n```swift\nOGDataProvider.shared.cacheManager = OGDataNoCacheManager()\n```\n\nYou can implement custom cache feature and use it like this.\n\n```swift\nclass MemoryCacheManager: OGDataCacheManagerProtocol {\n    // implementation of required methods\n}\n\nOGDataProvider.shared.cacheManager = MemoryCacheManager()\n```\n\n## OpenGraph.Data Properties\n\n```swift\npublic let imageUrl: URL?\npublic let pageDescription: String?\npublic let pageTitle: String?\npublic let pageType: String?\npublic let siteName: String?\npublic let sourceUrl: URL?\npublic let url: URL?\n```\n\n## OpenGraphDataDownloader\n\nYou can only use download feature of OGData with `OpenGraphDataDownloader` like this.\n\n```swift\nlet urlString = ...\nOpenGraphDataDownloader.shared.fetchOGData(urlString: urlString) { result in\n    switch result {\n    case let .success(data, isExpired):\n        // do something\n    case let .failure(error, isExpired):\n        // do something\n    }\n}\n```\n\nIf you use `OGDataProvider` with `OGDataNoCacheManager`, it is almost same process.\n\n```swift\nOGDataProvider.shared.cacheManager = OGDataNoCacheManager()\nlet urlString = ...\nOGDataProvider.shared.fetchOGData(urlString: urlString) { ogData, error in\n    // do something\n}\n```\n\n## Installation\n\n#### CocoaPods\n\nURLEmbeddedView is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\n# Uncomment the next line to define a global platform for your project\n# platform :ios, '8.0'\n\ntarget 'Your Project Name' do\n  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks\n  use_frameworks!\n\n  # Pods for URLEmbeddedViewSample\n  pod \"URLEmbeddedView\"\nend\n```\n\n#### Carthage\n\nIf you’re using [Carthage](https://github.com/Carthage/Carthage), simply add\nNoticeObserveKit to your `Cartfile`:\n\n```ruby\ngithub \"marty-suzuki/URLEmbeddedView\"\n```\n\n## Use in Objective-C\n\n```objective-c\n#import \u003cURLEmbeddedView/URLEmbeddedView-Swift.h\u003e\n\n- (void)viewDidLoad {\n    [super viewDidLoad];\n    URLEmbeddedView *embeddedView = [[URLEmbeddedView alloc] init];\n    [self.view addSubView:embeddedView];\n    [embeddedView loadURL:@\"https://github.com/\" completion:nil];\n}\n\n- (void)setUpdateInterval {\n  [OGDataProvider sharedInstance].updateInterval = [NSNumber days:10];\n}\n\n- (void)fetchOpenGraphData {\n  [[OGDataProvider sharedInstance] fetchOGDataWithUrlString:self.textView.text\n                                            completion:^(OpenGraphData *data, NSError *error) {\n      NSLog(@\"OpenGraphData = %@\", data);\n  }];\n}\n```\n\n[Here](./Example/URLEmbeddedViewSample/OGObjcSampleViewController.m) is Objective-C sample.\n\n## Special Thanks\n\n- [CryptoSwift](https://github.com/krzyzanowskim/CryptoSwift) is a greate Crypto related functions and helpers for Swift. (Created by [@krzyzanowskim](https://github.com/krzyzanowskim))\n\n## Requirements\n\n- Xcode 10.2 or greater\n- iOS 8.0 or greater\n- tvOS 10.0 or greater\n- UIKit\n- CoreData\n- CoreGraphics\n\n## Other\n\n- [MisterFusion](https://github.com/szk-atmosphere/MisterFusion) - Swift DSL for AutoLayout\n- [NoticeObserveKit](https://github.com/marty-suzuki/NoticeObserveKit) (type-safe NotificationCenter wrapper) is used in this sample.\n- Android version is [here](https://github.com/kaelaela/OpenGraphView). (Created by [@kaelaela](https://github.com/kaelaela))\n\n## Author\n\nTaiki Suzuki, s1180183@gmail.com\n\n## License\n\nURLEmbeddedView is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarty-suzuki%2FURLEmbeddedView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarty-suzuki%2FURLEmbeddedView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarty-suzuki%2FURLEmbeddedView/lists"}