Page 1 of 2

mobileGetContactData

Posted: Tue Aug 13, 2013 6:22 am
by William Jamieson
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

Re: mobileGetContactData

Posted: Wed Aug 21, 2013 2:27 pm
by LCNeil
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
--

Re: mobileGetContactData

Posted: Wed Aug 21, 2013 3:38 pm
by Klaus
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

Re: mobileGetContactData

Posted: Wed Aug 21, 2013 9:55 pm
by William Jamieson
@ 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**

Re: mobileGetContactData

Posted: Thu Aug 22, 2013 8:09 pm
by William Jamieson
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

Re: mobileGetContactData

Posted: Fri Aug 23, 2013 1:47 am
by Simon
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

Re: mobileGetContactData

Posted: Fri Aug 23, 2013 8:14 am
by William Jamieson
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?

Re: mobileGetContactData

Posted: Fri Aug 23, 2013 8:31 am
by Simon
I'd say yes.
They should have this sorted out for iOS. For Android that's another matter.

Simon

Re: mobileGetContactData

Posted: Sun Aug 25, 2013 4:38 am
by Simon
OK still haven't figured this out.
Neil's code is not working on Android 2.3 (I see why it should).

Simon

Re: mobileGetContactData

Posted: Mon Sep 02, 2013 7:42 pm
by Simon
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

Re: mobileGetContactData

Posted: Mon Sep 02, 2013 11:50 pm
by Jellicle
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

Re: mobileGetContactData

Posted: Wed Sep 11, 2013 1:29 pm
by LCNeil
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
--

Re: mobileGetContactData

Posted: Wed Sep 11, 2013 10:24 pm
by Simon
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

Re: mobileGetContactData

Posted: Wed Sep 11, 2013 11:41 pm
by Jellicle
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

Re: mobileGetContactData

Posted: Thu Sep 12, 2013 1:04 am
by Simon
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