Last active
February 15, 2023 16:41
-
-
Save alimovlex/e9e6db7080874cd8a9429bf9c1b56bac to your computer and use it in GitHub Desktop.
The location service class for iOS devices written in Swift.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (C) 2023 Recompile.me. | |
| * All rights reserved. | |
| */ | |
| import CoreLocation | |
| class Navigator: NSObject, CLLocationManagerDelegate { | |
| let locationManager = CLLocationManager(); | |
| var currentLocation: CLLocation!; | |
| override init() { | |
| super.init(); | |
| self.locationManager.delegate = self; | |
| self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; | |
| } | |
| func locationAuthStatus() { | |
| locationManager.requestWhenInUseAuthorization(); | |
| locationManager.startMonitoringSignificantLocationChanges(); | |
| if CLLocationManager.authorizationStatus() == .authorizedWhenInUse { | |
| currentLocation = locationManager.location; | |
| print(currentLocation.coordinate.latitude, currentLocation.coordinate.longitude); | |
| } else { | |
| locationManager.requestWhenInUseAuthorization(); | |
| locationAuthStatus(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment