Issue Description
On iOS, the callback event for both 'selectedProperty' and 'selectedPerson' of Ti.Contacts.showContacts has an empty value for the "person" property. When selecting a person from the contacts list, The expected behavior is to see an object attached to the person property that get the name of the contact (e.g., e.person.name).
The callback event for 'selectedProperty' returns:
{"value":"052255","property":"phone","label":"home","type":"selectedProperty","source":{},"person":{}}
Steps to replicate
-Create a new titanium alloy project
-Open the app folder
-Replace the index.xml file inside views folder and the index.js file inside controllers
-Build and run
-Click open
-Select a contact
Test Case
Index.xml
<Alloy>
<Window id="nav" backgroundColor="#fff">
<Button onClick="open">Open</Button>
</Window>
</Alloy>
Index.js
$.nav.open();
function open(){
Ti.Contacts.showContacts({
selectedProperty: function(e){
alert(JSON.stringify(e));
}
});
}
[~rramirez], Can you point to the source/docs which describe the expected properties on person object?
Hi, I have changed this from bug to improvement, because the person object has been empty since iOS 8.4, when we use
selectedProperty
instead ofselectedPerson
. And in our docs we never mentioned if there's going to be information inside that object. Will investigate to see if we can populate any other information about the person in the person object. The information may only be partial as stated here: https://developer.apple.com/library/prerelease/mac/documentation/Contacts/Reference/Contacts_Framework/index.html.Thanks [~cng] ! Please keep us updated.
[~rramirez] The person object cannot be JSON stringified. But you can access it as
But be advised that in iOS 9 the person object is a partial object by default and not all properties are available.
We can consider to update the apidoc on this as a PR to explain what properties in the e.person object you can obtain.
PR https://github.com/appcelerator/titanium_mobile/pull/7517 Docs are updated to add info about person property.
Approved. PR merged.
I tested
e.person.fullName
and it doesn't actually return the contact's name. It returns the string "No name".[~bachmakm], which property did you select? Is this on iOS 9.1? May I know the device model or simulator?
This is also happening if you use the 4.4.0.GA ?
NVM I was confusing Studio with SDK.
[~ssombhatla] can you look into the latest comment? contacts is managed differently between iOS8.4 and iOS 9.1. [~bachmakm] can you describe how to reproduce your crash in more detail please?
Steps to Reproduce
_Environment_ * *Device*: iOS 5s simulator (v 9.1) or iOS 5 device (v 9.1) * *Ti SDK*: 5.1.1GA * *Ti Studio Version*: 4.4.0.201511241829-24112015183016 _Replicate_ In order to reproduce, follow the steps in the original issue description, but with a couple minor changes:In
index.xml
change<Button onClick="open">Open</Button>
to<Button onClick="openThings">Open</Button>
.In
index.js
change thefunction open()
header tofunction openThings()
.After starting the app and selecting a contact, select a mobile _phone number_.
Crash.
NOTE: If the method header isn't changed toopenThings()
fromopen()
inindex.js
, the contacts list view will not open. This might be due to a scope issue with athis.open()
call happening in the background.[~bachmakm] The reason it crashes on iOS 9.1 is because of TIMOB-20063. Can you reverify the same on SDK 5.1.2.
Tested [~bachmakm] 's steps, and was able to reproduce the issue when building with the 5.1.1GA SDK. When built with SDK:
5.1.2.v20151208161231
the issue was no longer reproducible.Verifying ticket as fixed - in regards to the issue occurring where selectedProperty causes an app crash. This issue is no longer reproducible when built with SDK 5.2.0 Tested on: iPhone 6s Plus Device (9.2) & iPhone 6 Plus Device (8.4) Mac OSX El Capitan 10.11 (15A284) Ti SDK: 5.2.0.v20160114021251 Appc NPM: 4.2.2 App CLI: 5.2.0-220 Xcode 7.2 Node v4.2.3 *Closing Ticket.*