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=false
aSkyPath.start()
call is required to start recording again.Required.
Declaration
Swift
func didUpdateRecordingStatus(to recording: Bool)
Parameters
recording
When 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
TurbulenceQuery
to 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
areaType
Use 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
NowcastQuery
to 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
.none
turbulence 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
turbulence
The 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
TurbulencePolygonsQuery
to get data to show. IfDataQuery.types
does not haveturbulencePolygons
this 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
error
to get more details.Optional.
Default Implementation
Declaration
Swift
func didFailToFetchNewData(with error: SPError)
Parameters
error
An error object.
-
didReceiveAlert(_:
Default implementation) Turbulence alert is a warning when there are some turbulence reports ahead based on
AlertQuery
parameters.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.turbulence
into clusters and notify the pilot about a cluster instead of eachTurbulenceItem
.Optional.
Default Implementation
Declaration
Swift
func didReceiveAlert(_ alert: AlertResult)
Parameters
alert
The alert consists of all turbulence reports found according to an
AlertQuery
at each location update (not a delta since the last report). UseTurbulenceClusterer
for grouping and better alerting logic. -
locationManagerDidFail(withError:
Default implementation) The
CLLocationManager
is 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
error
An 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()
viaenv
parameter, 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
isReachable
Flag 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
inPosition
will 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
inPosition
Is the device currently in a steady position or not. This also can be checked via
SkyPath.inPosition
.horizontal
Turbulence 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
lowPowerMode
Is low power mode enabled or not. When
true
no 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
fetching
It will be
true
when a new fetching server request started. It will befalse
when the corresponding request is completed and received data or there was an error.areaType
The data fetching is broken down into different area types. Each type is fetched via a separate fetching server request. See
DataAreaType
for more details.dataType
Data type that updates fetching status.