Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Geolocation API on Companion does not work on SDK5

The piece of code below works on All simulator versions, SDK4 but not on SDK5.

 

Though the Versa 3 and Sense have a built in GPS, I would like to get the location from the phone as the fix is faster and the chance is high that it had a recent location.

 

The **ahem** object is empty when running it on an Fitbit sense using a sideloaded app.

 

var GPSFix = false;
var GPSoptions = {
    enableHighAccuracy: true,
    maximumAge: 600000,

};

geolocation.getCurrentPosition(locationSuccess, locationError, GPSoptions);

function locationSuccess(**ahem**){
  console.log("companion:location found"+JSON.stringify(**ahem**));
  GPSFix = true;
  sendFile("GPSPosition.txt",**ahem**);

}

.

 

Best Answer
0 Votes
3 REPLIES 3

I assume you're testing this outside? Have you checked that the Fitbit Exercise app is actually getting a GPS fix? I was testing my Alpine Snow app and it took quite a while to get the very first fix, but was ok after that.

Best Answer
0 Votes

Jon,

 

Well, the LocationSucces function got an empty object. I guess the LocationSuccess function is only called when a GPS fix was made. I was indoors, at a window. And my phone gets a gps signal when I'm at this window. 

 

BTW that **ahem** is a santiy filter on this forum? I don't know that position without "ition" means in Enlish, but it must be bad.

Best Answer
0 Votes

Hi @JonFitbit ,

 

I assume this bug is on the issue list of fitbit? 

 

Today I did some more test. The position object passed to the locationSuccess function is always empty on SDK5. I'm using a Huawei P10, which is not supported, but it does work on sdk4.

 

It does not matter if I use getCurrentPosition or Watchposition. If I run google maps in the background to be sure that my GPS is active, it still gives an empty object.

 

It is not a major issue, but there are use cases when it makes more sense to use the phones GPS instead of the built in GPS. For example, I use it to fetch some data from the open Wheater API.

Best Answer
0 Votes