Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
iOS Documentation
SDLSubscribeButton

SDLSubscribeButton Class Reference

Section Contents

Overview

Establishes a subscription to button notifications for HMI buttons. Buttons are not necessarily physical buttons, but can also be “soft” buttons on a touch screen, depending on the display in the vehicle. Once subscribed to a particular button, an application will receive both SDLOnButtonEvent and SDLOnButtonPress notifications whenever that button is pressed. The application may also unsubscribe from notifications for a button by invoking the SDLUnsubscribeButton operation

When a button is depressed, an SDLOnButtonEvent notification is sent to the application with a ButtonEventMode of BUTTONDOWN. When that same button is released, an SDLOnButtonEvent notification is sent to the application with a ButtonEventMode of BUTTONUP

When the duration of a button depression (that is, time between depression and release) is less than two seconds, an SDLOnButtonPress notification is sent to the application (at the moment the button is released) with a ButtonPressMode of SHORT. When the duration is two or more seconds, an SDLOnButtonPress notification is sent to the application (at the moment the two seconds have elapsed) with a ButtonPressMode of LONG

The purpose of SDLOnButtonPress notifications is to allow for programmatic detection of long button presses similar to those used to store presets while listening to the radio, for example

When a button is depressed and released, the sequence in which notifications will be sent to the application is as follows:

For short presses:

  • OnButtonEvent (ButtonEventMode = BUTTONDOWN)
  • OnButtonEvent (ButtonEventMode = BUTTONUP)
  • OnButtonPress (ButtonPressMode = SHORT)

For long presses:

  • OnButtonEvent (ButtonEventMode = BUTTONDOWN)
  • OnButtonEvent (ButtonEventMode = BUTTONUP)
  • OnButtonPress (ButtonPressMode = LONG)

HMILevel needs to be FULL, LIMITED or BACKGROUND

Since SmartDeviceLink 1.0
See SDLUnsubscribeButton

-initWithHandler:

Construct a SDLSubscribeButton with a handler callback when an event occurs.

Objective-C

- (nonnull instancetype)initWithHandler:
    (nullable SDLRPCButtonNotificationHandler)handler;

Swift

init(handler: SDLRPCButtonNotificationHandler? = nil)

Parameters

handler

A callback that will be called when a button event occurs for the subscribed button.

Return Value

An SDLSubscribeButton object

-initWithButtonName:handler:

Construct a SDLSubscribeButton with a handler callback when an event occurs with a button name.

Objective-C

- (nonnull instancetype)
    initWithButtonName:(nonnull SDLButtonName)buttonName
               handler:(nullable SDLRPCButtonNotificationHandler)handler;

Swift

init(buttonName: SDLButtonName, handler: SDLRPCButtonNotificationHandler? = nil)

Parameters

buttonName

The name of the button to subscribe to

handler

A callback that will be called when a button event occurs for the subscribed button

Return Value

An SDLSubscribeButton object

handler

A handler that will let you know when the button you subscribed to is selected.

Warning

This will only work if you use SDLManager.

Objective-C

@property (nonatomic, copy) SDLRPCButtonNotificationHandler _Nonnull handler;

Swift

var handler: SDLRPCButtonNotificationHandler { get set }

buttonName

The name of the button to subscribe to @discussion An enum value, see SDLButtonName

Objective-C

@property (nonatomic, strong) SDLButtonName _Nonnull buttonName;

Swift

var buttonName: SDLButtonName { get set }
View on GitHub.com
Previous Section Next Section