ABID in Whatsapp URL Schemas

Whatsapp updated its iOS app yesterday and published the official URL scheme (api hooks).

I wanted to play a little with this, and now I am faced with the problem that I do not understand all this "plentiful" thing ?! How do I get the contact id? And how do I use it?

Thank you in advance:)

+4
ios whatsapp url-scheme
Jul 17 '13 at 22:24
source share
6 answers

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; } } 
+10
Jul 22 '13 at 14:52
source share

Note that Whatsapp removed (in March 16) a URL scheme to open a conversation with a specific contact.

As you can see on the Custom URLs Page page, there is no longer an ABID parameter.

+3
Mar 31 '16 at 15:40
source share

I wrote one way to get the ABID here: http://n8henrie.com/2014/02/how-to-get-the-abid-for-whatsapp-url-schemes/

The basic idea is to use iFunBox to access sqlite on your phone, then run a script that retrieves all ABIDs and names.

+2
Aug 18 '14 at 14:01
source share

Last two decisions (July 2017)

I found, tested and reviewed two new solutions in THIS ANOTHER ANSWER (because of SO policies I had to put a link to the solution, without duplicates).

+1
Jul 21 '17 at 0:43
source share

abid means the address book identifier, and this is the parameter that you use using the Whatsapp URL scheme to use the data that you have in the address book. From Whatsapp website .

To use the URL scheme for Whatsapp in your application to send text with the words "Hello World", you would do something like this (example from the site):

  NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; } 

But since you did not specify the code, I cannot say how to use it above or where to put it. But you can always check out some guidelines on using URL schemes if you need to.

Hope that answers your question!

0
Jul 17 '13 at 22:39
source share

To do this, you can get a list of contacts, and then send a message to a specific person.

  • Get the ID of an entry from the address book

     contactList=[[NSMutableArray alloc] init]; CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(m_addressbook); CFIndex nPeople = ABAddressBookGetPersonCount(m_addressbook); for (int i=0;i<nPeople;i++) { NSMutableDictionary *dOfPerson=[[NSMutableDictionary alloc] init]; ABRecordRef ref = CFArrayGetValueAtIndex(allPeople,i); NSNumber *recordId = [NSNumber numberWithInteger:ABRecordGetRecordID(ref)]; [dOfPerson setObject:recordId forKey:@"RecordID"]; [contactList addObject:dOfPerson]; } 
  • Get selected record id:

    NSString * recordID = [dict objectForKey: @ "RecordID"];

  • Call that application url scheme

     NSString *str = [NSString stringWithFormat:@"whatsapp://send?text=Whenitize&abid=%@",recordID]; NSLog(@"%@", str); NSURL *whatsappURL = [NSURL URLWithString:str]; if ([[UIApplication sharedApplication] canOpenURL:whatsappURL]) { [[UIApplication sharedApplication] openURL:whatsappURL]; } else { [[[UIAlertView alloc] initWithTitle:@"" message:@"Please install What App in your device." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; } 
-one
Oct 17 '14 at 10:01
source share



All Articles