Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20059] iOS: 'person' property in Ti.Contacts.showContacts is empty

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-12-01T07:08:43.000+0000
Affected Version/sRelease 5.1.0, Release 5.0.2
Fix Version/sRelease 5.2.0
ComponentsiOS
Labelscontacts, ios
Reporter Ricardo Ramirez
AssigneeSrikanth Sombhatla
Created2015-11-24T17:32:33.000+0000
Updated2016-01-14T22:43:32.000+0000

Description

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));
		}
	});
}

Comments

  1. Srikanth Sombhatla 2015-11-26

    [~rramirez], Can you point to the source/docs which describe the expected properties on person object?
  2. Chee Kiat Ng 2015-11-26

    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 of selectedPerson. 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.
  3. Ricardo Ramirez 2015-11-26

    Thanks [~cng] ! Please keep us updated.
  4. Srikanth Sombhatla 2015-11-27

    [~rramirez] The person object cannot be JSON stringified. But you can access it as
       e.person.fullName
       
    But be advised that in iOS 9 the person object is a partial object by default and not all properties are available.
  5. Chee Kiat Ng 2015-11-27

    We can consider to update the apidoc on this as a PR to explain what properties in the e.person object you can obtain.
  6. Srikanth Sombhatla 2015-12-01

    PR https://github.com/appcelerator/titanium_mobile/pull/7517 Docs are updated to add info about person property.
  7. Chee Kiat Ng 2015-12-01

    Approved. PR merged.
  8. Kristen Bachman 2015-12-01

    I tested e.person.fullName and it doesn't actually return the contact's name. It returns the string "No name".
  9. Chee Kiat Ng 2015-12-02

    [~bachmakm], which property did you select? Is this on iOS 9.1? May I know the device model or simulator?
  10. Kristen Bachman 2015-12-03

  11. Ricardo Ramirez 2015-12-03

    This is also happening if you use the 4.4.0.GA ?
  12. Ricardo Ramirez 2015-12-03

    NVM I was confusing Studio with SDK.
  13. Chee Kiat Ng 2015-12-04

    [~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?
  14. Kristen Bachman 2015-12-04

    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 the function open() header to function openThings().

    After starting the app and selecting a contact, select a mobile _phone number_.

    Crash.

    NOTE: If the method header isn't changed to openThings() from open() in index.js, the contacts list view will not open. This might be due to a scope issue with a this.open() call happening in the background.
  15. Srikanth Sombhatla 2015-12-14

    [~bachmakm] The reason it crashes on iOS 9.1 is because of TIMOB-20063. Can you reverify the same on SDK 5.1.2.
  16. Harry Bryant 2015-12-14

    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.
  17. Harry Bryant 2016-01-14

    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.*

JSON Source