ABID stands for the Address book Record ID,the code below works to get the AB Record ID. It is sensitive to the use of delimeters in the URL itself. So the initial trials were not working. To send a note to a specific user use this - urlstring format:
whatsapp://send?abid=123&text=What%20a%20nice%20day - note the use of & to mark the second parameter.
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
{
QR_whatsappABID = (ABRecordID)ABRecordGetRecordID(person);
....
QR_whatsapp_string = [NSString stringWithFormat:@"whatsapp://send?abid=%d&text=%@;",QR_whatsappABID, outmessage];
....
}
this can be coded without using the people picker simply open the address book:
go through the records one by one comparing the name or name and number -
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions (NULL, error);
int len = (int)ABAddressBookGetPersonCount(addressBook);
for(int i = 1; i < (len + 1); i++) {
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, (ABRecordID)i);
NSString *first, *last;
if (!person) {
continue;
}
CFStringRef firstc = (CFStringRef)ABRecordCopyValue(person, kABPersonFirstNameProperty);
if (firstc) {
CFStringRef lastc =(CFStringRef) ABRecordCopyValue(person, kABPersonLastNameProperty);
if (lastc) {
first = [NSString stringWithFormat:@"%@",firstc];
last =[NSString stringWithFormat:@"%@",lastc];
CFRelease(lastc);
}
CFRelease(firstc);
}
if ([[first lowercaseString] isEqualToString:[firstname lowercaseString]] && [[last lowercaseString] isEqualToString:[surname lowercaseString]]) {
alreadyExists = YES;
ABID = ABRecordGetRecordID(person);
break;
}
}