Skip to content

Release 5.3.0

Compare
Choose a tag to compare
@kierangraham kierangraham released this 26 Feb 11:44
· 8 commits to master since this release
  • New! Callbacks can be bound to receive events generated by the SDK
  • New! Power level can be chosen when launch SDK, lowPower & highPower
    • High power is typically faster at detecting events but consumes slightly more battery

High Power & Low Power

The predict.io SDK comes in two power levels which cater to different requirements of battery consumption and latency of events being detected.

NOTE: Power level won't take effect properly until a fresh app relaunch, it's not a setting which should be toggled at runtime.

High Power

  • 5% typical battery usage in 24 hour period
  • Events detected within a few minutes
  • Mode of Transport detection (coming soon in future beta)
  • Intention detection (coming soon in future beta)
PredictIO.start(apiKey: apiKey, powerLevel: .highPower) {
  error in
  // Handled as above
}

Low Power

  • Less than 1% typical battery usage in 24 hour period
  • Events detected with up to 30 min delay
  • No Mode of Transport detection
  • Intention detection (coming soon in future beta)

NOTE: Low power is the default if no value is set for the powerLevel parameter.

PredictIO.start(apiKey: apiKey, powerLevel: .lowPower)

Events

The predict.io SDK can give you callbacks for the events which are detected for you to integrate with your own app's functionality.

PredictIO.notify(on: .any) {
  (event: PredictIOTripEvent) in
  // Do something with event 
}
PredictIO.notify(on: .departure) {
    event in
    // Do something when user has left a location
}
PredictIO.notify(on: .arrival) {
    event in
    // Do something when user has arrived at a location
}

PredictIOTripEvent

A PredictIOTripEvent is the event you will receive that describes attributes of the event which was detected, namely; the location, timestamp and type of the event from the following:

  • .arrival
  • .departure
  • .enroute (High Power only)
  • .still (High Power only)
public class PredictIOTripEvent: CustomStringConvertible {
  public let type: PredictIOTripEventType
  public let coordinate: CLLocationCoordinate2D
  public let timestamp: Date
}