mobileGetContactData

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

mobileGetContactData

Post by William Jamieson » Tue Aug 13, 2013 6:22 am

Ok so I know that this function is in the library, but I have not found many examples online so thought we could share some knowledge on this function.

So far I can get the "mobileGetContactData" function to return the first name of the contacts using the script below. However, I have not succeeded in getting phone numbers, emails, etc.

Is anyone familiar with this function and know how to get the other data from the phone's internal contact database?

Code: Select all

on retrieveContacts
   lock screen
   ## This is just a small sample so it doesn't take too long
   repeat with x = 100 to 125
      put mobileGetContactData(x) into theData[Contact]
      put theData[contact]["firstname"] into tContact
      put tContact & cr after field "contacts" of me
   end repeat
   unlock screen
end retrieveContacts

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: mobileGetContactData

Post by LCNeil » Wed Aug 21, 2013 2:27 pm

Dear William,

Thank you for your request.

As mobileGetContactData puts all data relating to a specific contact into an array it should be possible to use the combine command to return this data as a list.

The following example should help with getting you started

Code: Select all

on mouseUp
   repeat with x = 1 to 10
      put mobileGetContactData(x) into theData
       combine theData with space
       put theData& cr after field "contacts"
   end repeat
end mouseUp 
Kind Regards,

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
--

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: mobileGetContactData

Post by Klaus » Wed Aug 21, 2013 3:38 pm

Hi Neil,
runrevneil wrote:...
Thank you for your request.
although this is indeed very polite, it seems "une peu deplacée" here in my opinion.
This is the (less formal) forum and not "support@runrev.com" 8-)


Best

Klaus

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: mobileGetContactData

Post by William Jamieson » Wed Aug 21, 2013 9:55 pm

@ Klaus: Youre definitely right on the spot. I emailed Neil at support for help because no one posted. Didn't know what else to do.

So thank you so much Neil for helping me out!

And you are very observant Klaus**

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: mobileGetContactData

Post by William Jamieson » Thu Aug 22, 2013 8:09 pm

So I tried the handler that you posted and I am still faced with the same issue. The only data that is put into field "contacts" is the first name. I know by looking in my contact list that the contacts listed have at least phone numbers as well. So I am still perplexed as to how to get phone numbers and other such data to appear.I also noticed that for an address book of 1000 contacts, this handler will take an extremely long amount of time, even with locking the screen.

I just downloaded the app "Viber" which in half a second after install had all my contacts listed with their phone numbers already compared to the Viber database in their app. I am really curious to how I can create something like that.

Any help with this or insights would be much appreciated. Thanks.

-Will

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobileGetContactData

Post by Simon » Fri Aug 23, 2013 1:47 am

Hi Will,
I'm with you there is something odd about mobileGetContactData
But using your original code did you try:

Code: Select all

put theData[contact]["lastname"] into tContact
and "mobile" etc?

On my Android I only get 1 contact back using Neil's code. Seems that my contacts may not have numeric ID's, I get 9 blank lines after the first one.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: mobileGetContactData

Post by William Jamieson » Fri Aug 23, 2013 8:14 am

So I have tried calling "LastName", "Phone", "Email" and so on and so forth and none of them respond a value. given most of them do not have emails, but i sample 100 contact ID's when testing. about 20 to 30 show up in the range. All of them with phone numbers. The only thing that came up was a really weird facebook id marker from a previous phone on 2 of the contacts???

So I still don't get how to use it. Should I email Neil again?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobileGetContactData

Post by Simon » Fri Aug 23, 2013 8:31 am

I'd say yes.
They should have this sorted out for iOS. For Android that's another matter.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobileGetContactData

Post by Simon » Sun Aug 25, 2013 4:38 am

OK still haven't figured this out.
Neil's code is not working on Android 2.3 (I see why it should).

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobileGetContactData

Post by Simon » Mon Sep 02, 2013 7:42 pm

Hi Will,
I understand that you posted a bug report on this?
Could you provide me with it's number so I can follow up?

Thanks,
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: mobileGetContactData

Post by Jellicle » Mon Sep 02, 2013 11:50 pm

Using Neil's code I get back the names and notes fields (only) for the first 10 contacts in the simulator's address book.

I've tried mobileGetContactData before and found it to be weird and (it seems) buggy.

Neil, some good working examples would be good :)

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: mobileGetContactData

Post by LCNeil » Wed Sep 11, 2013 1:29 pm

Hi William et al

Apologies for the delayed response.

The code I provided will should provide data in regards to the array that is created. My initial tests on iOS returned my contacts data, but this seems to not work as expected on iOS.

I have spoken to Hanson from our Quality Control Team regarding this and he has mentioned that using the combine command does not offer this kind of processing and returns the "empty" string if nested data is found. This should explain why it was not working.

More information on this can be found on the bug report here-

http://quality.runrev.com/show_bug.cgi?id=11163

Hanson has also provided a more advanced stack that should be able to assist with extracting the specific contact data that you need. I have attached that stack to this reply.

Kind Regards,

Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
--
Attachments
Mobile Contact Retrieve.livecode.zip
(3.63 KiB) Downloaded 396 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobileGetContactData

Post by Simon » Wed Sep 11, 2013 10:24 pm

Interesting
RESOLVED NOT_A_BUG
Maybe the bug is in the documentation then? :D

On my Android 2.3 I'm not seeing sequential ID's, they go from 75 to somewhere in the 4000 range (I don't have that many contacts). Not saying this is wrong, just pointing out that "if it is empty then next repeat" should be taken into account.

Thanks for the stack, it does show some info which will allow me to better take the problems apart.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: mobileGetContactData

Post by Jellicle » Wed Sep 11, 2013 11:41 pm

runrevneil wrote: Hanson has also provided a more advanced stack that should be able to assist with extracting the specific contact data that you need. I have attached that stack to this reply.
The example stack doesn't seem to work at all. The display button returns nothing into the field - the retrieve button seems to put something (empty lines, perhaps?) into the field...but it isn't the contact details text :(

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: mobileGetContactData

Post by Simon » Thu Sep 12, 2013 1:04 am

Hi Gerry,
My old HTC was crashing with the Display button so I added

Code: Select all

   repeat for each item tContact in tContactIds
      add 1 to N
      put tContact & cr after field "contacts"
      put mobileGetContactData(tContact) into theData
      put displayArrayData (theData, "") & cr after field "contacts"
      if N = 5 then exit repeat
   end repeat
that counter just so I could see the first few.
That showed me that

Code: Select all

--put theData[contact]["phone"]["mobile"]into tMobile
--should be
put theData[contact]["phone"]["mobile"]["1"] into tMobile
I just showed the ID's by:

Code: Select all

   repeat for each item tContact in tContactIds
      put tContact & cr after field "contacts"
     -- put mobileGetContactData(tContact) into theData
      --put displayArrayData (theData, "") & cr after field "contacts"
   end repeat
Which told me I didn't have sequential ID's.

Oh, I also set the field text color to black because I did see the empty field, don't know if that was necessary.


Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply