Test
Before going live, implementation should be tested in simulation mode on the ground, and in the air.
Recording
Recording turbulence works only in the air, so SDK provides a simulation mode to test it on the ground.
Use it for STAGING ENV only. It can be set by env: .staging(serverUrl: nil) in the AuthConfig passed to SkyPath.initialize(with:completion:). By default when no env parameter is passed, the production server is used.
All simulation APIs live on SkyPath.shared.testing.
The SDK enforces the staging-only rule. On any other environment every simulation API does nothing and logs an error, so the calls are safe to leave in the app code.
// Set SDK to use the simulated location that you provide instead of the real from the device
SkyPath.shared.testing.enableSimulation(true)
// Enable SDK to send turbulence and events to the server. Otherwise, simulated events will not be sent. The default is disabled.
SkyPath.shared.testing.enablePushSimulated(true)
// Stop simulation when not needed
SkyPath.shared.testing.enableSimulation(false)
Provide your simulated location. The simplest way is to have an array of CLLocationCoordinate2D on the same air altitude and pass it by a timer with 1-second time intervals.
Please note that a correct course value in CLLocation passed to simulate is required for testing turbulence notifications (alerts) in a beam mode. Otherwise, the beam will head north up and not heading the simulated flight direction.
SkyPath.shared.testing.simulatedLocation(location)
You can have some hidden developer options to enable/disable simulation mode for QA testing. Simulation mode can be enabled/disabled at any time.
Trigger a turbulence event by using a timer at some time intervals, or randomly during some time, or just by having a test button or your event trigger. Turbulence will not be tracked on the ground, so need an air-simulated location.
Turbulence is recorded only while SkyPath.shared.recordingState is .recording, so check it before simulating an event. See Record Data for the other states and what they mean.
guard SkyPath.shared.recordingState == .recording else { return }
SkyPath.shared.testing.simulateTurbulence(sev: .moderate)
Reset cache
SkyPath.shared.testing.resetCache(all:issuedAt:) clears locally cached data. Use it to check how the app behaves with no data, or with expired data.
Unlike the simulation APIs above it works on any environment.
// Drop the fetched data cache only. The SDK re-fetches on its next cycle.
SkyPath.shared.testing.resetCache()
// Make all the cached data look old to test the "expired data" case.
SkyPath.shared.testing.resetCache(issuedAt: Date().addingTimeInterval(-24 * 60 * 60))
// Wipe everything, including settings and files. It stops the SDK, so initialize it again after.
SkyPath.shared.testing.resetCache(all: true)
SkyPath.shared.initialize(with: config) { error in }