RSDActiveUIStepObject

open class RSDActiveUIStepObject : RSDUIStepObject, RSDActiveUIStep

RSDActiveUIStepObject extends the RSDUIStepObject to include a duration and commands. This is used for the case where an RSDUIStep has an action such as start walking or stop walking; the step may also implement the RSDActiveUIStep protocol to allow for spoken instruction.

  • The duration of time to run the step. If 0, then this value is ignored.

    Declaration

    Swift

    open var duration: TimeInterval
  • The set of commands to apply to this active step. These indicate actions to fire at the beginning and end of the step such as playing a sound as well as whether or not to automatically start and finish the step.

    Seealso

    RSDActiveUIStepCommand.stringMapping for a list of the coding strings included in this framework.

    Declaration

    Swift

    open var commands: RSDActiveUIStepCommand
  • Whether or not the step uses audio, such as the speech synthesizer, that should play whether or not the user has the mute switch turned on. Default = false.

    Declaration

    Swift

    open var requiresBackgroundAudio: Bool
  • Should the task end early if the task is interrupted by a phone call? Default = false.

    Declaration

    Swift

    open var shouldEndOnInterrupt: Bool
  • A mapping of the localized text that represents an instructional voice prompt to the time marker for speaking the instruction.

    The mapping is Codable using either TimeInterval values as the keys or by using the SpokenInstructionKeys as special keys into the mapping dictionary.

    • example:

          // Example JSON dictionary that includes a spoken instruction map.
          let json = """
          {
             "identifier": "foo",
             "type": "active",
             "title": "Hello World!",
             "text": "Some text.",
             "duration": 30,
             "requiresBackgroundAudio": true,
             "commands": ["playSoundOnStart", "vibrateOnFinish"],
             "spokenInstructions" : { "start": "Start moving",
                                      "10": "Keep going",
                                      "halfway": "Halfway there",
                                      "countdown": "5",
                                      "end": "Stop moving"}
          }
          """.data(using: .utf8)! // our data in native (JSON) format
      
          // The decoded mapping.
          self.spokenInstructions = [ 0.0 : "Start moving",
                                      10.0 : "Keep going",
                                      15.0 : "Halfway there",
                                      25.0 : "five",
                                      26.0 : "four",
                                      27.0 : "three",
                                      28.0 : "two",
                                      29.0 : "one",
                                      Double.infinity : "Stop moving"]
      

    Declaration

    Swift

    open var spokenInstructions: [TimeInterval : String]?
  • The SpokenInstructionKeys are specialized markers for the timing of when to speak the spoken instruction. These include keys that can be transformed into a time interval using the duration of the step to indicate the halfway point.

    See more

    Declaration

    Swift

    public enum SpokenInstructionKeys : String, CodingKey
  • Localized text that represents an instructional voice prompt. Instructional speech begins when the step passes the time indicated by the given time. If timeInterval is greater than or equal to duration or is equal to Double.infinity, then the spoken instruction returned should be for when the step is finished.

    Declaration

    Swift

    open func spokenInstruction(at timeInterval: TimeInterval) -> String?

    Parameters

    timeInterval

    The time interval at which to speak the instruction.

    Return Value

    The localized instruction to speak or nil if there isn’t an instruction.

  • Default type is .active.

    Declaration

    Swift

    open override class func defaultType() -> RSDStepType
  • Override to set the properties of the subclass.

    Declaration

    Swift

    override open func copyInto(_ copy: RSDUIStepObject)
  • Override to set the properties on this instance.

    • example:

          // Example JSON dictionary that includes a duration, commands, and spoken instruction mapping.
          let json = """
          {
             "identifier": "foo",
             "type": "active",
             "title": "Hello World!",
             "text": "Some text.",
             "duration": 30,
             "commands": ["playSoundOnStart", "vibrateOnFinish"],
             "spokenInstructions" : { "start": "Start moving",
                                      "10": "Keep going",
                                      "halfway": "Halfway there",
                                      "countdown": "5",
                                      "end": "Stop moving"}
          }
          """.data(using: .utf8)! // our data in native (JSON) format
      
      

    Declaration

    Swift

    open override func decode(from decoder: Decoder, for deviceType: RSDDeviceType?) throws