Skip to content

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

Open
@txbrown

Description

@txbrown

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
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions