{"id":21623263,"url":"https://github.com/przemek-jablonski/earendil","last_synced_at":"2025-04-11T11:23:07.007Z","repository":{"id":47489031,"uuid":"398401286","full_name":"przemek-jablonski/Earendil","owner":"przemek-jablonski","description":"Fetch user location without asking for permission 👺. All  platforms.","archived":false,"fork":false,"pushed_at":"2023-06-08T14:35:15.000Z","size":900,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T07:41:40.321Z","etag":null,"topics":["apple","geolocation","ios","location","macos","multiplatform","swift"],"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/przemek-jablonski.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-20T21:11:46.000Z","updated_at":"2024-08-12T04:13:34.000Z","dependencies_parsed_at":"2024-11-25T09:04:15.643Z","dependency_job_id":null,"html_url":"https://github.com/przemek-jablonski/Earendil","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemek-jablonski%2FEarendil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemek-jablonski%2FEarendil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemek-jablonski%2FEarendil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemek-jablonski%2FEarendil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/przemek-jablonski","download_url":"https://codeload.github.com/przemek-jablonski/Earendil/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248382177,"owners_count":21094544,"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":["apple","geolocation","ios","location","macos","multiplatform","swift"],"created_at":"2024-11-25T00:12:10.448Z","updated_at":"2025-04-11T11:23:06.957Z","avatar_url":"https://github.com/przemek-jablonski.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Earendil\n\nSwift Package for fetching approximate user location without asking for their permission 👺.\n\nGet their country, subregion or continent with one method call. This includes country names, their coordinates and even `MKCoordinateRegion` property, instantly usable with your `MapKit` views. Perfect for setting your Map's location for the first time, if you don't need GPS permission otherwise.\n\n100% App Store safe, no-private APIs used.\n\u003c/br\u003e\n\n## Usage\n\nGet the location at any time:\n```swift\nlet userLocation = Earendil.inferredLocation\n\nuserLocation.country.name // \"United States of America\"\nuserLocation.country.region.center // (37.09, -95.7)\nuserLocation.country.region.span // (60, 60)\n```\n\nUse the inferred location for your needs:\n```swift\nlet userLocation = Earendil.inferredLocation\n\n// use location data as the first-time region displayed by the map\nmapView.setRegion(userLocation.country.coordinateRegion, animated: true)\n\n// use location title (ENG only) as a content of any label in your app\nnavigationItem.title = userLocation.region.name\n\n// use location for analytics purposes\nFirebaseAnalytics.logEvent(UserLocationEvent(userLocation))\n```\n\n## What? How come? Why?\nIt's super simple - the idea is to fetch current OS system Locale (`NSLocale.current`), cast it back to Foundation's `NSLocale` and retrieve the two-character `countryCode` key. This key is mapped to internal json dataset, which contains names and coordinates for every worlds-location. That way there is no need to ask for any location permission. You can check it out right here: [InferredLocationProvider.swift](Sources/Earendil/Internals/InferredLocationProvider.swift#L22).\n\nThis approach has some consequences, mainly:\n- Returned location (even for most granular level, `country`, is really very broad)\n- Users travelling to another country won't update Earendil's location (which may even be desired).\n- Setting location-agnostic Locale (such as `eu` instead of `eu_ES` or `en` instead of `en_US`) will prevent Earendil from getting proper location.\n\n## Installation\n\nAvailable through Swift Package Manager - open up the xcode, type this repos URL and you are good to go.\n\u003c/br\u003e\n\n## Platform Availability\n\n iOS 14.0\u003c/br\u003e\n iPadOS 14.0\u003c/br\u003e\n macOS 11.0 Big Sur\u003c/br\u003e\n watchOS 7.0\u003c/br\u003e\n tvOS 14.0\u003c/br\u003e\n\nalso compliant with  Mac Catalyst\n\u003c/br\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprzemek-jablonski%2Fearendil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprzemek-jablonski%2Fearendil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprzemek-jablonski%2Fearendil/lists"}