Yesterday Whatsapp updated their iOS application and released official URL scheme (api hooks).
I wanted to play a little with it and I'm now facing the problem that I don't understand this whole "abid" thing?! Where do I get the contact ID from? And how do I have to use it then?
Thanks in advance :)
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With