Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Accessing standard GPS location assurances on iOS

Discussion in 'iOS and tvOS' started by NNSkelly, Sep 19, 2022.

  1. NNSkelly

    NNSkelly

    Joined:
    Nov 16, 2015
    Posts:
    35
    Since iOS 15- out for over a year- Apple has provided the CLLocationSourceInformation API (https://developer.apple.com/documentation/corelocation/cllocationsourceinformation) as a quick, standard, minimal test for whether GPS information is at least plausibly real vs being spoofed by standard software/hardware means. Thus, when contracting GPS-based apps for iOS, my company's prospective clients are now naturally expecting at least this level of assurance that users aren't gaming the system, not particularly caring that we only develop in Unity, not native. So... is there, now or on the horizon, officially or via an off-the-shelf plugin, etc., any way to get at these standard isSimulatedBySoftware / isProducedByAccessory flags from within Unity? Or is the only option going to be homebrewing a custom iOS plugin and wrestling that pipeline?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,507
  3. NNSkelly

    NNSkelly

    Joined:
    Nov 16, 2015
    Posts:
    35
    If it's more appropriate, sure. Android has also had basic mock-location permission detection for awhile, and more recently, detection on the actual GPS data payload, so this looks increasingly like something that would be worthwhile platform-wide.

    For now, I've tripped over https://kulwik.medium.com/unity-native-gps-plugin-ios-and-android-11469d86190c which provides a complete barebones native GPS plugin template for both iOS and Android with all source used. After half a day diving Apple's legacy Objective-C docs and half a day of banging Android Studio back into usable shape, I was able to expose the respective OS-level GPS mock status flags up to Unity on both paths, and draft in a fallback to the regular Unity location services. It means I'm pretty much stuck with the plugin's GPS data if I want to be confident in what the sourcing flags are referring to, but that's not much of an inconvenience when I'm already leaning on a plugin.