[TIMOB-19508] iOS9: Properties of person is unavailable (module Ti.Contacts)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-09-14T13:45:49.000+0000 |
Affected Version/s | Release 5.0.0 |
Fix Version/s | Release 5.0.0 |
Components | iOS |
Labels | Ti.Contacts, qe-automation, regression |
Reporter | THOMAS LEMAITRE |
Assignee | Chee Kiat Ng |
Created | 2015-09-11T14:19:10.000+0000 |
Updated | 2015-10-01T18:19:47.000+0000 |
Description
I tested my app and i appears that the module Ti.Contacts is broken. In fact, you can only get the properties "identifier" of a person. Other properties is unavailable and causing crash of the app.
var people = Ti.Contacts.getAllPeople(),
person = null;
for (var i=0, ilen=people.length; i<ilen; i++){
var person = people[i];
Ti.API.log('identifier ' + person.getIdentifier()); //works
Ti.API.log('firstName ' + person.getFirstName()); // didn't works
Ti.API.log('middleName ' + person.getMiddleName()); // didn't works
Ti.API.log('lastName ' + person.getLastName()); // didn't works
//... etc for all other properties of Person except "identifier"
}
Master PR:https://github.com/appcelerator/titanium_mobile/pull/7177 backport 5_0_X: https://github.com/appcelerator/titanium_mobile/pull/7178
PRs approved and merged.
The fix works when we build using iOS SDK 9.0. However, if the app is build using iOS SDK 8.4, then the getAllPeople returns zero contacts even though there are contacts. Hence, it would not output any details in the sample code. Mac OS 10.10.5 Titanium CLI: 5.0.1 SDK: 5.0.0.v20150914021515 Xcode: 7 GM seed
The reason why it's not working for iOS 8.4 is because the older version of contacts require the developer to explicitly request for permission to access the addressbook. Please use this sample code instead:
*Note:* getId() is for iOS8, and is replaced with getIdentifier() for iOS9. So expect to see identifier = undefined when run in iOS8.
[~bhatfield] looks like an issue for Release Notes.
Contact properties shown. Also checked when build with iOS 8.4 and using code for Kiat that explicitly asks for Contacts permission. Verified on: Mac OS 10.10.5 Appc CLI NPM: 4.2.0-8 Appc CLI Core: 5.0.0-51 Titanium CLI: 5.0.3 Appc Studio: 4.3.0.201509140942 SDK: 5.0.0.v20150914163105 Xcode: 7 GM seed
[~cng] In your note, shouldn't it be *recordId* for iOS 8? *id* is marked as an Android-only property for Ti.Contacts.Person. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Contacts.Person-property-recordId http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Contacts.Person-property-id
my bad. i meant *recordId* for iOS 8.