Changes Introduced in APL Version 1.2
Alexa Presentation Language 1.2 introduces new features and capabilities for APL.
General updates
All components now have new properties for displaying shadow effects:
All components now have new properties for cursor handlers:
The set of filters now includes a Noise you can use to add generated noise to images. Use this with the Image
component.
APL now provides support for keyboards and keyboard events. You can define handlers for KeyUp and KeyDown events at both the component and document level. See Keyboard.
Components that can respond to touch, cursor, and keyboard events now have additional actionable component properties such as onFocus
and handleKeyDown
. The following components are actionable:
- Pager
- ScrollView
- Sequence
- TouchWrapper
See Actionable Component Properties for the new properties available on these components.
Work with APL versions
In your APL document, set the version
to "1.2"
.
A user can invoke your skill on older devices that do not support the latest version of APL. When working with features introduced in a specific version of APL, provide an alternative experience for devices running earlier versions of APL. The environment.aplVersion
property in the data-binding context returns the version of APL on the device. This property returns null
for APL 1.0 and the actual version for 1.1 or later. Use this property in when
statements to create conditional blocks based on version.
For example, this renders a VectorGraphic
on a device with APL 1.1 or later, and an image for APL 1.0:
[
{
"type": "Image",
"when": "${environment.aplVersion == null}",
"width": 100,
"height": 100,
"source": "https://example.com/alternate/image/for/older/versions.jpg"
},
{
"type": "VectorGraphic",
"when": "${environment.aplVersion != null}",
"source": "lightbulb",
"width": 100,
"height": 100,
"scale": "best-fit"
}
]
The APL version is also available in requests sent to your skill, in:
context.System.device.supportedInterfaces.['Alexa.Presentation.APL'].runtime.maxVersion
This example shows a request from a device with 1.2. Note that the session
, request
, and viewport
properties are omitted for brevity.
{
"version": "1.0",
"session": {},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.1"
},
"user": {
"userId": "amzn1.ask.account.1"
},
"device": {
"deviceId": "amzn1.ask.device.1",
"supportedInterfaces": {
"Alexa.Presentation.APL": {
"runtime": {
"maxVersion": "1.2"
}
}
}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ..."
},
"Viewport": {}
},
"request": {}
}