question

Jude avatar image
Jude asked

How to get geo-coordinates of the customer's device

Hi All,

I have created a skill using ASK SDK with Node.js. In that I have used device address API (getDeviceAddressServiceClient) to get the full address of the customer device.

Right now I'm trying to get the geo-coordinates by enabling the location permission in settings and modify the logic by adding the sample code in the docs(https://developer.amazon.com/docs/custom-skills/location-services-for-alexa-skills.html)

context.Geolocation

var isGeoSupported = context.System.device.supportedInterfaces.Geolocation;
var geoObject = context.Geolocation;
if (isGeoSupported) {
    var ACCURACY_THRESHOLD = 100; // accuracy of 100 meters required                if (geoObject && geoObject.coordinate && geoObject.coordinate.accuracyInMeters < ACCURACY_THRESHOLD ) {                          console.log(geoObject);  // Print the geo-coordinates object if accuracy is within 100 meters                }
}


When I try to invoke the skill intent, it returns undefined for both isGeoSupportedand geoObject

and in the log it shows the supportedInterfaces attributes of device object return empty

2019-02-07T13:42:31.738Z 503fbe25-71d2-47a4-ac1b-7ad8cdbb9bcf

{ "deviceId": "amzn1.ask.device.AHC6DQBCQLEU7775V3FWM3WGTDIMHYWM342TM4M7VR3FIDA2PE564ONQYOEMGZ4V44JF76C54PYYGEFPLENFVYWV4XTUPFDJJVOBQ7UGES5OQWU4FMTDP4UKXSGI6MPI", "supportedInterfaces": {} }

Expecting your support to resolve this issue.


Thanks,

Jude

alexa skills kit
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Rokas avatar image
Rokas answered

Not all devices return geo coordinates. When I was testing it I was only able to get geo coordinates from alexa app on the phone. Echo devices or dev console, didn't return geo coordinates. Maybe some wearable gadgets also return geo coordinates, but I am not sure. But you should make sure, that if geo is not available, skill returns some sort of response saying that.

If you have suggestions how to improve it, create a feature request in amazon alexa website.

2 comments
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi Rokas,

Thanks for your response. I will test it in alexa app on the phone and confirm the response with "supportedInterfaces" objects.


Thanks,

Jude

0 Likes 0 ·