ABID stands for the address book entry identifier, the code below works to get the AB entry identifier. It is sensitive to the use of delimiters in the URL itself. Thus, the initial tests did not work. To send a note to a specific user, use this format - urlstring: whatsapp: // send? abid = 123 & text = That% 20a% 20nice% 20day - pay attention to the use and 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 encoded without using the people picker, just open the address book:
look through the records one by one, comparing the name, 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; } }
Paulo Jul 22 '13 at 14:52 2013-07-22 14:52
source share