QPEngine

@objc
public class QPEngine : NSObject
extension QPEngine : CLLocationManagerDelegate
extension QPEngine: UNUserNotificationCenterDelegate
extension QPEngine : AVSpeechSynthesizerDelegate

Main class used by clients to integrate QuandoPasso SDK functionalities in their apps.

  • Returns the current Device ID, as returned by iOS

    Declaration

    Swift

    public static var deviceID: String? { get }
  • Undocumented

    Declaration

    Swift

    internal static let latestFetchRegionId: String
  • Undocumented

    Declaration

    Swift

    internal var signals: [QPSignal]
  • Undocumented

    Declaration

    Swift

    internal var pollTimer: Timer?
  • Undocumented

    Declaration

    Swift

    public var settings: QPSettings
  • Welcome message

    Declaration

    Swift

    internal var welcomeMessage: QPWelcomeMessage
  • Undocumented

    Declaration

    Swift

    public var locationManager: CLLocationManager!
  • Undocumented

    Declaration

    Swift

    public var latestDetectedActivity: CMMotionActivity?
  • Undocumented

    Declaration

    Swift

    public var engineStatus: QPEngineStatus
  • Undocumented

    Declaration

    Swift

    internal var notificationCenter: UNUserNotificationCenter
  • Undocumented

    Declaration

    Swift

    internal var locationBuffer: [CLLocation]
  • Undocumented

    Declaration

    Swift

    internal let speechSynthesizer: AVSpeechSynthesizer
  • Undocumented

    Declaration

    Swift

    public var latestKnownLocation: CLLocation? { get }
  • Undocumented

    Declaration

    Swift

    internal var latestFetchLocation: CLCircularRegion?
  • Undocumented

    Declaration

    Swift

    public weak var delegate: QPManagerDelegate?
  • Undocumented

    Declaration

    Swift

    public var metricsManager: MetricsManager!
  • Undocumented

    Declaration

    Swift

    internal lazy var stackableOperationsQueue: StackableOperationsQueue { get set }
  • Undocumented

    Declaration

    Swift

    internal var speechMessagesCount: Int
  • Undocumented

    Declaration

    Swift

    internal var categories: [QPCategory]?
  • Undocumented

    Declaration

    Swift

    public private(set) var fcdDataStack: CoreDataStack! { get }
  • Undocumented

    Declaration

    Swift

    internal var currentTripID: String?
  • Initialise a QPEngine instance with the provided QPSettings params

    Declaration

    Swift

    public init(settings: QPSettings)

    Parameters

    settings

    The QPSettings instance, containing the configuration parameters.

    Return Value

    The initialised QPEngine instance.

  • Undocumented

    Declaration

    Swift

    deinit
  • Undocumented

    Declaration

    Swift

    internal func dispatchEvent(event: QPEvent)
  • Undocumented

    Declaration

    Swift

    internal func addOperationToQueue(closure: (() -> Void)?, completion: (() -> Void)?)
  • Undocumented

    Declaration

    Swift

    public static var version: String { get }
  • Get the list of the active categories

    Declaration

    Swift

    public func getCategories() -> [QPCategory]?
  • Update the list of the active categories

    Declaration

    Swift

    public func updateCategories(_ completion: @escaping (_ completed: Bool) -> ())
  • Undocumented

    Declaration

    Swift

    internal func fetchCategories(_ completion: @escaping ([QPCategory]) -> Void)
  • Undocumented

    Declaration

    Swift

    func saveFCD(with location: CLLocation, isNewTrip: Bool)
  • Undocumented

    Declaration

    Swift

    func update(trip: QPTrip, location: CLLocation, bearing: Double, avgSpeed: Double)
  • Undocumented

    Declaration

    Swift

    func endTrip(with id: String, with location: CLLocation)
  • Undocumented

    Declaration

    Swift

    public func fetchSavedFCD(batchSize: Int? = nil) -> [QPFloatingCarData]
  • Undocumented

    Declaration

    Swift

    func fetchSavedTrip(for tripId: String?) -> QPTrip?
  • Undocumented

    Declaration

    Swift

    public func fetchFCD(with tripId: String?) -> QPFloatingCarData?
  • Perform all required logic when we receive a location update from the GPS

    Declaration

    Swift

    internal func onGPSLocationUpdated(newLocation: CLLocation)
  • Delegate method called by the GPS module when the current location has been updated.

    Declaration

    Swift

    public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
  • Delegate method called when a monitored geofence location is exited. Geofences are used to determine when we need to fetch vSigns from the APIs, i.e. when we exit from the area covered by the radius we pass when fetching the vsigns.

    Declaration

    Swift

    public func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion)
  • Delegate method called when GPS updates are suspended by the system, commonly after a period of inactivity.

    Declaration

    Swift

    public func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager)
  • Delegate method called when the GPS permissions are updated by the user, for example by going into System Settings and manually revoke them.

    Declaration

    Swift

    public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
  • Undocumented

    Declaration

    Swift

    public func userNotificationCenter(_ center: UNUserNotificationCenter,
    								   willPresent notification: UNNotification,
    								   withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
  • Shows the user the required permission popups

    Declaration

    Swift

    public func askPermission()
  • Returns an array of permissions with the current authorization status in a closure.

    Declaration

    Swift

    public func getPermissions(completion: @escaping ([QPPermission]) -> ())
  • Returns a vsign by id from the stored collection

    Declaration

    Swift

    internal func getSignalBy(id: String) -> QPSignal?
  • Sets up a Timer to schedule vsign API polling

    Declaration

    Swift

    internal func pollForSignals()
  • Undocumented

    Declaration

    Swift

    internal func stopPollingForSignals()
  • Process a list of vSigns, scheduling notificatios and marking them as notified.

    Declaration

    Swift

    internal func processMatchedSignals(results: VSignScanResults, currentLocation: CLLocation)

    Parameters

    results

    The VSignScanResults instance, containing a list of matching vSigns for the given location

    currentLocation

    The current GPS location

  • Undocumented

    Declaration

    Swift

    internal func updateSignalsNotifiedStatus(vsigns: [QPSignal], currentLocation: CLLocation)
  • Fetch the list of nearby vSigns from the API

    Declaration

    Swift

    public func fetchSignals(near: CLLocationCoordinate2D, completed: (() -> Void)? = nil)
  • Forces an API call to update the list of nearby vSigns. Mainly used to debug and troubleshooting, but can be used to trigger an immediate API call without waiting for the scheduled ones.

    Declaration

    Swift

    public func forceFetchSignals()
  • Forces an API call to update the list of nearby vSigns. Mainly used to debug and troubleshooting, but can be useful to perform an immediate match, bypassing the scheduler.

    Declaration

    Swift

    public func forceVSignScan()
  • Clears the notification statuses for all known vSigns

    Declaration

    Swift

    public func resetSignalsNotificationStatus()
  • Determines the vSign message to read according to lang settings and schedule Text-To-Speech activation

    Declaration

    Swift

    internal func speak(signal: QPSignal)

    Parameters

    signal

    The vSign to read

  • Add a message to a queue of messages to read according to Text-To-Speech activation.

    Declaration

    Swift

    public func speak(text: String, language: QPLangCode?, useIterationSettings: Bool? = false)

    Parameters

    text

    The text to read

    language

    In which language the message will be read. If not defined the message will be read according to settings. Default: english.

    useIterationSettings

    Determines whether or not to use TTS Iterations Settings. Default is false.

  • Exec a Welcome Message action

    Declaration

    Swift

    internal func execWelcomeMessage(signal: QPSignal)
  • Undocumented

    Declaration

    Swift

    public func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance)
  • Initialise engine and start all required services. Moves the engine to running state.

    Declaration

    Swift

    public func start()
  • Stops QP services: updating location, motion activities updates, polling for signals. Moves the engine to stopped state.

    Declaration

    Swift

    public func stop()
  • Undocumented

    Declaration

    Swift

    public func checkAndSwitchSuspendedState()
  • Update location manager params to be less accurate reducing battery consumption but keep getting updates (so we can do activity detection even when the app is suspended). Moves the engine to suspendedShortTerm state. Suspend also polling for signals.

    Declaration

    Swift

    public func suspendShortTerm()
  • After a defined period of time that the app is in the suspended status reduces more the accurancy of location manager params, keep getting updates but reducing battery compumption. Moves the engine to suspendedLongTerm state.

    Declaration

    Swift

    public func suspendLongTerm()
  • Update location manager params to use normal precision settings. Reactivates polling for signals and check in which status the engine should be. Move the engine to running state.

    Declaration

    Swift

    public func reactivate()
  • Undocumented

    Declaration

    Swift

    internal func processUserActivity()
  • Delegate method called when the application is resumed. Used to reschedule GPS updates after GPS has been suspended by the system after a long period of inactivity.

    Declaration

    Swift

    @objc
    func onAppDidBecomeActive()
  • Delegate method called when the application is about to be terminated.

    Declaration

    Swift

    @objc
    func appWillTerminate()
  • Updates current SDK’s settings passing a custom json as parameter.

    Declaration

    Swift

    public func updateSettings(with jsonString: String) -> Bool
  • Updates current SDK’s settings passing a custom json dictionarys.

    Declaration

    Swift

    public func updateSettings(with dict: [String : Any])