Software Archive
Read-only legacy content
17060 Discussions

IOS wrong localization

Alain_M_1
Beginner
362 Views

Hi all,

I have to submit you a true poisonning problem on my App.

First of all, I give you two words about the app. I wrote several messages here for various problems, especially about builds. With accurate help of some people in this forum, they are all solved.

My App uses geolocalization and google maps to display the results, an sql/oracle database connected to the app bay ajax, and indexedDB for local storage of data (to prevent networks breach by synchronizing local stored data and the external SQl database).

It works perfectly on my Android smartphone and my Ipad/Wifi.

Now, I am in beta test phasis, so I asked to several friends to test the builds of my application on their phones, and we discovered a BIG PROBLEM.

Several users who tested the application received incorrect information from the geolocation functions of the XDK. When I say incorrect, I say really incorrect (several kilometers). Tests are made with 2 versions of the application 

The firtst uses the following code :

function getCurrentPosition()
{
navigator.geolocation.getCurrentPosition(function(position){
            PLat = position.coords.latitude;  
            PLng = position.coords.longitude;
            //alert( PLat + "|" + PLng);
            $("#fld_Lat").val(PLat);
            $("#fld_Lng").val(PLng);
        }, function(error){
            if(error.code == PositionError.PERMISSION_DENIED)
            {
                alert("App doesn't have permission to use GPS");
            }
            else if(error.code == PositionError.POSITION_UNAVAILABLE)
            {
                alert("No GPS device found");
            }
            else if(error.code == PositionError.TIMEOUT)
            {
                alert("Its taking too long find user location");
            }
            else
            {
                alert("An unknown error occured");
            }
        }, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });
}

The second uses the following code :

var gCSPsuc = function(p){
        //alert("geolocation success");
        if (p.coords.latitude != undefined)
        {
            PLat = p.coords.latitude;
            PLng= p.coords.longitude;

            $("#fld_Lat").val(PLat);
            $("#fld_Lng").val(PLng);
        }

    };
var gCSPfail = function(){ 
        alert("geolocation fails"); 
    };

function getCurrentSearchPosition()
{
if (! navigator.geolocation)
{
    alert("geolocation not available on this device.");
    return false;
}

intel.xdk.geolocation.getCurrentPosition(gCSPsuc,gCSPfail);

}

Both have same wrong results.

finally, one of the tester explained that the position returned bay the geolocation service is its office place, at more than 20km, where he was previously, several hours before.

Tested are realized on Iphone 5 and Iphone 6, with GPS activated, and both wifi on AND off.

My questions are :

1/ Is that trouble has been experimented before by some people here ?

2/ Is that an error on my functions, or a problem with the geolocation plugin ?

3/ Is anybody have a solution ?

4/ According to the fact that geolocalition is the central key of my app, do I consider that on xdk platform, this functionnality is not sure and do I have to completely change my developpment platform to make an application fully compatible with the main mobile OS on the market ?

Thanks for your help

Alain

 

0 Kudos
2 Replies
John_H_Intel2
Employee
362 Views

A couple things I noticed from your code.

1. You use getCurrent position. This just gets the current location one time. If the device was previously connected (say 20 km away), its possible that the device will provide this as the current position. Instead you should try using watchPosition. This will watch the position until you tell it to stop watching.

2. You used 

intel.xdk.geolocation.getCurrentPosition(gCSPsuc,gCSPfail);

in your second function. Stick to using the core Cordova plugins whenever possible, not the intel.xdk plugins.

 

Take a look at the example I attached.

0 Kudos
Alain_M_1
Beginner
362 Views

Hi John,

Nice to read you.

I used this fonction WatchPosition but I noticed some troubles with the fact it allways change the geo coordinates. Because I needed One time only this information, i prefered to uses gerCurrentPosition. But you're right, especillay on IOS, because the app is not reaaly closed, it is possible that my beta testers reuses old coordinates, or keep the one stored on not updated variables. So I will test your solution, clever, once again.

Thanks a lot

Alain

0 Kudos
Reply