Alert

public protocol Alert

An Alert to be sent to the server. The alert is sent by calling the raise() method. The time of the alert is set when raise() is called, allowing raise() to be called more than once.

The set method returns the Alert instance to allow the fields of the alert to be set in fluent style.

  • Set the value of a field in the Alert. The fields are determined by the format given when the Alert is created. The value is validated according to the constraints in the format. If the value is not valid, a ClientError.argument is raised.

    All fields defined in the format that are “optional” must be set before calling raise().

    Throws

    ClientError.argument if fieldName is not a valid field name or value is not the field type.

    Declaration

    Swift

    func set(fieldName: String, value: AnyObject) throws -> Alert

    Parameters

    fieldName

    the name of a field from the alert format

    value

    the value to set

    Return Value

    Alert object that can be used for function chaining

  • Send the alert. The event time is set when this method is called.

    The onError handler of the parent virtual device will be called if there is error sending the alert.

    All fields defined in the format that are “optional” must be set before calling raise(). If raise() is called before setting all “optional” fields, the function will fail with a specific ErrorType

    Throws

    • ClientError.argument if a required field is not set
    • ClientError.network if a MessageDispatcher cannot be obtained.

    Declaration

    Swift

    func raise() throws
  • Set a callback that is invoked if an error occurs when raising the Alert. The callback may be nil, which will un-set the callback.

    Declaration

    Swift

    func setOnError(callback: ((ErrorEvent) -> ())?)

    Parameters

    callback

    a callback to invoke, or nil