I have the simplest possible test to find the longitude of a user.
I have a single webpage with a WebdeviceLocation control with the event 'DeviceLocation ’ containing the code:
my_long = Longitude.Tostring
I have a button with the following code:
When tapping the button the my_long variable is empty.
Moreover the DeviceLocation event isn’t fired. (That is at least consistent). When I run there is no request for permission to use location. It looks like I first have to add a certificate.
- Is it indeed true I can’t even test this locally
- Can I use the example .crt file provided in th User Guide: SSL for Standalone Web Apps?
- The User Guide recommends using the ‘copy files build automation’ step. I do not really understand what that embodies (except that the results will be that the .crt file gets at the server at the appropriate place. But what then for local testing?)
Requesting a device location is asynchronous. That is, a message is sent to the browser and some time in the future it may respond if the user allows it.
Implement the events on your WebLocator class to receive the data when it comes back. Try the Error Event to see if theres a specific problem.
SSL is not required.
Thanks. I tested it with my Safari browser (rather than Firefox) and this gave me the following:
Could not determine the device location: Origin does not have permission to use Geolocation service
Seems that there is some security issue?
Of course I started from the MapLocation example in the XOJO examples and that one too gives this Safari error message.
You need to enable location services in the system preferences and allow Safari to determine the location.
Hi Hector, Enabling location services in OSX system preferences worked for Firefox. However Safari still returns:
Origin does not have permission to use Geolocation service
I can see that Safari is allowed by the system to use its location but I can also see that Safri didn’t even try (one can see in the security prefs which apps have used or tried to use location services). So there is still something within Safari blocking me to get at the system location. According to the Apple documents there should be a reset option for Safari (inclusing reset location services) but that Apple Doc is outdated. Reset has disappeared from the Safari menu. No new apple doc is available.
After some searching I found the remark that refers to the title of this Conversation. It turns out that Safari and Chrome nowadays REQUIRE a secure connection. Here is the quote (from stack overflow):
[code]I had the same problem and it is because of new standards for the Golocation API in Chrome (and Safari):
Chrome no longer supports obtaining the user’s location using the HTML5 Geolocation API from pages delivered by non-secure connections.[/code]
This apparently also holds for local testing. Therefore I need to add a certificate. I will ask about this in a separate conversation but at least I have now certainty that local testing of location services is only working with https. (except for Firefox!)
Also with Firefox it is possible to test locally but not from the cloud. Apparently then Firefox also requires the web app to interact though een secure connection. Just handy to know.