Description
Can not add the phone number to the contact list using [setPhone](
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Contacts.Person-method-setPhone) method.
Steps To Reproduce
1. Just run the following code to the device.
2. Click the add button then check the phone contact.
var win = Titanium.UI.createWindow({
title : 'Add Phone',
backgroundColor : '#fff',
layout : 'vertical'
});
// Create a Button.
var add = Ti.UI.createButton({
title : 'Add Number',
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
top : 50,
});
var person = Ti.Contacts.createPerson({
firstName : 'fname',
lastName : 'lname',
});
// Listen for click events.
add.addEventListener('click', function() {
var number = {
phone : {
mobile : ['01723306519']
}
};
person.setPhone(number);
Ti.API.info('Contact saved');
});
// Add to the parent view.
win.add(add);
win.open();
[ERROR] : Script Error {
[ERROR] : column = 17;
[ERROR] : line = 32;
[ERROR] : message = "*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray";
[ERROR] : stack = "[native code]\n";
[ERROR] : }
The "phone" argument should be set when creating the person, I don't think the (manual) setters should even be in the docs. Better:
Please give it a try. *EDIT*: And for the case it has to be added to an existing contact, we'd need to investigate it.
This ticket is invalid. The "phone" key should not be there of course, you are already specifying the property to set in the setter. Working code:
Closing ticket as invalid with reference to the above comments.