Search code examples
iosobjective-ccore-locationjailbreakiphone-privateapi

Check if location services are used at the moment


My goal is to check if a jailbroken iPhone is currently using any background navigation service.
I've gone mainly thru the CLLocationManager.hheader, but searched for appropriate methods in all other CoreLocation headers. Found nothing of use. Also searched for methods in the private framework GeoServices. But that one is so extensive, I'm not sure where to search.
However, I now think of checking if the phone is using location in the background by checking if the location arrow is showing.

How would I proceed and check that?


Solution

  • Here's what I've been using in iOS 9. If I rememeber correctly, appsUsingLocationWithDetails returns a dictionary of all apps that are registered for location services. LocationTechnologiesInUse contains an array of technologies being used by the app to update location data but its values are unknown to me. Probably some enum with values indicating that GPS, WiFi hotspots, cell towers or something else used. It doesn't really matter as the array will contain something only if the app uses location services at the moment. Here's an example:

    for (NSDictionary* app in [[CLLocationManager sharedManager] appsUsingLocationWithDetails].allValues)
    {
        if ([app[@"LocationTechnologiesInUse"] count] > 0)
        {
            //the app uses location services
        }
    }
    

    There're maybe some entitlement you will need to access that information. My daemon is signed with these entitlements with boolean value set to true.

    com.apple.locationd.authorizeapplications
    com.apple.locationd.preauthorized
    com.apple.locationd.effective_bundle
    com.apple.locationd.status
    com.apple.CoreLocation.PrivateMode
    

    Try using them if my code example doesn't work for you. It's been a long time since a wrote that piece of code and unfortunately I didn't document all entitlements. My daemon was already signed with these and the code above just worked, so maybe something is needed or may be not.