SkyPathDelegate
public protocol SkyPathDelegate : AnyObject
Delegate methods to receive events from the SDK.
All methods will be called on the main thread.
Usage example:
SkyPath.shared.delegate = delegate
-
Called after
SkyPath.start()when SDK verified the key with the server and started recording and fetching data.SDK will save the session so not every call of
start()will trigger a server request. However, if the session has expired the network connection will be required to refresh the session and be able to receive fresh data from the server.It can also be called when SDK stopped recording due to an error like session invalidated or company/key deactivated etc. If
recording=falseaSkyPath.start()call is required to start recording again.Required.
Declaration
Swift
func didUpdateRecordingStatus(to recording: Bool)Parameters
recordingWhen successfully started recording the flag will be
true. When the API key or session is expired, or any other error it will be called with the flagfalse. In this case, SDK needs to be started again. -
SDK automatically fetches data periodically when online to keep data as fresh as possible.
SDK notifies when new data has been fetched from the server. It does not provide which new data has been received.
So to update data on the map you need to make a new query using
TurbulenceQueryto get the data you need. It can also be called once after starting notifying that the locally cached data is ready to use.Required.
Declaration
Swift
func didReceiveNewTurbulenceData(areaType: DataAreaType)Parameters
areaTypeUse it to distinguish area types like route corridor or viewport when needed.
-
didReceiveNewNowcast()Default implementationSDK automatically fetches data periodically when online.
SDK notifies when new data has been fetched from the server. It does not provide which new data has been received.
So to update data on the map you need to make a new query using
NowcastQueryto get the data you need. It can also be called once after starting notifying that the locally cached data is ready to use.Optional.
Default Implementation
Declaration
Swift
func didReceiveNewNowcast() -
detectedTurbulence(_:Default implementation) Notifies when a new turbulence event is detected. Or when a crossed tile is marked as turbulence clean or smooth which means the
.noneturbulence severity report will be sent for this tile.Some indication for the pilot can be presented or it can be ignored.
Optional.
Default Implementation
Declaration
Swift
func detectedTurbulence(_ turbulence: TurbulenceItem)Parameters
turbulenceThe generated turbulence report item that will also be sent to the server.
-
didReceiveNewTurbulencePolygons()Default implementationWhen a global turbulence polygons data type is enabled,
it will be called when new turbulence polygons data has been received from the server. SDK automatically downloads data periodically.
SDK does not provide the received changes so need to make a query by
TurbulencePolygonsQueryto get data to show. IfDataQuery.typesdoes not haveturbulencePolygonsthis will not be called as polygons data will not be available.Optional.
Default Implementation
Declaration
Swift
func didReceiveNewTurbulencePolygons() -
didReceiveNewLiveFlightData()Default implementationWhen received new live flight data in the route corridor or viewport.
Default Implementation
Declaration
Swift
func didReceiveNewLiveFlightData() -
didFailToFetchNewData(with:Default implementation) SDK failed to get new data.
This could be due to no connection, the server not being reachable, or something else. Check
errorto get more details.Optional.
Default Implementation
Declaration
Swift
func didFailToFetchNewData(with error: SPError)Parameters
errorAn error object.
-
didReceiveAlert(_:Default implementation) Turbulence alert is a warning when there are some turbulence reports ahead based on
AlertQueryparameters.By default, SDK does not search for alerts. You can start auto monitoring by calling
SkyPath.startMonitoringAlerts(with:)specifying desired parameters inAlertQuery. It will use default recommended parameters when not set, so it will be a good start.SDK will search for turbulence on every location update and notify this delegate if there is a match. It will not be called multiple times if the same reports are found. But it will be called once the situation change - whether a new turbulence is found or any from the previous alert disappeared or is not relevant anymore.
Due to a lot of reports alerts can be provided frequently. To make pilot notifications more consistent and less frequent you can use
TurbulenceClusterer. I will groupAlertResult.turbulenceinto clusters and notify the pilot about a cluster instead of eachTurbulenceItem.Optional.
Default Implementation
Declaration
Swift
func didReceiveAlert(_ alert: AlertResult)Parameters
alertThe alert consists of all turbulence reports found according to an
AlertQueryat each location update (not a delta since the last report). UseTurbulenceClustererfor grouping and better alerting logic. -
locationManagerDidFail(withError:Default implementation) The
CLLocationManageris used to track location.It can be called in case the app has not been granted permission to use location services or the location is not available (which can happen frequently when in the air). It can also be called in the case when the system failed to provide a location.
Optional.
Default Implementation
Declaration
Swift
func locationManagerDidFail(withError error: Error)Parameters
errorAn error object provided by the system
CLLocationManager. -
serverReachabilityUpdated(to:Default implementation) By default, the SkyPath server domain is used to communicate with the server.
You can also set a custom proxy server in
SkyPath.start()viaenvparameter, it will solve the whitelisting issue.This method will be called in case the server domain (default or custom proxy) is not reachable anymore or became reachable. Not reachable could be due to no internet connection or not being whitelisted. Called only on change from reachable to not reachable and vice versa.
Optional.
Default Implementation
Declaration
Swift
func serverReachabilityUpdated(to isReachable: Bool)Parameters
isReachableFlag if the server is now reachable or not.
-
The device sensors are analyzed to determine the turbulence events, so the fixed device position (angle) is required for a correct recording.
SDK automatically calibrates the device position and notifies when it is set properly and SDK can track data or not.
For example, when the device is positioned in the cradle and then moved in hands the
inPositionwill be false as SDK detects this movement. Later when it will be placed back in the cradle SDK will auto-detect it as well and notifyinPosition = true.The data will not be tracked while the device is not in position. Also, when the device is horizontal (flat) like laying on the table or near that it is also in the wrong position.
The application can show a note for the pilot that the device is currently not in position and data is not tracked.
Required.
Declaration
Swift
func didChangeDevicePosition(_ inPosition: Bool, horizontal: Bool)Parameters
inPositionIs the device currently in a steady position or not. This also can be checked via
SkyPath.inPosition.horizontalTurbulence is not tracked also when the device is horizontal. This also can be checked via
SkyPath.isHorizontal. -
didUpdateLowPowerMode(_:Default implementation) When the flight is started by
SkyPath.startFlight(_:)the high accuracy location tracking is enabled in both background and foreground.The high accuracy is also used when no flight started and the app is foreground, but not when in the background.
When no need for a location like when the app is in the background without a flight on the ground or when landed, the SDK will stop tracking location and notify that it switched to “low power mode” which means no location and sensor data tracking to save battery. When a new flight is started SDK will go out of low power mode.
Optional.
Default Implementation
Declaration
Swift
func didUpdateLowPowerMode(_ lowPowerMode: Bool)Parameters
lowPowerModeIs low power mode enabled or not. When
trueno sensor data and location will be tracked. SDK will stand for starting a new flight. -
didUpdateFetchingStatus(to:Default implementationareaType: dataType: ) Data is auto-fetched periodically from the server. The period can be configured by
SkyPath.dataUpdateFrequency.You can use this method to show an indicator that SkyPath is loading data or not. Called only on change.
Optional.
Default Implementation
Declaration
Swift
func didUpdateFetchingStatus(to fetching: Bool, areaType: DataAreaType, dataType: DataTypeOptions)Parameters
fetchingIt will be
truewhen a new fetching server request started. It will befalsewhen the corresponding request is completed and received data or there was an error.areaTypeThe data fetching is broken down into different area types. Each type is fetched via a separate fetching server request. See
DataAreaTypefor more details.dataTypeData type that updates fetching status.
SkyPathDelegate Protocol Reference