This release includes a new helper class: DeviceAddressService
that helps developers to better utilize the device address api.
To get user device address information, simply call one of the following functions:
DeviceAddressService.getFullAddress(deviceId, apiEndpoint, token);
DeviceAddressService.getCountryAndPostalCode(deviceID, apiEndpoint, token);
An example to get user full address information is as follows:
const Alexa = require('alexa-sdk');
'DeviceAddressIntent': function () {
if (this.event.context.System.user.permissions) {
let token = this.event.context.System.user.permissions.consentToken;
let apiEndpoint = this.event.context.System.apiEndpoint;
let deviceId = this.event.context.System.device.deviceId;
let das = new Alexa.services.DeviceAddressService();
das.getFullAddress(deviceId, apiEndpoint, token)
.then((data) => {
this.response.speak('<address information>');
console.log('Address get: ' + JSON.stringify(data));
})
.catch((error) => {
this.response.speak('I'm sorry. Something went wrong.');
console.log(error.message);
});
} else {
this.response.speak('Please grant skill permissions to access your device address.')
}
this.emit(':responseReady');
}