Page 1 of 1

mobileGetContactData to get users URL

Posted: Thu Aug 31, 2017 4:22 am
by quailcreek
Hi,
I'm using mobileGetContactData to gather a contacts info. I can get everything except the contacts website. I created some dummy contacts on my phone for testing so I know there is a website there. What am I doing wrong? Thanks in advance.

Code: Select all

put theData[contact]["URL"]["home"]["1"] into theHomeWebsite
mobileControlSet "Website","text", theHomeWebsite
I running LC 8.1.6

Re: mobileGetContactData to get users URL

Posted: Sun Sep 03, 2017 7:44 pm
by quailcreek
So is this the correct syntax? If so, it's not working.

Code: Select all

 put theData[contact]["URL"]["home"]["1"] into theHomeWebsite

Re: mobileGetContactData to get users URL

Posted: Fri Sep 08, 2017 8:19 pm
by dave.kilroy
Tom I've never used mobileGetContactData but am guessing it's giving you an array of data which you're putting into 'theData' - if so then you can query this array to find out what keys it holds (at multiple levels) so you can be sure you're calling the right element of the array. For example the follow code (untested) should display the keys (at the top level) of the array

Code: Select all

put the keys of theData into tKeysTopLevel
answer tKeysTopLevel

Re: mobileGetContactData to get users URL

Posted: Fri Sep 08, 2017 8:27 pm
by dave.kilroy
Although, looking at the mobileGetContactData in the dictionary, the structure of what is returned looks very different to what you posted (but maybe the dictionary is out of date - it has also been known to be wrong!)

Re: mobileGetContactData to get users URL

Posted: Fri Sep 08, 2017 10:29 pm
by quailcreek
Hi Dave,
Thanks for the reply. I've attached a stack that shows what I'm doing. I even edited the contact in the sim to have a home website and still no joy. Everything gets pulled for the contact except the url/website data both in the iPhone sim and device. It fails on the Android sim at the point where I check if the data is an array. That's odd because the documentation says mobileGetContactData is supposed to work on both.
Pull data from contacts.livecode.zip
(4.96 KiB) Downloaded 242 times

Re: mobileGetContactData to get users URL

Posted: Sun Sep 10, 2017 6:57 am
by quailcreek
I figured out why it was failing on Android. I needed to check Read Contacts under Application Permissions.

Re: mobileGetContactData to get users URL

Posted: Sun Sep 10, 2017 12:18 pm
by dave.kilroy
Tom I think you've found a bug (or bugs) in how mobileGetContactData() operates - testing it here [LC 8.1.7(rc1), OS X 10.12.6 iPhone 6s running 10.3] it gives buggy results - sometimes data returned from a contact found with mobilePickContact returns ok, sometimes I only get partial data (a bit like you not getting the url), and sometimes I get a hard crash - mobileGetContactData() crashes and I can't even get it report the result...

I didn't try it on Android - I suggest you go to quality.livecode.com and report what you've found (upload your little test stack), if you then add a link to the bug report here in this thread I'll add a comment to the bug report mentioning my findings

Regards

Dave

Re: mobileGetContactData to get users URL

Posted: Sun Sep 10, 2017 7:51 pm
by quailcreek
Hi Dave,
Thanks for the feedback. I've reported bugs before so I know the procedure. :D I think the reason you're getting partial data is because, right now, I'm only checking for Home data. Maybe the "missing" information from your contact contains Work data.

Re: mobileGetContactData to get users URL

Posted: Sun Sep 10, 2017 8:35 pm
by dave.kilroy
Hey Tom - BTW I tweaked your stack here and when looking at some of contacts on my device I can see that the array produced by mobileGetContactData() is missing some keys and data - and for at least two of my contacts the app crashes hard. In fact I made a new test contact right on the phone and mobileGetContactData() could only get some of it's data...

So definitely buggy :shock:

Re: mobileGetContactData to get users URL

Posted: Sun Sep 10, 2017 11:27 pm
by quailcreek
Here's a link to the bug report.
http://quality.livecode.com/show_bug.cgi?id=20358