Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store if mocked location on iOS (15+) #446

Open
txbrown opened this issue Jan 3, 2025 · 0 comments
Open

Store if mocked location on iOS (15+) #446

txbrown opened this issue Jan 3, 2025 · 0 comments

Comments

@txbrown
Copy link

txbrown commented Jan 3, 2025

At the moment the mocked field is only set for Android implementation. For the app we're working on I created the following extesion and made a patch for the moment. This issue is so that we can add it officially to the package in LocationUtils.swift

func locationToDict(_ location: CLLocation) -> [String: Any] {
    return [
        "coords": [
            "latitude": location.coordinate.latitude,
            "longitude": location.coordinate.longitude,
            "altitude": location.altitude,
            "accuracy": location.horizontalAccuracy,
            "altitudeAccuracy": location.verticalAccuracy,
            "heading": location.course,
            "speed": location.speed,
            "mocked": location.isSimulated()
        ],
        "timestamp": location.timestamp.timeIntervalSince1970 * 1000 // ms
    ]
}
extension CLLocation {
    func isSimulated() -> Bool {
        if #available(iOS 15.0, *) {
            return self.sourceInformation?.isSimulatedBySoftware ?? false
        } else {
            return false
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant