{"id":19318945,"url":"https://github.com/ky1vstar/custombrowserkit","last_synced_at":"2025-02-24T05:11:40.034Z","repository":{"id":31083338,"uuid":"126684009","full_name":"ky1vstar/CustomBrowserKit","owner":"ky1vstar","description":"Let your users open links in their favorite browser","archived":false,"fork":false,"pushed_at":"2022-05-13T13:11:49.000Z","size":347,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T06:04:22.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","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/ky1vstar.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":"2018-03-25T09:54:45.000Z","updated_at":"2020-03-07T16:55:38.000Z","dependencies_parsed_at":"2022-08-09T03:30:23.681Z","dependency_job_id":null,"html_url":"https://github.com/ky1vstar/CustomBrowserKit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ky1vstar%2FCustomBrowserKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ky1vstar%2FCustomBrowserKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ky1vstar%2FCustomBrowserKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ky1vstar%2FCustomBrowserKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ky1vstar","download_url":"https://codeload.github.com/ky1vstar/CustomBrowserKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240420982,"owners_count":19798502,"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":[],"created_at":"2024-11-10T01:20:21.743Z","updated_at":"2025-02-24T05:11:40.004Z","avatar_url":"https://github.com/ky1vstar.png","language":"Objective-C","readme":"# CustomBrowserKit\n\n[![CI Status](http://img.shields.io/travis/ky1vstar/CustomBrowserKit.svg?style=flat)](https://travis-ci.org/ky1vstar/CustomBrowserKit)\n[![Version](https://img.shields.io/cocoapods/v/CustomBrowserKit.svg?style=flat)](http://cocoapods.org/pods/CustomBrowserKit)\n[![License](https://img.shields.io/cocoapods/l/CustomBrowserKit.svg?style=flat)](http://cocoapods.org/pods/CustomBrowserKit)\n[![Platform](https://img.shields.io/cocoapods/p/CustomBrowserKit.svg?style=flat)](http://cocoapods.org/pods/CustomBrowserKit)\n\nCustomBrowserKit is a library designed to provide ability to open links in browser besides Safari to your awesome app's users. It is written in Objective-C and extended with Swift.\n\n## Supported browsers\n\nCustomBrowserKit currently supports:\n\n* [Google Chrome](https://itunes.apple.com/app/id535886823)\n* [Firefox](https://itunes.apple.com/app/id989804926)\n* [Opera Mini](https://itunes.apple.com/app/id363729560)\n* [UC Browser](https://itunes.apple.com/app/id1048518592)\n* [Puffin Web Browser](https://itunes.apple.com/app/id472937654)\n* [Yandex Browser](https://itunes.apple.com/app/id483693909)\n* Opening links in `SFSafariViewController` if iOS version is 9.0+\n* Safari\n\n## Requirements\n\n* Xcode 8.0+\n* iOS 8.0+\n* Swift 3.1+\n\n## Installation\n\nCustomBrowserKit is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'CustomBrowserKit'\n```\n\nAlso, starting with iOS 9.0 you must declare the URL schemes of external apps you want to launch. There are only two available browsers you can use without declaring appropriate URL schemes: `BKBrowserInAppSafari` and `BKBrowserSafari`. So if you want to use another browsers you must add the [LSApplicationQueriesSchemes](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/plist/info/LSApplicationQueriesSchemes) key to your app's Info.plist file. You are not required to add all of this schemes below, only those you want to let your users to use. But it is important to add BOTH schemes for browsers which have two of them. For example if you want to use Google Chrome, you have to declare both `googlechrome` and `googlechromes` URL schemes.\n\n\n\n| Browser            | URL Schemes                         |\n|--------------------|-------------------------------------|\n| Google Chrome      | `googlechrome`\u003cbr /\u003e`googlechromes` |\n| Firefox            | `firefox`                           |\n| Opera              | `opera`                             |\n| UC Browser         | `ucbrowser`                         |\n| Puffin Web Browser | `puffin`\u003cbr /\u003e`puffins`             |\n| Yandex Browser     | `yandexbrowser-open-url`            |\n\n## Usage\n\nMake sure to import the framework header: `#import \u003cCustomBrowserKit/CustomBrowserKit.h\u003e` for Objective-C or `import CustomBrowserKit` for Swift.\n\n### Obtaining information about browser\n**Objective-C**\n```objectivec\nBKBrowser browser = BKBrowserFirefox;\nNSString *browserName = BKBrowserGetName(browser); // @\"Firefox\"\nUIImage *browserLogo = BKBrowserGetThumbnail(browser); // UIImage of size 100x100\n```\n\n**Swift**\n```swift\nlet browser = BKBrowser.firefox\nlet browserName = browser.name // \"Firefox\"\nlet browserLogo = browser.thumbnail // UIImage of size 100x100\n```\n\n### Obtaining list of available browsers\n**Objective-C**\n```objectivec\nfor (NSNumber *wrappedBrowser in BKManager.availableBrowsers) {\nBKBrowser browser = (BKBrowser)wrappedBrowser.intValue;\n    NSLog(@\"%@ is available\", BKBrowserGetName(browser));\n}\n```\n\n**Swift**\n```swift\nfor browser in BKManager.availableBrowsers {\n    print(\"\\(browser.name) is available\")\n}\n```\n\n### Opening links in specific browser\n**Objective-C**\n```objectivec\nNSURL *url = [NSURL URLWithString:@\"https://google.com/\"];\n\nif ([BKManager openURL:url withBrowser:BKBrowserOpera]) {\n    NSLog(@\"did open url successfully\");\n} else {\n    NSLog(@\"did fail to open url\");\n}\n```\n\n**Swift**\n```swift\nlet url = URL(string: \"https://google.com/\")!\n\nif BKManager.open(url, with: .opera) {\n    print(\"did open url successfully\")\n} else {\n    print(\"did fail to open url\")\n}\n```\n\n### Opening links in specific browser with fallback to another browser if needed\n**Objective-C**\n```objectivec\nNSURL *url = [NSURL URLWithString:@\"https://google.com/\"];\n\n// BKManager will try to open URL in Opera. If Opera Mini turns out to not be installed or available, BKManager will try to open URL in Google Chrome.\nif ([BKManager openURL:url withBrowser:BKBrowserOpera fallbackToBrowser:BKBrowserChrome]) {\n    NSLog(@\"did open url successfully\");\n} else { // if both Opera Mini and Google Chrome are not available\n    NSLog(@\"did fail to open url\");\n}\n```\n\n**Swift**\n```swift\nlet url = URL(string: \"https://google.com/\")!\n\n// BKManager will try to open URL in Opera. If Opera Mini turns out to not be installed or available, BKManager will try to open URL in Google Chrome.\nif BKManager.open(url, with: .opera, fallbackTo: .chrome) {\n    print(\"did open url successfully\")\n} else { // if both Opera Mini and Google Chrome are not available\n    print(\"did fail to open url\")\n}\n```\n\n### Saving `BKBrowser` to `NSUserDefaults`\n**Objective-C**\n```objectivec\nBKBrowser browser = BKBrowserUCBrowser;\nNSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;\n\n// saving\n[userDefaults setObject:BKBrowserGetIdentifier(browser) forKey:@\"savedBrowser\"];\n\n// restoring\nNSString *browserIdentifier = [userDefaults stringForKey:@\"savedBrowser\"];\nBKBrowser savedBrowser;\nif (browserIdentifier) {\n    savedBrowser = BKBrowserFromIdentifier(browserIdentifier);\n} else {\n    savedBrowser = BKBrowserInAppSafari;\n}\n```\n\n**Swift**\n```swift\nlet browser = BKBrowser.ucBrowser\nlet userDefault = UserDefaults.standard\n\n// saving\nuserDefault.set(browser.identifier, forKey: \"savedBrowser\")\n\n// restoring\nlet savedBrowser: BKBrowser\nif let browserIdentifier = userDefault.string(forKey: savedBrowser) {\n    savedBrowser = BKBrowser(identifier: browserIdentifier)\n} else {\n    savedBrowser = .inAppSafari\n}\n```\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first. Example project includes both Objective-C and Swift versions.\n\n## License\n\nCustomBrowserKit is available under the MIT license. See the LICENSE file for more info.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fky1vstar%2Fcustombrowserkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fky1vstar%2Fcustombrowserkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fky1vstar%2Fcustombrowserkit/lists"}