sobh…here’s my listener, give it a try and you will see what is contained in event.data.
It looks for “custom” labels for email and phone so they don’t get dropped when importing.
It also looks for Zip Codes, they are now in caps. homeZIP for ex.
[lua]
local function onComplete( event )
print("")
print("")
print(“onComplete(event) / import Contact”)
print( “*********event.name:”, event.name );
print( “*********event.type:”, event.type );
– event.data is either a table or nil depending on the option chosen
print ( “***********event.data:”, event.data );
print("********** event.data.note == “, event.data.notes)
print(”********** event.data.lastName == “, event.data.lastName)
local firstName, lastName = “”, “”
– If there is event.data print it’s key/value pairs
if event.data then
if D then --create table to store Contact Info Data
D = nil
D = {}
else
D = {}
end
print( “********event.data: {” );
for k, v in pairs( event.data ) do
local kk, vv = k, v
if type( v ) == “note” then
vv = “note”
print(”***** vv = note ==", vv)
end
if type( v ) == “table” then
vv = “table”
print("****** table FOUND table == “, vv)
print(”****** table key == “, kk)
end
if type( v ) == “userdata” then
vv = “userdata”
print(”******* userData == “, userData)
end
if “notes” == k then
print(”********* notes == “, notes)
– else print (”******* NO notes")
end
if “note” == k then
print("********* note == “, note)
– else print (”******* NO note")
end
– Print the picture table
if “picture” == k then
for a, b in pairs( v ) do
print( a, b )
--PhotoFileName
if a == “fileName” then
D.fileName = b
print(">>>>>>>>>!!! Picture Key == “…a…” fileName == “…b)
end
end
end
--textBox.text = textBox.text … " " … kk … “: " … vv … “\n”
--displays each Key/Value pair in Table
--This will show “custom” labels for email and cell phone
print( k , “:” , v );
– Set the first name
if “string” == type( v ) then
– New Code to find Email Addresses and add “Email” to end of Key string
local EmailFlag1 = string.find(v, “@”)
local EmailFlag2 = string.find(v, “.”)
print(“EmailFlag1 == “, EmailFlag1)
if EmailFlag1 ~= nil and EmailFlag2 ~= nil then
print(“Email Address Found!!!”)
k = “”…k…“Email?”
D[””…k…””] = v
print(“emailKey : k == “…k…””)
– print(“D.k == “, D.k)
– print(“D[””…k…”"] == " …D[""…k…""]…")
end
--End New Code
--New Code to find phone numbers
local PhoneFlag2 = string.find(v, “%(%d%d%d%)”)
print(“PhoneFlag2 == “, PhoneFlag2)
print(“PhoneFlag2 k == “,k)
print(“PhoneFlag2 v == “,v)
if PhoneFlag2 ~= nil then
print(“PhoneNumber Found!!!”)
k = “”…k…“PhoneNumber?”
D[””…k…””] = v
print(“k == “…k…””)
– print(“D.k == “, D.k)
– print(“D[””…k…””] == " …D[”"…k…""]…")
end
– End Find Phone Number Code
--Names
if k == “firstName” then
D.firstName = v
– Set the second name
elseif k == “lastName” then
print("**********>>>>>>>>>>>>")
print("********** k == ‘lastName’ == “, k)
D.lastName = v
elseif k == “middleName” then
D.middleName = v
elseif k == “prefix” then
D.prefix = v
elseif k == “suffix” then
D.suffix = v
elseif k == “organization” then
D.organization = v
elseif k == “jobTitle” then
D.jobTitle = v
elseif k == “birthday” then
D.birthday = v
elseif k == “nickName” then
D.nickName = v
elseif k == “anniversary” then
D.anniversary = v
--[[] --PhotoFileName
elseif k == “fileName” then
print(”************* fileName == “…k…” / v == “…v)
D.fileName = v --]]
--Other
elseif k == “phoneticFirstName” then
D.phoneticFirstName = v
elseif k == “phoneticMiddleName” then
D.phoneticMiddleName = v
elseif k == “phoneticLastName” then
D.phoneticLastName = v
--Emails
elseif k == “homeEmail” then
D.homeEmail = v
print(”*** homeEmail FOUND!")
print(“D.homeEmail == “, D.homeEmail)
elseif k == “workEmail” then
D.workEmail = v
elseif k == “email” then
D.email = v
print(”…email found!”)
print("…D.email == “, D.email)
--Phone
elseif k == “phoneHome” then
D.phoneHome = v
elseif k == “phoneWork” then
D.phoneWork = v
elseif k == “phoneIphone” then
D.phoneIphone = v
elseif k == “phoneMobile” then
D.phoneMobile = v
elseif k == “phoneMain” then
D.phoneMain = v
elseif k == “note” then
D.notes = v
print(”******* note Found! note == “, D.notes)
elseif k == “notes” then
D.notes = v
print(”******* notes Found! notes == “, D.notes)
--fax
elseif k == “faxHome” then
D.faxHome = v
elseif k == “faxWork” then
D.faxWork = v
elseif k == “faxOther” then
D.faxOther = v
--pager
elseif k == “pager” then
D.pager = v
--URLS
elseif k == “homePageUrl” then
D.homePageUrl = v
elseif k == “workUrl” then
D.workUrl = v
elseif k == “homeUrl” then
D.homeUrl = v
--address
elseif k == “homeStreet” then
D.homeStreet = v
elseif k == “homeCity” then
D.homeCity = v
elseif k == “homeState” then
D.homeState = v
elseif k == “homeZIP” then
D.homeZip = v
elseif k == “homeCountry” then
D.homeCountry = v
elseif k == “workStreet” then
D.workStreet = v
elseif k == “workCity” then
D.workCity = v
elseif k == “workState” then
D.workState = v
elseif k == “workZIP” then
D.workZip = v
elseif k == “workCountry” then
D.workCountry = v
elseif k == “otherStreet” then
D.otherStreet = v
elseif k == “otherCity” then
D.otherCity = v
elseif k == “otherState” then
D.otherState = v
elseif k == “otherZIP” then
D.otherZip = v
elseif k == “otherCountry” then
D.otherCountry = v
elseif k == “otherStreet1” then
D.otherStreet1 = v
elseif k == “otherCity1” then
D.otherCity1 = v
elseif k == “otherState1” then
D.otherState1 = v
elseif k == “otherZip1” then
D.otherZip1 = v
elseif k == “otherCountry1” then
D.otherCountry1 = v
elseif k == “otherStreet2” then
D.otherStreet2 = v
elseif k == “otherCity2” then
D.otherCity2 = v
elseif k == “otherState2” then
D.otherState2 = v
elseif k == “otherZIP2” then
D.otherZip2 = v
elseif k == “otherCountry2” then
D.otherCountry2 = v
elseif k == “otherStreet3” then
D.otherStreet3 = v
elseif k == “otherCity3” then
D.otherCity3 = v
elseif k == “otherState3” then
D.otherState3 = v
elseif k == “otherZIP3” then
D.otherZip3 = v
elseif k == “otherCountry3” then
D.otherCountry3 = v
elseif k == “otherStreet4” then
D.otherStreet4 = v
elseif k == “otherCity4” then
D.otherCity4 = v
elseif k == “otherState4” then
D.otherState4 = v
elseif k == “otherZIP4” then
D.otherZip4 = v
elseif k == “otherCountry4” then
D.otherCountry4 = v
--People
elseif k == “father” then
D.father = v
elseif k == “mother” then
D.mother = v
elseif k == “parent” then
D.parent = v
elseif k == “brother” then
D.brother = v
elseif k == “sister” then
D.sister = v
elseif k == “child” then
D.child = v
elseif k == “friend” then
D.friend = v
elseif k == “spouse” then
D.spouse = v
elseif k == “partner” then
D.partner = v
elseif k == “assistant” then
D.assistant = v
elseif k == “manager” then
D.manager = v
--Social
elseif k == “socialFacebook” then
D.socialFacebook = v
elseif k == “socialTwitter” then
D.socialTwitter = v
elseif k == “socialGameCenter” then
D.socialGameCenter = v
elseif k == “socialFlickr” then
D.socialFlickr = v
elseif k == “socialLinkedIn” then
D.socialLinkedIn = v
elseif k == “socialMyspace” then
D.socialMyspace = v
elseif k == “socialSinaWeibo” then
D.socialSinaWeibo = v
elseif k == “instantMessagingFacebook” then
D.instantMessagingFacebook = v
elseif k == “instantMessagingAim” then
D.instantMessagingAim = v
elseif k == “instantMessagingGaduGadu” then
D.instantMessagingGaduGadu = v
elseif k == “instantMessagingGoogleTalk” then
D.instantMessagingGoogleTalk = v
elseif k == “instantMessagingICQ” then
D.instantMessagingICQ = v
elseif k == “linstantMessagingJabber” then
D.instantMessagingJabber = v
elseif k == “instantMessagingMSN” then
D.instantMessagingMSN = v
elseif k == “instantMessagingQQ” then
D.instantMessagingQQ = v
elseif k == “instantMessagingSkype” then
D.instantMessagingSkype = v
elseif k == “instantMessagingYahoo” then
D.instantMessagingYahoo = v
else
end
textBox.text = textBox.text … " " … kk … “: " … vv … “\n”
end
end
– Set the contacts name
– contactName.text = “Selected Contact:\n " … D.firstName … " " … D.lastName
local Name = “Selected Contact: \n”
if D.prefix then
if D.prefix ~= “” then
Name = “”…Name…””…D.prefix
end
end
if D.firstName then
if D.firstName ~= “” then
Name = Name…” “…D.firstName
end
end
if D.middleName then
if D.middleName ~= “” then
Name = Name…” “…D.middleName
end
end
if D.lastName then
if D.lastName ~= “” then
Name = Name…” “…D.lastName
end
end
if D.suffix then
if D.suffix ~= “” then
Name = Name…” “…D.suffix
end
end
– contactName.text = contactName.text…”\n\n"
--contactName.y = 85
if contactName then
display.remove(contactName)
contactName = nil
end
contactName = display.newText( Name, 10, 65, native.systemFontBold, 16 )
contactName:setReferencePoint(display.TopLeftReferencePoint)
contactName:setFillColor( 0, 0, 0 )
PickContactGroup:insert(contactName)
print( “}” );
print("…D.homeEmail == ", D.homeEmail)
end
end
[/lua]
Hope this helps.
Nail