{"id":1621,"url":"https://github.com/Isuru-Nanayakkara/Reach","last_synced_at":"2025-08-02T04:31:55.105Z","repository":{"id":20314961,"uuid":"23589017","full_name":"Isuru-Nanayakkara/Reach","owner":"Isuru-Nanayakkara","description":"A simple class to check for internet connection availability in Swift.","archived":true,"fork":false,"pushed_at":"2019-07-26T16:54:10.000Z","size":41,"stargazers_count":455,"open_issues_count":11,"forks_count":119,"subscribers_count":26,"default_branch":"master","last_synced_at":"2024-12-06T08:34:46.475Z","etag":null,"topics":["ios","reachability","swift"],"latest_commit_sha":null,"homepage":null,"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/Isuru-Nanayakkara.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":"2014-09-02T17:47:07.000Z","updated_at":"2024-12-02T08:44:28.000Z","dependencies_parsed_at":"2022-09-01T00:22:22.407Z","dependency_job_id":null,"html_url":"https://github.com/Isuru-Nanayakkara/Reach","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Isuru-Nanayakkara/Reach","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isuru-Nanayakkara%2FReach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isuru-Nanayakkara%2FReach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isuru-Nanayakkara%2FReach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isuru-Nanayakkara%2FReach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Isuru-Nanayakkara","download_url":"https://codeload.github.com/Isuru-Nanayakkara/Reach/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Isuru-Nanayakkara%2FReach/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334614,"owners_count":24233793,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ios","reachability","swift"],"created_at":"2024-01-05T20:15:51.597Z","updated_at":"2025-08-02T04:31:54.824Z","avatar_url":"https://github.com/Isuru-Nanayakkara.png","language":"Swift","funding_links":[],"categories":["Networking","Libs"],"sub_categories":["Video","Other free courses","Network"],"readme":"Reach\n==================\n\nA simple class to check for internet connection availability in Swift. Works for both 3G and WiFi connections.\n\n\n## Install\n\n##### Manually\n- Add the _Reach.swift_ file to your project.\n\n\n## Usage\nThere are two ways to get network status information from Reach.\n\n1. Call `Reach().connectionStatus()`. The network status is returned in an enum called `ReachabilityStatus`.\n\n```swift\nlet status = Reach().connectionStatus()\n\nswitch status {\ncase .unknown, .offline:\n    print(\"Not connected\")\ncase .online(.wwan):\n    print(\"Connected via WWAN\")\ncase .online(.wiFi):\n    print(\"Connected via WiFi\")\n}\n```\n\n2. By subscribing to `ReachabilityStatusChangedNotification`s. The network status is returned as a string.\n\n```swift\noverride func viewDidLoad() {\n    super.viewDidLoad()\n    \n    NotificationCenter.default.addObserver(self, selector: #selector(ViewController.networkStatusChanged(_:)), name: Notification.Name(rawValue: ReachabilityStatusChangedNotification), object: nil)\n    \n    Reach().monitorReachabilityChanges()\n}\n\n@objc func networkStatusChanged(_ notification: Notification) {\n    if let userInfo = notification.userInfo {\n        let status = userInfo[\"Status\"] as! String\n        print(status)\n    }\n    \n}\n```\n\n\n## ToDo\n- [ ] Return storngly typed object containing more information about the network status.\n\n## Credits\n\n* [Chris Danielson](http://www.chrisdanielson.com/2009/07/22/iphone-network-connectivity-test-example/) is the author of the original code written in Objective-C.\n* [Martin R](http://stackoverflow.com/users/1187415/martin-r) from StackOverflow helped me immensely in converting C code to Swift.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIsuru-Nanayakkara%2FReach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIsuru-Nanayakkara%2FReach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIsuru-Nanayakkara%2FReach/lists"}