我正在制作一个使用 CLLocationManager 的应用程序,该应用程序将用于记录员工的出席者。为了验证员工的出席情况,我们将获取 GPS 坐标。
据我所知,有一个应用程序通常用来获取假GPS。我想阻止这个模拟 GPS 在用户使用我的应用程序时处于事件状态。
如果我使用 Android,我可以下载一个假的 GPS 应用程序。当我使用 Tinder 时,我可以伪造我的位置。假设我实际上在曼谷,但因为我使用假 GPS 应用程序,我可以将我的 Tinder 位置设置在伦敦,而不是曼谷。
所以基本上我想防止用户使用我的应用程序时来自假 GPS 的假位置。说实话我真的不知道iOS是否允许虚假位置
我可以在 Swift 中获取该函数吗?
这是我用来获取坐标的 LocationManager 类
import UIKit
import CoreLocation
class LocationManager: NSObject {
let manager = CLLocationManager()
var didGetLocation: ((Coordinate?) -> Void)?
override init() {
super.init()
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestLocation()
}
func getPermission() {
// to ask permission to the user by showing an alert (the alert message is available on info.plist)
if CLLocationManager.authorizationStatus() == .notDetermined {
manager.requestWhenInUseAuthorization()
}
}
}
extension LocationManager : CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedWhenInUse {
manager.requestLocation()
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print(error.localizedDescription)
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.first else {
didGetLocation?(nil)
return
}
let coordinate = Coordinate(location: location)
if let didGetLocation = didGetLocation {
didGetLocation(coordinate)
}
}
}
private extension Coordinate {
init(location: CLLocation) {
latitude = location.coordinate.latitude
longitude = location.coordinate.longitude
}
}
最佳答案
您可以检查应用程序是否越狱。如果它已经越狱,您可以通过显示永久对话框或其他内容来阻止用户使用该应用程序。 如果你想知道如何检测设备是否越狱,可以自行查找。有很多文献可以告诉您如何操作。
干杯:)
关于ios - 如何防止 Swift 中的假 GPS 应用程序模拟 GPS 位置(欺骗)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49376312/