4

I am making an app that using CLLocationManager, this app will be used to record the attendee of the employee. to validate the attendee of the employees, we will get GPS Coordinate.

as far as I know, in there is an app that usually used to get fake GPS. I want to prevent this mock GPS to be active when the user using my app.

If I am using Android, I can download a fake GPS app. and when let say I use tinder I can fake my location. let say actually I am in Bangkok, but because I use fake GPS app, I can set my tinder location to be in London, not in Bangkok anymore.

So Basically I want to prevent fake location that comes from that fake GPS when the user using my App. To be honest I don't really know whether iOS allow fake location or not

can I get that function in Swift?

here is the class LocationManager I use to get the coordinate

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
    }
}
maximiliano
  • 353
  • 5
  • 15
  • What are you referring to? How is location data being spoofed? – rmaddy Mar 20 '18 at 04:25
  • You can spoof location by connecting the device to Xcode. There is no way to prevent this. – Paulw11 Mar 20 '18 at 04:30
  • I am sorry if it is not clear since english is not my first language. If I am using Android, I can download a fake GPS app. and when let say I use tinder I can fake my location. let say actually I am in Bangkok, but because I use fake GPS app, I can set my tinder location to be in London, not in Bangkok anymore. So Basically I want to prevent fake location that comes from that fake GPS when the user using my App. To be honest I don't really know whether iOS allow fake location or not – maximiliano Mar 20 '18 at 04:31
  • can I prevent that in Swift? – maximiliano Mar 20 '18 at 04:32
  • iOS doesn't support the ability to spoof location simply running apps from the App Store. – rmaddy Mar 20 '18 at 04:32
  • You can't get fake GPS apps from the Apple App store, so most users cannot fake location. You cannot prevent a sophisticated user from using Xcode – Paulw11 Mar 20 '18 at 04:32
  • “To be honest I don't really know whether iOS allow fake location or not” Exactly so. You are not actually having this problem on iOS so this question is not about anything. Your question is like saying How can I prevent my chair from suddenly turning into a unicorn. Let’s cross that bridge when we come to it. – matt Mar 20 '18 at 04:34
  • I am sorry, this is my first time making an app (iOS). because I am confused and worried. there is fake GPS app in the app store, so i need to make sure. Thank you, I just know that fake location can only be used if the user using Xcode but not from the app – maximiliano Mar 20 '18 at 04:38
  • calm down @matt I am not that bad – maximiliano Mar 20 '18 at 04:41
  • 1
    And what's about tools like iTools (https://www.thinkskysoft.com/itools/)? I also tough it was not possible to fake GPS on iOS but seem you easily can. – Steve Jul 26 '18 at 16:32
  • @maximiliano have you got any solutions for this? – Midhun Narayan May 11 '19 at 04:41

2 Answers2

3

You can check if the app is jailbroken or not. If it already jailbroken, you can prevent the user to use the app with showing permanent dialog or something else. If you wanna know how to detect the device is jailbroken or not, you can find it by yourself. There is so many literature that will tell you how.

Cheers :)

Wendra
  • 507
  • 6
  • 8
2

Only thing I can tell you and I've been in a similar situation is you need to have a backup method to get the user location. Use an IP location API/service (which is not 100% reliable) and create a logic in your app to compare the data.

PS: THIS IS NOT A SOLUTION TO YOUR PROBLEM it's just an idea you could try to work with. But this would only work best if spoofing the location is happening using different cities/states since IP location is not a high accuracy one. If GPS says you are in San Diego but your IP say you are in San Francisco, then you could block the UI/request until user confirms something.

PS2: in iOS the only way I know a user can spoof it's location is running an app through XCode, using the location feature and then opening your app. (used to do that a lot with pokemon go #notproud :))

gmogames
  • 2,993
  • 1
  • 28
  • 40