Alexa GeoLocation undefined

amazon-alexa

#1

Hello

Our skill provides information based on the location of the user. While the “normal” approach using the address works, we can’t get mobile devices (using the GeoLocation of the device) to work.

We specified the “Location Services” permissions in the console and activated them in the app. hasGeoLocationInterface() is true, getGeoLocationPermissionStatus() results in status “GRANTED”. However when trying to access the GeoLocationObject (using the approach presented in the docs with this.$alexaSkill!.getGeoLocationPermissionStatus()) we get an undefined. This is same for all methods discussed in https://www.jovo.tech/docs/v2/amazon-alexa/data#geolocation-object.

Are we missing something in the process, or is there an error in the framework/in the response from Amazon?


#2

I played around with the GeoLocation API (and found some bugs that i reported to Amazon). I would not call the feature production ready. You really do a lot of error handling to make sure to filter out wrong inputs (some of them are device specific, coming from the users mobile phone OS).

Concerning your issue: I ran into the same. You need to allow the Alexa App to use Location Services. Turn them on in iOS System Preferences for the Alexa App (same on Android i guess).

Let me know if it solved your issue!


#3

You’re right, switching the permission from “ask” to “always” on the iPhone solved the problem. Silly of me not to have checked that beforehand. But interesting that the skill got rejected back then because not correctly handling the users position on mobile in that case - they suggested requesting the permission from the user.

Anyhow, Thank you for your help!


#4

You can handle this error gracefully. First check whether the context.System.device.supportedInterfaces object has a Geolocation field and in case it is there but undefined prompt the user to give the Alexa app permission to access the location of the user. If even you and me do not know this step how could the user :grinning:


#5

Some more learnings:

  • always check for accuracyInMeters (eg. to be less than 30m has been proven to be a good rule of thumb). Indoors or without a clear GPS coverage it can be frustrating for the user to get totally out of bound location information. iOS and Android devices behave totally different here!

  • Check for a valid coordinate object. I sometimes get either latitude or longitude as zero although the accuracyInMeters is valid: "coordinate": { "latitudeInDegrees": 0, "longitudeInDegrees": 28.3, "accuracyInMeters": 12.1 } I filed a bug for that case.

Let me know if you have more findings! It is a lot of try and error because different devices behave differently and testing is really hard.


#6

I’ve the same issue. However, even had service location “always” on, the object coordinate is returned always undefined.

I’m using this: var location = await this.$alexaSkill.getCoordinateObject();

Btw, i’m a noob in jovo :slight_smile: