Swift Types

Configuration

For clientId and clientSecret values, see account setup. You must specify a unique identifier for each new user specified in userId. By default shareUserData is false.

public struct Configuration {
  public let clientId: String
  public let clientSecret: String
  public let userId: String
  public let shareUserData: Bool
}

ContextStateCollection

public final class ContextStateCollection {
  public let created: Date
  public let ... // Various {Place,Trip}ContextState variables
}

Place

[warning] Optional Permission!

Places will never contain a CLLocation unless your user has granted Background Location permission.

public struct Place {
  public let id: String
  public let location: CLLocationCoordinate2D?
  public let label: String?
}

PlaceType

[warning] Optional Permission!

.location(CLLocation) PlaceTypes are not available unless your user has granted Background Location permission

public enum PlaceType {
  case home
  case any
  case location(_: CLLocation)
}

Trip

[warning] Optional Permission!

distance is never available unless your user has granted Background Location permission

public struct Trip {
  public let id: String
  public let start: Place
  public let end: Place?
  public let distance: Double
  public let mode: TripMode
  public let label: String?
}

TripMode

[warning] Optional Permission!

TripMode will always be .any unless your user has granted Background Location permission

public enum TripMode {
  case any
  case walking
  case running
  case cycling
  case automotive
}

Bounds

public enum Bounds {
  case unknown
  case past(start: Date, end: Date)
  case current(start: Date, end: DatePrediction?)
  case future(start: DatePrediction?, end: DatePrediction?)
}

DatePrediction

public struct DatePrediction {
  public let date: Date
  public var confidence: Double
  public let window: TimeInterval
}

ContextState

public struct ContextState {
  public let name: String
  public let bounds: Bounds
  public let confidence: Double
}

PlaceContextState

public struct PlaceContextState {
  public let name: String
  public let bounds: Bounds
  public let confidence: Double
  public let place: Place
}

TripContextState

public struct TripContextState {
  public let name: String
  public let bounds: Bounds
  public let confidence: Double
  public let trip: Trip
}

EventType

public enum EventType {
  case start(bounds: Bounds, state: ContextStateCollection)
  case end(bounds: Bounds, state: ContextStateCollection)
  case data(bounds: Bounds, state: ContextStateCollection)
}

EventDelay

public enum EventDelay {
  case fiveSeconds = 5
  case fifteenSeconds = 15
  case thirtySeconds = 30
  case oneMinute = 60
  case fiveMinutes = 300
  case fifteenMinutes = 900
  case thirtyMinutes = 1800
  case oneHour = 3600
}

EventTiming

public enum EventTiming {
  case after(delay: EventDelay)
  case upon
}

Condition

public enum Condition {
  case any
  case anyTime
  case normalTime
  case earlierThanNormal
  case laterThanNormal
  case anyDuration
  case normalDuration
  case longerThanNormal
  case anyFrequency
  case lowFrequency
  case mediumFrequency
  case highFrequency
  case lessThan(count: Int, inPastInterval: TimeInterval)
  case lessThanOrEqualTo(count: Int, inPastInterval: TimeInterval)
  case equalTo(count: Int, inPastInterval: TimeInterval)
  case greaterThanOrEqualTo(count: Int, inPastInterval: TimeInterval)
  case greaterThan(count: Int, inPastInterval: TimeInterval)
}

Context

public enum Context {
  case any
  case tracked(event: String, conditions: [Condition])
  case arrivedAt(type: PlaceType, conditions: [Condition])
  case departedFrom(type: PlaceType, conditions: [Condition])
  case atPlace(type: PlaceType, conditions: [Condition])
  case notAtPlace(type: PlaceType)
  case onTrip(type: TripType, from: PlaceType, to: PlaceType)
  case onWifi
  case notOnWifi
  case pluggedIn
  case notPluggedIn
  case unplugged
  case moving
  case notMoving
  case walking
  case notWalking
  case running
  case notRunning
  case cycling
  case notCycling
  case automotive
  case notAutomotive
  case weekend
  case notWeekend
  case weekday
  case notWeekday
  case morning
  case notMorning
  case afternoon
  case notAfternoon
  case evening
  case notEvening
  case night
  case notNight
  case foreground
  case background
}

ContextEvent

public struct ContextEvent {
  public let type: EventType
  public let handlerId: String
  public let created: Date
}

SetError

public enum SetError: Error {
  case sdkAlreadyRunning
  case sdkNotInitialized
  case invalidAppToken
  case missingBundleId
  case internalError
  case jsonDecodingError
  case invalidUserIdFormat
}



Get in touch

results matching ""

    No results matching ""