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

News & Updates

SDL iOS Library v4.3.0 is in Beta with Tons of New Features!

Hello to all of our iOS developers! It's been a long time since v4.0.0, the last update that really delivered new features for most developers. v4.1.0 enabled some app launching features for OEMs, and v4.2.0 added a lot of features for navigation developers, with a improved streaming video settings and touch callbacks.

v4.3.0 is a big update and changes many of the ways you currently interact with SDL by providing you with a bunch of new high-level APIs. We're really excited about this update because it lays the foundation for what's to come in the future. Because of all these lofty goals, we want to get this update right, so we need a little more time. Still, the framework is ready for you to use right now in public beta, and we're using it ourselves in several internal apps.

Since this is a minor version, all your previous code should still work, though some code may throw deprecation warnings. If your old code broke upon updating, let us know.

How Do I Get It?

If you want to get your hands on it now, you'll need to use a beta release. Carthage doesn't support pre-releases, but if you're using Cocoapods, change your podfile to this:

pod 'SmartDeviceLink-iOS', '4.3.0-beta.4'

You can also use the dynamic framework from our releases page.

So what's in this release? I'm so glad you asked! (Code examples are taken from the improved SDL Example App).

A Whole New Lifecycle

If you wish, you can still set up your app exactly as before, using SDLProxy. But now there's a better way. Meet SDLManager.

SDLManager is a simple object like SDLProxy, but unlike SDLProxy, you'll never need to destroy it after a disconnection. So you can store it, turn it into a singleton, or whatever you desire.

You can create one using an SDLConfiguration.

self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self];

An SDLConfiguration has two parts, an SDLLifecycleConfiguration and a SDLLockScreenConfiguration. There are some convenience initializers for each, but I strongly recommend you look through each of their header files at all of the properties.

A SDLLifecycleConfiguration comes in two basic options, as a default (read: IAP) configuration, and a debug (read: WiFi) configuration. You use debug to connect to SDLCore or default to connect to a TDK or a head unit in production. After initializing a SDLLifecycleConfiguration, you may want to modify some additional options, such as an appType. By default, the default configuration will not log anything while the debug configuration will log to the console.

SDLLockScreenConfiguration is brand new and will be discussed below under "Lock Screens".

After setting up SDLManager with a configuration, just call:

[self.sdlManager startWithReadyHandler:^(BOOL success, NSError * _Nullable error) {
    if (!success) {
        NSLog(@"SDL errored starting up: %@", error);
    }

    // Whatever other startup you need
}];

and get started.

Response Handlers

When you send an RPC, you no longer have to implement a delegate method and use correlation ids to figure out what's being responded to. And there was much rejoicing! Here's how it works.

[weakSelf.sdlManager sendRequest:request withResponseHandler:^(__kindof SDLRPCRequest * _Nullable request, __kindof SDLRPCResponse * _Nullable response, NSError * _Nullable error) {
    // Check for an error, do something with the response
}];

That's it! It's really that simple.

Of course, if you want to send a request and you don't care about the response, you can always just call sendRequest: too:

[self.sdlManager sendRequest:initalData];

Event Handlers

But wait, there's more! For certain RPCs (listed below), you no longer have to check delegate method notifications and try to figure out what to do next. The RPCs affected are:

  • SDLAddCommand
  • SDLSubscribeButton
  • SDLSoftButton

For any of these, you can now set a block that will get called when that button is pressed. For example:

SDLAddCommand *exampleCommand = [[SDLAddCommand alloc] init];
exampleCommand.vrCommands = [NSMutableArray arrayWithObject:commandName];
exampleCommand.menuParams = commandMenuParams;
exampleCommand.cmdID = @1;
exampleCommand.handler = ^void(__kindof SDLRPCNotification *notification) {
    // Do whatever you want when that notification comes back
};

So that's pretty neat. We think so anyway. Next!

File Manager

The File Manager is an easier way to track and upload images and files to the remote system. To access it, just pull it off your SDLManager.

self.sdlManager.fileManager

When your start handler is called on SDLManager startWithReadyHandler:, the file manager will already have a list of files available on the remote system. This will be available on fileManager.remoteFileNames.

To upload a file, you'll need to create an SDLFile or SDLArtwork object. If you want it to overwrite an existing file set the file's overwrite property to YES. Then, call:

[self.sdlManager.fileManager uploadFile:file completionHandler:^(BOOL success, NSUInteger bytesAvailable, NSError * _Nullable error) {
    // The file either succeeded or failed
}];

Lock Screens

We now provide a default lock screen (with customization options) and better access to making your own if you wish. Since these files are included in a resource bundle, it should come automatically in a dynamic framework, but you will have to manually drag this resource bundle in if you are using CocoaPods. See our guides for more information.

In the lock screen configuration, you can create the lock screen in four possible ways.

  • disabledConfiguration - Disable the lock screen during testing & development. You need a lock screen in production.
  • enabledConfiguration - Totally default lock screen.
  • enabledConfigurationWithAppIcon:backgroundColor: - Configure your lock screen with an icon to use on the lock screen and a custom background color. The other icons on screen will be either black or white to match your background.
  • enabledConfigurationWithViewController: - Use your own view controller as the lock screen. Note that if you are a subclass of SDLLockScreenViewController, you will be able to have the vehicleIcon property set if the remote system sends one.

Notification Dispatcher

If you want any other SDL notifications, they're now posted as iOS notifications. All the notification names are in the SDLNotificationConstants.h header. For example, you can watch the onHashChange notification by implementing:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newSDLHash:) name:SDLDidReceiveNewHashNotification object:nil];

and then implement the newSDLHash method like so:

- (void)newSDLHash:(SDLRPCNotificationNotification *)notification {
    SDLOnHashChange *onHashChange = notification.notification;

    // Do what you want
}

Fixes

  • The OnKeyboardEvent notification will now show up. Sorry about that!

Misc.

  • Correlation ids are managed by SDLManager, you don't have to manage them at all.

Thanks for reading! We look forward to seeing the great apps you build with SDL and to bringing you more improvements in the future. If you need to contact us, we're around StackOverflow, Github, and Slack. For more detailed information, see our guides.

Joel Fischer

iOS Lead

02 Sep 2016

Next Article