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
SDLManager

SDLManager Class Reference

Section Contents

Overview

The top level manager object for all of SDL’s interactions with the app and the head unit

configuration

The configuration the manager was set up with.

Objective-C

@property (nonatomic, copy, readonly) SDLConfiguration *_Nonnull configuration;

Swift

@NSCopying var configuration: SDLConfiguration { get }

hmiLevel

The current HMI level of the running app.

Objective-C

@property (nonatomic, copy, readonly, nullable) SDLHMILevel hmiLevel;

Swift

var hmiLevel: SDLHMILevel? { get }

audioStreamingState

The current audio streaming state of the running app.

Objective-C

@property (nonatomic, copy, readonly) SDLAudioStreamingState _Nonnull audioStreamingState;

Swift

var audioStreamingState: SDLAudioStreamingState { get }

systemContext

The current system context of the running app.

Objective-C

@property (nonatomic, copy, readonly) SDLSystemContext _Nonnull systemContext;

Swift

var systemContext: SDLSystemContext { get }

fileManager

The file manager to be used by the running app.

Objective-C

@property (nonatomic, strong, readonly) SDLFileManager *_Nonnull fileManager;

Swift

var fileManager: SDLFileManager { get }

permissionManager

The permission manager monitoring RPC permissions.

Objective-C

@property (nonatomic, strong, readonly) SDLPermissionManager *_Nonnull permissionManager;

Swift

var permissionManager: SDLPermissionManager { get }

streamManager

The streaming media manager to be used for starting video sessions.

Objective-C

@property (nonatomic, strong, readonly, nullable) SDLStreamingMediaManager *streamManager;

Swift

var streamManager: SDLStreamingMediaManager? { get }

screenManager

The screen manager for sending UI related RPCs.

Objective-C

@property (nonatomic, strong, readonly) SDLScreenManager *_Nonnull screenManager;

Swift

var screenManager: SDLScreenManager { get }

systemCapabilityManager

Centralized manager for retrieving all system capabilities.

Objective-C

@property (nonatomic, strong, readonly) SDLSystemCapabilityManager *_Nonnull systemCapabilityManager;

Swift

var systemCapabilityManager: SDLSystemCapabilityManager { get }

registerResponse

The response of a register call after it has been received.

Objective-C

@property (nonatomic, strong, readonly, nullable) SDLRegisterAppInterfaceResponse *registerResponse;

Swift

var registerResponse: SDLRegisterAppInterfaceResponse? { get }

authToken

The auth token, if received. This should be used to log into a user account. Primarily used for cloud apps with companion app stores.

Objective-C

@property (nonatomic, strong, readonly, nullable) NSString *authToken;

Swift

var authToken: String? { get }

delegate

The manager’s delegate.

Objective-C

@property (nonatomic, weak, nullable) id<SDLManagerDelegate> delegate;

pendingRPCTransactions

The currently pending RPC request send transactions

Objective-C

@property (nonatomic, copy, readonly) NSArray<__kindof NSOperation *> *_Nonnull pendingRPCTransactions;

Swift

var pendingRPCTransactions: [Operation] { get }

-initWithConfiguration:delegate:

Initialize the manager with a configuration. Call startWithHandler to begin waiting for a connection.

Objective-C

- (nonnull instancetype)
    initWithConfiguration:(nonnull SDLConfiguration *)configuration
                 delegate:(nullable id<SDLManagerDelegate>)delegate;

Parameters

configuration

Your app’s unique configuration for setup.

delegate

An optional delegate to be notified of hmi level changes and startup and shutdown. It is recommended that you implement this.

Return Value

An instance of SDLManager

-startWithReadyHandler:

Start the manager, which will tell it to start looking for a connection. Once one does, it will automatically run the setup process and call the readyBlock when done.

Objective-C

- (void)startWithReadyHandler:(nonnull SDLManagerReadyBlock)readyHandler;

Swift

func start(readyHandler: @escaping SDLManagerReadyBlock)

Parameters

readyHandler

The block called when the manager is ready to be used or an error occurs while attempting to become ready.

-stop

Stop the manager, it will disconnect if needed and no longer look for a connection. You probably don’t need to call this method ever.

If you do call this method, you must wait for SDLManagerDelegate’s managerDidDisconnect callback to call startWithReadyHandler:.

Objective-C

- (void)stop;

Swift

func stop()

-startRPCEncryption

Start the encryption lifecycle manager, which will attempt to open a secure service.

Please call this method in the successful callback of startWithReadyHandler. If you do call this method, you must wait for SDLServiceEncryptionDelegate’s serviceEncryptionUpdatedOnService delegate method before you send any encrypted RPCs.

Objective-C

- (void)startRPCEncryption;

Swift

func startRPCEncryption()

-sendRPC:

Send an RPC of type Response, Notification or Request. Responses and notifications sent to Core do not a response back from Core. Each request sent to Core does get a response, so if you need the response and/or error, call sendRequest:withResponseHandler: instead.

Objective-C

- (void)sendRPC:(nonnull __kindof SDLRPCMessage *)rpc;

Swift

func sendRPC(_ rpc: SDLRPCMessage)

Parameters

rpc

An RPC of type SDLRPCResponse, SDLRPCNotification or SDLRPCRequest

-sendRequest:

Send an RPC request and don’t bother with the response or error. If you need the response or error, call sendRequest:withCompletionHandler: instead.

Objective-C

- (void)sendRequest:(nonnull SDLRPCRequest *)request;

Swift

func send(_ request: SDLRPCRequest)

Parameters

request

The RPC request to send

-sendRequest:withResponseHandler:

Send an RPC request and set a completion handler that will be called with the response when the response returns.

Objective-C

- (void)sendRequest:(nonnull SDLRPCRequest *)request
    withResponseHandler:(nullable SDLResponseHandler)handler;

Swift

func send(request: SDLRPCRequest, responseHandler handler: SDLResponseHandler? = nil)

Parameters

request

The RPC request to send

handler

The handler that will be called when the response returns

-sendRequests:progressHandler:completionHandler:

Send all of the requests given as quickly as possible, but in order. Call the completionHandler after all requests have either failed or given a response.

Objective-C

- (void)sendRequests:(nonnull NSArray<SDLRPCRequest *> *)requests
      progressHandler:
          (nullable SDLMultipleAsyncRequestProgressHandler)progressHandler
    completionHandler:
        (nullable SDLMultipleRequestCompletionHandler)completionHandler;

Swift

func send(_ requests: [SDLRPCRequest], progressHandler: SDLMultipleAsyncRequestProgressHandler?) async -> Bool

Parameters

requests

The requests to be sent

progressHandler

A handler called every time a response is received

completionHandler

A handler to call when all requests have been responded to

-sendSequentialRequests:progressHandler:completionHandler:

Send all of the requests one at a time, with the next one going out only after the previous one has received a response. Call the completionHandler after all requests have either failed or given a response.

Objective-C

- (void)sendSequentialRequests:(nonnull NSArray<SDLRPCRequest *> *)requests
               progressHandler:
                   (nullable SDLMultipleSequentialRequestProgressHandler)
                       progressHandler
             completionHandler:(nullable SDLMultipleRequestCompletionHandler)
                                   completionHandler;

Swift

func sendSequential(requests: [SDLRPCRequest], progressHandler: SDLMultipleSequentialRequestProgressHandler?) async -> Bool

Parameters

requests

The requests to be sent

progressHandler

A handler called every time a response is received. Return NO to cancel any requests that have not yet been sent, YES to continue sending requests.

completionHandler

A handler to call when all requests have been responded to

-subscribeToRPC:withBlock:

Subscribe to callbacks about a particular RPC request, notification, or response with a block callback.

Objective-C

- (nonnull id)subscribeToRPC:(nonnull SDLNotificationName)rpcName
                   withBlock:(nonnull SDLRPCUpdatedBlock)block;

Swift

func subscribe(to rpcName: NSNotification.Name, block: @escaping SDLRPCUpdatedBlock) -> Any

Parameters

rpcName

The name of the RPC request, response, or notification to subscribe to.

block

The block that will be called every time an RPC of the name and type specified is received.

Return Value

An object that can be passed to unsubscribeFromRPC:ofType:withObserver: to unsubscribe the block.

-subscribeToRPC:withObserver:selector:

Subscribe to callbacks about a particular RPC request, notification, or response with a selector callback.

The selector supports the following parameters:

  1. Zero parameters e.g. - (void)registerAppInterfaceResponse
  2. One parameter e.g. - (void)registerAppInterfaceResponse:(NSNotification *)notification;

Note that using this method to get a response instead of the sendRequest:withResponseHandler: method of getting a response, you will not be notified of any SDLGenericResponse errors where the head unit doesn’t understand the request.

Objective-C

- (void)subscribeToRPC:(nonnull SDLNotificationName)rpcName
          withObserver:(nonnull id)observer
              selector:(nonnull SEL)selector;

Swift

func subscribe(to rpcName: NSNotification.Name, observer: Any, selector: Selector)

Parameters

rpcName

The name of the RPC request, response, or notification to subscribe to.

observer

The object that will have its selector called every time an RPC of the name and type specified is received.

selector

The selector on observer that will be called every time an RPC of the name and type specified is received.

-unsubscribeFromRPC:withObserver:

Unsubscribe to callbacks about a particular RPC request, notification, or response.

Objective-C

- (void)unsubscribeFromRPC:(nonnull SDLNotificationName)rpcName
              withObserver:(nonnull id)observer;

Swift

func unsubscribe(from rpcName: NSNotification.Name, observer: Any)

Parameters

rpcName

The name of the RPC request, response, or notification to unsubscribe from.

observer

The object representing a block callback or selector callback to be unsubscribed

View on GitHub.com
Previous Section Next Section