Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

SDLAlert Class Reference

Section Contents

Overview

Shows an alert which typically consists of text-to-speech message and text on the display. Either alertText1, alertText2 or TTSChunks needs to be set or the request will be rejected.

If connecting to SDL Core v.6.0+, the alert can be canceled programmatically using the cancelID. Canceling will not dismiss the alert’s speech - only the modal view will be dismissed. On older versions of SDL Core, the alert will persist until the user has interacted with the alert or the specified timeout has elapsed.

@since SDL 1.0

-initWithAlertText:softButtons:playTone:ttsChunks:alertIcon:cancelID:

Convenience init for creating a modal view with text, buttons, and optional sound cues.

Objective-C

- (nonnull instancetype)
    initWithAlertText:(nullable NSString *)alertText
          softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons
             playTone:(BOOL)playTone
            ttsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks
            alertIcon:(nullable SDLImage *)icon
             cancelID:(UInt32)cancelID;

Swift

init(alertText: String?, softButtons: [SDLSoftButton]?, playTone: Bool, ttsChunks: [SDLTTSChunk]?, alertIcon icon: SDLImage?, cancelID: UInt32)

Parameters

alertText

The string to be displayed in the first field of the display

softButtons

Soft buttons to be displayed

playTone

Whether the alert tone should be played before the TTS (if any) is spoken

ttsChunks

Speech or a sound file to be played when the alert shows

cancelID

An ID for this specific alert to allow cancellation through the CancelInteraction RPC

icon

Image to be displayed in the alert

Return Value

An SDLAlert object

-initWithTTSChunks:playTone:

Convenience init for creating a sound-only alert.

Objective-C

- (nonnull instancetype)initWithTTSChunks:
                            (nullable NSArray<SDLTTSChunk *> *)ttsChunks
                                 playTone:(BOOL)playTone;

Swift

init(ttsChunks: [SDLTTSChunk]?, playTone: Bool)

Parameters

ttsChunks

Speech or a sound file to be played when the alert shows

playTone

Whether the alert tone should be played before the TTS is spoken

Return Value

An SDLAlert object

-initWithAlertText1:alertText2:alertText3:softButtons:playTone:ttsChunks:duration:progressIndicator:alertIcon:cancelID:

Convenience init for setting all alert parameters.

Objective-C

- (nonnull instancetype)
    initWithAlertText1:(nullable NSString *)alertText1
            alertText2:(nullable NSString *)alertText2
            alertText3:(nullable NSString *)alertText3
           softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons
              playTone:(BOOL)playTone
             ttsChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks
              duration:(UInt16)duration
     progressIndicator:(BOOL)progressIndicator
             alertIcon:(nullable SDLImage *)icon
              cancelID:(UInt32)cancelID;

Swift

init(alertText1: String?, alertText2: String?, alertText3: String?, softButtons: [SDLSoftButton]?, playTone: Bool, ttsChunks: [SDLTTSChunk]?, duration: UInt16, progressIndicator: Bool, alertIcon icon: SDLImage?, cancelID: UInt32)

Parameters

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

softButtons

Buttons for the alert

playTone

Whether the alert tone should be played before the TTS (if any) is spoken

ttsChunks

An array of text chunks to be spoken or a prerecorded sound file

duration

The duration of the displayed portion of the alert, in milliseconds

progressIndicator

Whether an animation indicating that loading of a feature is progressing should be shown

cancelID

An ID for this specific alert to allow cancellation through the CancelInteraction RPC

icon

Image to be displayed in the alert

Return Value

An SDLAlert object

-initWithAlertText1:alertText2:duration:

Convenience init for creating an alert with two lines of text and a timeout.

Objective-C

- (nonnull instancetype)initWithAlertText1:(nullable NSString *)alertText1
                                alertText2:(nullable NSString *)alertText2
                                  duration:(UInt16)duration;

Swift

init(alertText1: String?, alertText2: String?, duration: UInt16)

Parameters

alertText1

The first line of the alert

alertText2

The second line of the alert

duration

The duration of the displayed portion of the alert, in milliseconds

Return Value

An SDLAlert object

-initWithAlertText1:alertText2:alertText3:

Convenience init for creating an alert with three lines of text.

Objective-C

- (nonnull instancetype)initWithAlertText1:(nullable NSString *)alertText1
                                alertText2:(nullable NSString *)alertText2
                                alertText3:(nullable NSString *)alertText3;

Swift

init(alertText1: String?, alertText2: String?, alertText3: String?)

Parameters

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

Return Value

An SDLAlert object

-initWithAlertText1:alertText2:alertText3:duration:

Convenience init for creating an alert with three lines of text and a timeout.

Objective-C

- (nonnull instancetype)initWithAlertText1:(nullable NSString *)alertText1
                                alertText2:(nullable NSString *)alertText2
                                alertText3:(nullable NSString *)alertText3
                                  duration:(UInt16)duration;

Swift

init(alertText1: String?, alertText2: String?, alertText3: String?, duration: UInt16)

Parameters

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

duration

The duration of the displayed portion of the alert, in milliseconds

Return Value

An SDLAlert object

-initWithAlertText1:alertText2:alertText3:duration:softButtons:

Convenience init for creating an alert with three lines of text and a timeout.

Objective-C

- (nonnull instancetype)initWithAlertText1:(nullable NSString *)alertText1
                                alertText2:(nullable NSString *)alertText2
                                alertText3:(nullable NSString *)alertText3
                                  duration:(UInt16)duration
                               softButtons:(nullable NSArray<SDLSoftButton *> *)
                                               softButtons;

Swift

init(alertText1: String?, alertText2: String?, alertText3: String?, duration: UInt16, softButtons: [SDLSoftButton]?)

Parameters

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

duration

The duration of the displayed portion of the alert, in milliseconds

softButtons

Buttons for the alert

Return Value

An SDLAlert object

-initWithTTS:playTone:

Convenience init for creating a speech-only alert.

Objective-C

- (nonnull instancetype)initWithTTS:(nullable NSString *)ttsText
                           playTone:(BOOL)playTone;

Swift

init(tts ttsText: String?, playTone: Bool)

Parameters

ttsText

Speech to be played

playTone

Whether the alert tone should be played before the TTS is spoken

Return Value

An SDLAlert object

-initWithTTS:alertText1:alertText2:playTone:duration:

Convenience init for creating an alert with two lines of text, optional sound cues, and a timout.

Objective-C

- (nonnull instancetype)initWithTTS:(nullable NSString *)ttsText
                         alertText1:(nullable NSString *)alertText1
                         alertText2:(nullable NSString *)alertText2
                           playTone:(BOOL)playTone
                           duration:(UInt16)duration;

Swift

init(tts ttsText: String?, alertText1: String?, alertText2: String?, playTone: Bool, duration: UInt16)

Parameters

ttsText

Speech to be played

alertText1

The first line of the alert

alertText2

The second line of the alert

playTone

Whether the alert tone should be played before the TTS is spoken

duration

The duration of the displayed portion of the alert, in milliseconds

Return Value

An SDLAlert object

-initWithTTS:alertText1:alertText2:alertText3:playTone:duration:

Convenience init for creating an alert with three lines of text, optional sound cues, and a timout.

Objective-C

- (nonnull instancetype)initWithTTS:(nullable NSString *)ttsText
                         alertText1:(nullable NSString *)alertText1
                         alertText2:(nullable NSString *)alertText2
                         alertText3:(nullable NSString *)alertText3
                           playTone:(BOOL)playTone
                           duration:(UInt16)duration;

Swift

init(tts ttsText: String?, alertText1: String?, alertText2: String?, alertText3: String?, playTone: Bool, duration: UInt16)

Parameters

ttsText

Speech to be played

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

playTone

Whether the alert tone should be played before the TTS is spoken

duration

The duration of the displayed portion of the alert, in milliseconds

Return Value

An SDLAlert object

-initWithTTSChunks:alertText1:alertText2:alertText3:playTone:softButtons:

Convenience init for creating an alert with three lines of text, soft buttons, and optional sound cues.

Objective-C

- (nonnull instancetype)
    initWithTTSChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks
           alertText1:(nullable NSString *)alertText1
           alertText2:(nullable NSString *)alertText2
           alertText3:(nullable NSString *)alertText3
             playTone:(BOOL)playTone
          softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons;

Swift

init(ttsChunks: [SDLTTSChunk]?, alertText1: String?, alertText2: String?, alertText3: String?, playTone: Bool, softButtons: [SDLSoftButton]?)

Parameters

ttsChunks

Speech or a sound file to be played when the alert shows

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

playTone

Whether the alert tone should be played before the TTS is spoken

softButtons

Buttons for the alert

Return Value

An SDLAlert object

-initWithTTSChunks:alertText1:alertText2:alertText3:playTone:duration:softButtons:

Convenience init for creating an alert with three lines of text, soft buttons, optional sound cues, and a timout.

Objective-C

- (nonnull instancetype)
    initWithTTSChunks:(nullable NSArray<SDLTTSChunk *> *)ttsChunks
           alertText1:(nullable NSString *)alertText1
           alertText2:(nullable NSString *)alertText2
           alertText3:(nullable NSString *)alertText3
             playTone:(BOOL)playTone
             duration:(UInt16)duration
          softButtons:(nullable NSArray<SDLSoftButton *> *)softButtons;

Swift

init(ttsChunks: [SDLTTSChunk]?, alertText1: String?, alertText2: String?, alertText3: String?, playTone: Bool, duration: UInt16, softButtons: [SDLSoftButton]?)

Parameters

ttsChunks

Speech or a sound file to be played when the alert shows

alertText1

The first line of the alert

alertText2

The second line of the alert

alertText3

The third line of the alert

playTone

Whether the alert tone should be played before the TTS is spoken

duration

The duration of the displayed portion of the alert, in milliseconds

softButtons

Buttons for the alert

Return Value

An SDLAlert object

alertText1

The first line of the alert text field.

@discussion At least either alertText1, alertText2 or ttsChunks need to be provided. @discussion If supported, the displayCapabilities will have a TextField with a name of alertText1.

String, Optional, Max length 500 chars @since SDL 1.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) NSString *alertText1;

Swift

var alertText1: String? { get set }

alertText2

The second line of the alert text field.

@discussion At least either alertText1, alertText2 or ttsChunks need to be provided. @discussion If supported, the displayCapabilities will have a TextField with a name of alertText2

String, Optional, Max length 500 chars @since SDL 1.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) NSString *alertText2;

Swift

var alertText2: String? { get set }

alertText3

The optional third line of the alert text field.

@discussion If supported, the displayCapabilities will have a TextField with a name of alertText3

String, Optional, Max length 500 chars @since SDL 2.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) NSString *alertText3;

Swift

var alertText3: String? { get set }

ttsChunks

An array of text chunks to be spoken or a prerecorded sound file.

@discussion At least either alertText1, alertText2 or ttsChunks need to be provided.

Array of SDLTTSChunk, Optional, Array length 1 - 100

@since SDL 1.0

Objective-C

@property (readwrite, strong, nonatomic, nullable)
    NSArray<SDLTTSChunk *> *ttsChunks;

Swift

var ttsChunks: [SDLTTSChunk]? { get set }

duration

The duration of the displayed portion of the alert, in milliseconds. Typical timeouts are 3 - 5 seconds. If omitted, the timeout is set to a default of 5 seconds.

Integer, Optional, Min value: 3000, Max value: 10000

@since SDL 1.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) NSNumber<SDLInt> *duration;

Swift

var duration: (NSNumber & SDLInt)? { get set }

playTone

Whether the alert tone should be played before the TTS (if any) is spoken. If omitted or set to false, no tone is played.

Boolean, Optional

@since SDL 1.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) NSNumber<SDLBool> *playTone;

Swift

var playTone: (NSNumber & SDLBool)? { get set }

progressIndicator

If supported on the given platform, the alert GUI will include some sort of animation indicating that loading of a feature is progressing (e.g. a spinning wheel or hourglass, etc.).

Boolean, Optional

@since SDL 2.0

Objective-C

@property (readwrite, strong, nonatomic, nullable)
    NSNumber<SDLBool> *progressIndicator;

Swift

var progressIndicator: (NSNumber & SDLBool)? { get set }

softButtons

Buttons for the displayed alert. If omitted on supported displays, the displayed alert shall not have any buttons.

Array of SDLSoftButton, Optional, Array size 0 - 4

@since SDL 2.0

Objective-C

@property (readwrite, strong, nonatomic, nullable)
    NSArray<SDLSoftButton *> *softButtons;

Swift

var softButtons: [SDLSoftButton]? { get set }

cancelID

An ID for this specific alert to allow cancellation through the CancelInteraction RPC.

Integer, Optional

See

SDLCancelInteraction @since SDL 6.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) NSNumber<SDLInt> *cancelID;

Swift

var cancelID: (NSNumber & SDLInt)? { get set }

alertIcon

Image to be displayed in the alert. If omitted on supported displays, no (or the default if applicable) icon should be displayed.

SDLImage, Optional @since SDL 6.0

Objective-C

@property (readwrite, strong, nonatomic, nullable) SDLImage *alertIcon;

Swift

var alertIcon: SDLImage? { get set }
View on GitHub.com
Previous Section Next Section