The lock screen is a vital part of your SDL app because it prevents the user from using the phone while the vehicle is in motion. SDL takes care of the lock screen for you. If you prefer your own look, but still want the recommended logic that SDL provides for free, you can also set your own custom lock screen.
If you would not like to use any of the following code, you may use the SDLLockScreenConfiguration
class function disabledConfiguration
, and manage the entire lifecycle of the lock screen yourself. However, it is strongly recommended that you use the provided lock screen manager, even if you use your own view controller.
To see where the SDLLockScreenConfiguration
is used, refer to the Integration Basics guide.
Using the default lock screen is simple. Using the lock screen this way will automatically load an automaker's logo, if available, to show alongside your logo. If it is not, the default lock screen will show your logo alone.
To do this, instantiate a new SDLLockScreenConfiguration
:
SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfiguration];
let lockScreenConfiguration = SDLLockScreenConfiguration.enabled()
It is possible to customize the background color and app icon in the default provided lockscreen. If you choose not to set your own app icon the library will use the SDL logo.
UIColor *backgroundColor = <# Desired Background Color #> SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfigurationWithAppIcon:<# Retrieve App Icon #> backgroundColor:backgroundColor];
let backgroundColor: UIColor = <# Desired Background Color #> let lockScreenConfiguration = SDLLockScreenConfiguration.enabledConfiguration(withAppIcon: <# Retrieve App Icon #>, backgroundColor: backgroundColor)
UIImage *appIcon = <# Retrieve App Icon #> SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfigurationWithAppIcon:appIcon backgroundColor:<# Desired Background Color #>];
let appIcon: UIImage = <# Retrieve App Icon #> let lockScreenConfiguration = SDLLockScreenConfiguration.enabledConfiguration(withAppIcon: appIcon, backgroundColor: <# Desired Background Color #>)
The default lock screen handles retrieving and setting the OEM logo from head units that support this feature.
This feature can be disabled on the default lock screen by setting showDeviceLogo
to false.
SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfiguration]; lockScreenConfiguration.showDeviceLogo = NO;
let lockScreenConfiguration = SDLLockScreenConfiguration.enabled() lockScreenConfiguration.showDeviceLogo = false
If you would like to use your own lock screen instead of the one provided by the library, but still use the logic we provide, you can use a new initializer within SDLLockScreenConfiguration
. Any custom lock screen you create should be a subclass of SDLLockScreenViewController
to ensure that it is configured correctly and can receive all of the information necessary to customize your lock screen such as the OEM icon.
If you create a custom lock screen view controller, please note that the view controller's default view
background will be transparent, even if you set a background color for it. You must place a custom view across the entire view controller in order to make your lock screen opaque.
MySDLLockScreenViewControllerSubclass *lockScreenViewController = <# Initialize Your View Controller #>; SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfigurationWithViewController:lockScreenViewController];
// This view controller should be a `SDLLockScreenViewController` subclass let lockScreenViewController = <# Initialize Your View Controller #> let lockScreenConfiguration = SDLLockScreenConfiguration.enabledConfiguration(with: lockScreenViewController)
In SDL iOS v6.4, a new parameter displayMode
has been added to the SDLLockScreenConfiguration
to control the state of the lock screen and the older boolean parameters have been deprecated.
DisplayMode | Description |
---|---|
never | The lock screen should never be shown. This should almost always mean that you will build your own lock screen |
requiredOnly | The lock screen should only be shown when it is required by the head unit |
optionalOrRequired | The lock screen should be shown when required by the head unit or when the head unit says that its optional, but not in other cases, such as before the user has interacted with your app on the head unit |
always | The lock screen should always be shown after connection |
Please note that a lock screen will be required by most OEMs. You can disable the lock screen manager, but you will then be required to implement your own logic for showing and hiding the lock screen. This is not recommended as the SDLLockScreenConfiguration
adheres to most OEM lock screen requirements. However, if you must create a lock screen manager from scratch, the library's lock screen manager can be disabled via the SDLLockScreenConfiguration
as follows:
SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration disabledConfiguration];
let lockScreenConfiguration = SDLLockScreenConfiguration.disabled()
The lock screen manager is configured to dismiss the lock screen when it is safe to do so. To always have the lock screen visible when the device is connected to the head unit, simply update the lock screen configuration.
SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfiguration]; lockScreenConfiguration.displayMode = SDLLockScreenConfigurationDisplayModeAlways;
let lockScreenConfiguration = SDLLockScreenConfiguration.enabled() lockScreenConfiguration.displayMode = .always
Starting in RPC v6.0+ users may now have the ability to dismiss the lock screen by swiping the lock screen down. Not all OEMs support this new feature. A dismissible lock screen is enabled by default if the head unit enables the feature, but you can disable it manually as well.
To disable this feature, set SDLLockScreenConfiguration
s enableDismissGesture
to false.
SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfiguration]; lockScreenConfiguration.enableDismissGesture = NO;
let lockScreenConfiguration = SDLLockScreenConfiguration.enabledConfiguration() lockScreenConfiguration.enableDismissGesture = false