Re: Problem simulating a location

2020-04-15 Thread Graham Samuel via use-livecode
Panos, this is solid gold as far as I’m concerned! I had no idea that 
mobileStartTrackingSensor would return control to the script without finishing 
its job, Wouldn’t it be better, since it isn’t blocking, to provide some sort 
of status token that could be queried by script? Thanks also for the note about 
the bug. I feel I can make progress!

Cheers

Graham

> On 15 Apr 2020, at 16:58, panagiotis merakos via use-livecode 
>  wrote:
> 
> 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@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
>>  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@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@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.

Re: Problem simulating a location

2020-04-15 Thread panagiotis merakos via use-livecode
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@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
>  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@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@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@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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___

Re: Problem simulating a location

2020-04-14 Thread Graham Samuel via use-livecode
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 
>  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 
>  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 
>>  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@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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Problem simulating a location (Graham Samuel)

2020-04-14 Thread Andrew at MidWest Coast Media via use-livecode
> 
> 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
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Problem simulating a location

2020-04-14 Thread Rick Harrison via use-livecode
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 
>  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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Problem simulating a location

2020-04-14 Thread Graham Samuel via use-livecode
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

> On 13 Apr 2020, at 14:38, Graham Samuel  wrote:
> 
> I’m trying to use the 10.2 XCode simulator to test an iOS app that uses the 
> phone’s ability to know its location (usually via GPS). I can run the 
> simulation and show that it’s working in a general way. Furthermore, 
> mobileSensorAvailable("location”) responds in the simulated app, saying the 
> sensor is ‘authorizedWhenInUse’
> 
> However the following button handler - adapted from a lesson by Devin Asay 
> (very sincere thanks for all that, Devin!) always returns an empty result. I 
> have set the location in the simulator to a (genuine) custom location, but if 
> I choose one of the built-in locations, I still get the same result.
> 
>  On mouseUp
>mobileStartTrackingSensor "location” -- enable the sensor first
>put "now trying to get a one-off location reading" & return after fld 
> “TheReport"
>put mobileSensorReading("location",false) into tSensorData -- this returns 
> a string with the current latitude, longitude and altitude
>mobileStopTrackingSensor “location” -- turn off the sensor when done
>if tSensorData is empty then
>put "no location info!!" & return after fld "TheReport"
>else
>put tSensorData & return after fld "TheReport"
>   end if
> end mouseUp
> 
> 
> Of course it’s me, but what am I doing wrong?
> 
> Graham


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Problem simulating a location

2020-04-13 Thread Alan Stenhouse via use-livecode
Hi Graham

IIRC, mobileSensorReading() returns an array so you need to check the keys of 
the array.

Perhaps:

if tSensorData["latitude"] is empty then


HTH

cheers

Alan

> On Mon, 13 Apr 2020 14:38:56,Graham Samuel  > wrote:
> 
> 
> I?m trying to use the 10.2 XCode simulator to test an iOS app that uses the 
> phone?s ability to know its location (usually via GPS). I can run the 
> simulation and show that it?s working in a general way. Furthermore, 
> mobileSensorAvailable("location?) responds in the simulated app, saying the 
> sensor is ?authorizedWhenInUse?
> 
> However the following button handler - adapted from a lesson by Devin Asay 
> (very sincere thanks for all that, Devin!) always returns an empty result. I 
> have set the location in the simulator to a (genuine) custom location, but if 
> I choose one of the built-in locations, I still get the same result.
> 
>  On mouseUp
>mobileStartTrackingSensor "location? -- enable the sensor first
>put "now trying to get a one-off location reading" & return after fld 
> ?TheReport"
>put mobileSensorReading("location",false) into tSensorData -- this returns 
> a string with the current latitude, longitude and altitude
>mobileStopTrackingSensor ?location? -- turn off the sensor when done
>if tSensorData is empty then
>put "no location info!!" & return after fld "TheReport"
>else
>put tSensorData & return after fld "TheReport"
>   end if
> end mouseUp
> 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode