This Week's Sponsor:

Kolide

Ensure that if a device isn’t secure it can’t access your apps.  It’s Device Trust for Okta.


Use WhatsApp’s URL Scheme with Drafts, Launch Center Pro, Or A Bookmarklet

WhatsApp

WhatsApp

I don’t use WhatsApp much[1], but when I saw the app’s documentation last night with a mention of the URL scheme, I thought I could play around with it a little bit.

The WhatsApp URL scheme is extremely basic and there’s one part that I can’t get to work. The scheme itself is, unsurprisingly, whatsapp:// – which you can use from Launch Center Pro if you simply want to launch WhatsApp. There are also parameters to do stuff with the URL scheme: text lets you pass along a (properly encoded) text message that will be automatically inserted in the compose field of the app; abid lets you specificy an “Address Book ID” to send a message to a specific contact.

The WhatsApp team explains:

Address book ID of contact to start a chat with. If contact with this ID has only one whatsapp-able phone number, application will open a conversation with that contact. If contact with this ID has more than one whatsapp-able phone numbers, application will present a menu with all phone numbers available for chat. If contact has no whatsapp-able phone numbers, or contact with this ID does not exist, or this parameter is missing, application will present contact picker listing all contacts available for chat via WhatsApp.

I thought that something like the following URL would have let me send the text message “Test” to my contact “Alex”:

whatsapp://send?abid=Alex&text=Test

But, in practice, I wasn’t able to get the abid parameter to work. I have tried with phone numbers, percent-encoded names and phone numbers, email addresses, but I can’t get WhatsApp to recognize the abid parameter I pass along, as the app continues to present a contact picker. Therefore, for the purpose of this post, I will show you how to send text to WhatsApp, choosing a recipient from the app’s built-in contact picker. If you manage to get abid to work, please let me know.

The URL scheme and text parameter can be easily integrated with apps like Launch Center Pro and Drafts. In Launch Center Pro, create an action that lets you write a message in a keyboard prompt, launching WhatsApp with your text already there:

whatsapp://send?text=[[prompt]]

WhatsApp

WhatsApp

Whereas in Drafts, you can use the app’s tags to send the contents of a draft to WhatsApp with a URL action:

whatsapp://send?text=[[draft]]

If you want to go one step further, you can use a bookmarklet to send the URL of the current webpage to a contact in your WhatsApp address book:

javascript:window.location='whatsapp://send?text='+encodeURIComponent(location.href);

Update: Thanks to reader Ernesto Miquel, I managed to get the “Address Book ID” parameter to work. Essentially, the ID is a unique string that WhatsApp associates with each contact in your buddy list. While it may be possible for developers to get this ID with the iOS SDK, there is a workaround for normal users as well.

With the latest update, WhatsApp lets you backup your chat history to iCloud, and, as we know, iCloud data can be browsed on a Mac inside the Mobile Documents folder. To find the ID of a WhatsApp user, you’ll need to back up WhatsApp to iCloud, then find the WhatsApp folder on your Mac’s Mobile Documents folder; inside that folder, navigate to Accounts, then your account’s name or phone number, then “backup”, and you’ll find a file called ChatStorage.sqlite. Copy the file, and download the free SQLite Database Browser for Mac.

Open the file, click Browse Data, and choose “ZWACHATSESSION” from the Table dropdown menu. Here, you’ll find the chat sessions you’ve backed up, with fields such as “partner name” and “last message”. Alongside these fields, you’ll also see “ZCONTACTABID”, which for me was a series of three digits-long IDs for my WhatsApp contacts.

With the ID, you can then tweak the URL scheme and launch WhatsApp with a message composed in Launch Center Pro/Drafts and directly into a specific chat session:

whatsapp://send?abid=122&text=[[prompt]]

WhatsApp is free on the App Store.


  1. “Much” as in only a couple of times each day. From what I’ve seen, the service has been more reliable than Apple’s iMessage (I’ve never seen a WhatsApp downtime myself) and the app’s media attachment options make more sense than Messages’ for me. Too bad it’s got no iPad or Mac clients. ↩︎

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.