I have used to ContactsManager of Kekiiwaa (https://github.com/Kekiiwaa/ContactsManager) and I dont know how to add a contact with multiple phone. Here is sample code for adding contact with one phone:
[self.contactsManager addContactName: @"Tefany"
lastName: @"Jhonson"
phones: @[@{@"label":@"mobile",@"value":@"731782982"}]
emails: @[@{@"label":@"work",@"value":@"[email protected]"}]
birthday: nil completion:^(BOOL wasAdded) {
NSLog(@"%i",wasAdded);
}];
SO HOW DO I ADD CONTACT WITH MULTIPLE PHONE? I try to use:
@[@{@"label":@"mobile",@"value":@"999999999999”},@{@"label":@"mobile",@"value":@"999999999999"}]
But It's won't work.
P/s: sorry with my bad English skill, thanks for your help!
Oh, i have just done. The problem is here:
[phonesList enumerateObjectsUsingBlock:^(NSDictionary *phone, NSUInteger idx, BOOL *stop) {
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(multiPhone, (__bridge CFTypeRef)(phone[@"value"]), (__bridge CFStringRef)(phone[@"label"]), NULL);
ABRecordSetValue(record, kABPersonPhoneProperty, multiPhone, nil);
}];
The lib is redeclaring with each dictionary in ARRAY phoneList, so the phone is created new instead adding to existing contact. So I think to add a contact with multiple phone number, need to get the multiphone out side block. And I have done with this:
ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
[phonesList enumerateObjectsUsingBlock:^(NSDictionary *phone, NSUInteger idx, BOOL *stop) {
ABMultiValueAddValueAndLabel(multiPhone, (__bridge CFTypeRef)(phone[@"value"]), (__bridge CFStringRef)(phone[@"label"]), NULL);
ABRecordSetValue(record, kABPersonPhoneProperty, multiPhone, nil);
}];