Hello,
We are experiencing issues using the GetLocation plugin with our native mobile application on an iOS device, it is unclear how it works on Android at the moment. It works fine and returns the correct position during our OfflineDataSync flow, but now we are trying to implement it in an OnClick and it returns (0, 0) every time. The GetLocation action appears to be completing successfully and is not returning a timeout message. We are using MABS 9 on a iPhone X with iOS 16.7.2. The GetLocation timeout is set to 30000 ms, and I have tried setting EnableHighAccuracy to False but that didn't help. The Location should be near (39.622, -104.897). I have confirmed that Location Permissions are enabled on my device and for the specific application. I have attached a screenshot of the OnClick logic flow where the GetLocation is failing every time. Please advise.
Thanks,Charlie Highum
Hi Charlie Highum,
i tried with location i got the same 0,0 attaching the oml if you want to check. instead of using location plugin.
use this simple javascript
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
console.log(`Latitude: ${latitude}, Longitude: ${longitude}`);
});
} else {
console.log("Geolocation is not supported by this browser.");
}
hope this will help
Thanks
Prince
I'm confused, what is the attached OML supposed to be showing me? It does not appear to have the simple JavaScript code implemented, and that JavaScript code is not working in my application either as it also returns (0, 0) coordinates.
In attached oml the location plugin is used but it's not working the same returning value 0,0. I have given you javascript which you can use for get the location instead of plugin. Make changes as per your requirement. Sorry for the confusion.
Unfortunately the JavaScript is also returning a 0,0 value, so it doesn't seem like a viable solution in this case.
Open this html code and take javascript from here and implement into outsystems
https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation
I tried and it is returning values
I have tried playing around with your original code, that link, ChatGPT, and several other sources and everything is returning 0,0 coordinates. Do you have any idea why this might be happening?
its working.
for you, it doesn't mean it works for the original poster of the question.
as @Toto adviced, fixed oml i am attaching, and yes it is giving the Location cordinates
@Prince Aadil Khan Panwar
Apologies for the confusion, the W3Schools demo works for me as well, but when I transfer that exact code into my application it returns 0,0. Are there any required dependencies or scripts I might be missing?
Hi Charlie,
I tried to replicate your logic
With Timeout 30000ms and EnableHighAccuracy False
It is work on my Android.
What I can suggest is :1. Update the Location plugin (there is new version on 20th Dec 2023, version 5.2.1)2. Try to open map application on your iphone then back to your app and check the location (I often got this case on Chinese Android device (not mainstream brand), that the GPS got stuck and need to open GoogleMap app to "unstuck" it)
3. Connect your device to mac, and open safari, there is feature to get the device log (I am not a mac user, but my team member do this to debug ios device), similar like connecting android device to laptop, then open chrome : chrome://inspect/#devices (for android need to enable USB debugging)
4. Check the iphone permission for the GPS and app (https://support.apple.com/en-us/102647#:~:text=Go%20to%20Settings%20%3E%20Privacy%20%26%20Security%2C%20then%20select%20Location%20Services,Precise%20Location%20on%20or%20off.)
@Toto
Thank you for the suggestions. The GetLocation plugin has already been updated to the most recent version and all of my permissions are setup correctly. The GetLocation plugin is working in the app on my device in the OfflineDataSync flow, but for some reason is returning 0,0 in the OnClick action.
I will work on getting the device log through safari and see if I find anything there.
You have confirmed it works on an Android, but not on an iOS device.
Can you try the following actions to narrow the problems space:
Regards,
Daniel
I am sorry for the confusion. We have not tested on Android yet, I am working on getting other team members to test with different devices.
It doesn't make sense that the GetLocation plugin works when called through the OfflineDataSync and is returning the correct location, but then returns 0,0 without a failure message when using it in an OnClick. Can you think of any possible workarounds here?
I have tried to implement the custom JavaScript @Prince Aadil Khan Panwar recommended, and it worked in the browser in the W3Schools demo, but then when I transferred it to my app it also returns 0,0.
I will work on regenerating the app with MABS 8 to test that option as well. Are there any potential consequences of using MABS 8 vs 9?