Problem simulating a location

panagiotis merakos merakosp at gmail.com
Wed Apr 15 10:58:12 EDT 2020


Hello Graham,

I have done a couple of tweaks to your code, and I can now successfully
read the location data from the simulator.

First thing - it is not suggested to call all these 3 commands/functions in
one go:

mobileStartTrackingSensor
mobileSensorReading()
mobileStopTrackingSensor

as the "mobileStartTrackingSensor" command takes some time for the sensors
to start tracking. So a good place to add this would be on openCard, or in
a separate button.

Similarly, I have removed the "mobileStopTrackingSensor" from the button
script, and have put it on the closeCard handler (you can but it in a
separate button for your testing if you wish)

So the main button code becomes:

On mouseUp
   put "now trying to get a one-off location reading" & return after fld
"TheReport"
   put mobileSensorReading("location",true) into tSensorData -- this
returns a string with the current latitude, longitude and altitude
   if tSensorData is empty then
      put "no location info!!" & return after fld "TheReport"
   else
      put tSensorData & return after fld "TheReport"
   end if
end mouseUp

However, it seems there is a bug in the function
mobileSensorReading("location",false)

which will be fixed asap

You can workaround this bug by using the "detailed" form of this function,
i.e. mobileSensorReading("location",true)

Note that the "detailed" form returns an array instead of a comma separated
list, so you have to modify the script as follows:

On mouseUp
   put "now trying to get a one-off location reading" & return after fld
"TheReport"
   put mobileSensorReading("location",true) into tSensorData -- this
returns a string with the current latitude, longitude and altitude
   if tSensorData is empty then
      put "no location info!!" & return after fld "TheReport"
   else
      combine tSensorData using return and ":"
      put tSensorData & return after fld "TheReport"
   end if
end mouseUp

Also, in the Simulator menubar, choose a location such as "City Run" or
"Freeway Drive" so as you could see the changes.

Hope this helps.

Kind regards,
Panos
--

On Tue, 14 Apr 2020 at 21:14, Graham Samuel via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Gents, thank you. Good advice, and I’m taking it! I will report back.
>
> Graham
>
> > On 14 Apr 2020, at 19:39, Andrew at MidWest Coast Media via use-livecode
> <use-livecode at lists.runrev.com> wrote:
> >
> >>
> >> From: Graham Samuel
> >> I suppose I can try the test on a real phone, but I would rather stick
> to the simulator for now.
> > If you have a physical device, regardless of age, try it. There are some
> things that either don’t work (like camera) or are spotty in the emulator.
> >
> >
> >> And I haven?t found out how LC knows I?ve got a provisioning profile
> (separate problem I admit).
> >
> > When you download from the Apple Developer site, just double-click the
> provisioning profile to open it in Xcode. Livecode will know it’s installed
> next time you open the Save As Standalone window (but won’t recognize if
> you install while that window is open)
> >>
> > —Andrew Bell
>
> > On 14 Apr 2020, at 17:33, Rick Harrison via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >
> > Hi Graham,
> >
> > You should really try it on the phone before knocking yourself out
> > about why it doesn’t work on the simulator.  I have found that
> > some things involving sensors simply don’t work on the simulator.
> >
> > Try that, if it doesn’t work on the phone let us know.
> >
> > Good luck!
> >
> > Rick
> >
> >> On Apr 14, 2020, at 11:18 AM, Graham Samuel via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >>
> >> Folks, I am still struggling with this. Alan Stenhouse has been kind
> enough to help me, but so far I have not got the simulator to simulate any
> kind of location information.
> >>
> >> There is a function, mobileCurrentLocation, that is supposed to return
> an array provided tracking is enabled and mobileSensorAvailable(“location”)
> has been invoked (see the LC Dictionary). I have made sure that both these
> things have  been done, but In my tests on the simulator the array appears
> to be empty.
> >>
> >> I suppose I can try the test on a real phone, but I would rather stick
> to the simulator for now. And I haven’t found out how LC knows I’ve got a
> provisioning profile (separate problem I admit).
> >>
> >> Has anyone got any idea what’s going wrong?
> >>
> >> Puzzled.
> >>
> >> Graham
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list