ActivityCollector

open class ActivityCollector: ActivityReporter

Class that uses both HealthKitReporter and CoreMotionReporter to retrieve activity data from both stores.

See HealthKit/README.md for detailed instructions.

  • Path to the CoreMotionReporter local data store; you usually place this in ~/Library.

    Declaration

    Swift

    open let cmPath: String
  • The CoreMotionActivityInterpreter to use to interpret core motion activity sampled by the receiver.

    Declaration

    Swift

    open let cmInterpreter: CoreMotionActivityInterpreter?
  • Designated initializer.

    Declaration

    Swift

    public init(coreMotionDBPath: String, coreMotionInterpreter: CoreMotionActivityInterpreter?)

    Parameters

    coreMotionDBPath

    The path to the local CoreMotion database, as used by CoreMotionReporter

    coreMotionInterpreter

    The core motion activity interpreter to use; uses CoreMotionReporter itself if nil

  • Creates a QuestionnaireResponse resource containing all activities of the past x days.

    Declaration

    Swift

    open func resourceForAllActivity(ofLastDays days: Int = 7, callback: @escaping ((QuestionnaireResponse?, Error?) -> Void))

    Parameters

    ofLastDays

    The number of days before today to start on

    callback

    The callback to call when all activities are retrieved

  • Creates a QuestionnaireResponse resource for all activity that was reported in the given period.

    Declaration

    Swift

    open func resourceForAllActivity(startingAt start: Date, until: Date, callback: @escaping ((QuestionnaireResponse?, Error?) -> Void))

    Parameters

    startingAt

    The start date

    until

    The end date

    callback

    The callback to call when all activities are retrieved

  • Collect activities from HealthKit and CoreMotion over the given period.

    Declaration

    Swift

    open func reportForActivityPeriod(startingAt start: Date, until: Date, callback: @escaping ((ActivityReportPeriod?, Error?) -> Void))

    Parameters

    startingAt

    The start date

    until

    The end date

    callback

    The callback to call when all activities are retrieved