Swift Package for fetching approximate user location without asking for their permission 👺 .

Overview

Earendil

Swift Package for fetching approximate user location without asking for their permission 👺 .

Get 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.

100% App Store safe, no-private APIs used.

Usage

Get the location at any time:

let userLocation = Earendil.inferredLocation

userLocation.country.name // "United States of America"
userLocation.country.region.center // (37.09, -95.7)
userLocation.country.region.span // (60, 60)

Use the inferred location for your needs:

let userLocation = Earendil.inferredLocation

// use location data as the first-time region displayed by the map
mapView.setRegion(userLocation.country.coordinateRegion, animated: true)

// use location title (ENG only) as a content of any label in your app
navigationItem.title = userLocation.region.name

// use location for analytics purposes
FirebaseAnalytics.logEvent(UserLocationEvent(userLocation))

What? How come? Why?

It'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.

This approach has some consequences, mainly:

  • Returned location (even for most granular level, country, is really very broad)
  • Users travelling to another country won't update Earendil's location (which may even be desired).
  • Setting location-agnostic Locale (such as eu instead of eu_ES or en instead of en_US) will prevent Earendil from getting proper location.

Installation

Available through Swift Package Manager - open up the xcode, type this repos URL and you are good to go.

Platform Availability

 iOS 14.0
 iPadOS 14.0
 macOS 11.0 Big Sur
 watchOS 7.0
 tvOS 14.0

also compliant with  Mac Catalyst

You might also like...
Swift-problem-solving - Swift 알고리즘 맛보기 😋

swift-problem-solving Swift 로 알고리즘 익히기 😆 Programmers 난이도 풀이 문제 바로가기 Lv.2 오픈채팅방 링크 Lv.3 다단계 칫솔 판매 링크 Lv.3 합승 택시 요금 링크 Leetcode 난이도 풀이 문제 바로가기 Medium 1

Swift-cuckoo-collections - Cross-platform Swift dictionaries & sets that use a cuckoo hashing algorithm

CuckooCollections A Swift package for open-addressed sets and dictionaries that

Helps you define secure storages for your properties using Swift property wrappers.

🔐 Secure Property Storage Helps you define secure storages for your properties using Swift property wrappers. 🌟 Features All keys are hashed using S

Swift cross-platform crypto library using CommonCrypto/libcrypto

BlueCryptor Swift cross-platform crypto library derived from IDZSwiftCommonCrypto. IMPORTANT NOTE: This release is NOT entirely source code compatible

CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift

CryptoSwift Crypto related functions and helpers for Swift implemented in Swift. (#PureSwift) Note: The master branch follows the latest currently rel

A wrapper for Apple's Common Crypto library written in Swift.

IDZSwiftCommonCrypto A Swift wrapper for Apple's CommonCrypto library. IDZSwiftCommonCrypto works with both CocoaPods and Cathage. For more details on

A framework for the JOSE standards JWS, JWE, and JWK written in Swift.

JOSESwift is a modular and extensible framework for the JOSE standards JWS, JWE, and JWK written in Swift. 💡 Please note that this implementation of

CCCryptor (AES encryption) wrappers for iOS and Mac in Swift. -- For ObjC, see RNCryptor/RNCryptor-objc

RNCryptor Cross-language AES Encryptor/Decryptor data format. The primary targets are Swift and Objective-C, but implementations are available in C, C

Elegant Swift interface to access the CommonCrypto routines

SCrypto [Overview • Requirements • Installation • Usage • Alternatives • Licence] Overview SCrypto provides neat Swift interface to access the CommonC

Releases(1.0.3)
Owner
Przemysław Jabłoński
Senior iOS Software Engineer
Przemysław Jabłoński
Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works.

Valet Valet lets you securely store data in the iOS, tvOS, watchOS, or macOS Keychain without knowing a thing about how the Keychain works. It’s easy.

Square 3.8k Jan 4, 2023
CryptoExchange - A fully functional structure for Crypto Exchange app without using many third party assests

cryptoExchange A fully functional structure for Crypto Exchange app without usin

Shwait Kumar 0 Jan 6, 2022
A simple way of doing both symmetric and asymmetric crypto without the headache

Simple Swift Crypto I needed a simple way of doing both symmetric and asymmetric

Joe Hinkle 6 Dec 19, 2022
A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.

SwiftKeychainWrapper A simple wrapper for the iOS / tvOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift. Prov

Jason 1.5k Dec 30, 2022
RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

Kitura 122 Dec 16, 2022
RSA public/private key encryption, private key signing and public key verification in Swift using the Swift Package Manager. Works on iOS, macOS, and Linux (work in progress).

BlueRSA Swift cross-platform RSA wrapper library for RSA encryption and signing. Works on supported Apple platforms (using Security framework). Linux

Kitura 122 Dec 16, 2022
A wrapper to make it really easy to deal with iOS, macOS, watchOS and Linux Keychain and store your user's credentials securely.

A wrapper (written only in Swift) to make it really easy to deal with iOS, macOS, watchOS and Linux Keychain and store your user's credentials securely.

Ezequiel Aceto 2 Mar 29, 2022
Ported Shamirs Secret Sharing Into A Swift Package

Shamirs-Secret-Sharing-Swift Ported Shamirs Secret Sharing Into A Swift Package Based on Adi Shamir's Secret Sharing (https://en.wikipedia.org/wiki/Sh

Charles Edge 5 May 15, 2022
Swift package wrapping the OpenWall BCrypt hashing algorithm

SwiftBCrypt A simple Swift Package wrapping the OpenWall BCrypt hashing algorithm. Generate Salt let bcryptSalt = try BCRypt.makeSalt() Hash Phrases

Tanner Silva 1 Jul 8, 2022
A SwiftUI package to beautifully display and handle permissions.

PermissionsSwiftUI: A SwiftUI package to handle permissions PermissionsSwiftUI displays and handles permissions in SwiftUI. It is largely inspired by

Jevon Mao 899 Dec 26, 2022