Â
How to link to WhatsApp from a different app
iOS
iOS
There are several ways to have your iPhone application interact with WhatsApp: universal links, custom URL schemes, share extension, and the Document Interaction API.
Universal links
Universal links are the preferred method of linking to a WhatsApp account.
Use
https://wa.me/<number>
where the <number>
is a full phone number in international format. Omit any brackets, dashes, plus signs, and leading zeros when adding the phone number in international format.Examples:
Use:
https://wa.me/15551234567
Don't use:
https://wa.me/+001-(555)1234567
Universal links can also include a pre-filled message that will automatically appear in the text field of a chat. Use
https://wa.me/whatsappphonenumber/?text=urlencodedtext
where whatsappphonenumber
is a full phone number in international format and URL-encodedtext
is the URL-encoded pre-filled message.Example:
https://wa.me/15551234567?text=I'm%20interested%20in%20your%20car%20for%20sale
To create a link with just a pre-filled message, use
https://wa.me/?text=urlencodedtext
Example: https://wa.me/?text=I'm%20inquiring%20about%20the%20apartment%20listing`
Custom URL Scheme
Opening whatsapp:// URL with one of the following parameters, will open our app and perform a custom action.
URL | Parameters | Opens |
---|---|---|
app | - | The WhatsApp Messenger application |
send | New chat composer | |
| text | If present, this text will be pre-filled into message text input field on a conversation screen. |
The Objective-C call to open one of these URLs is as follows:
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL];
}
Be sure to include WhatsApp URL scheme in your application's Info.plist under LSApplicationQueriesSchemes key if you want to determine whether WhatsApp is installed on the user’s iPhone using -[UIApplication canOpenURL:].
Share Extension
Introduced in iOS 8.0, Share Extension provides a convenient way for any app to share content with other applications installed on user's iPhone. This is now the preferred way of sharing your content onto WhatsApp. The Share extension allows you to share up to 30 mixed media files. To use Share Extension, create an instance of UIActivityViewController and present it in your app. WhatsApp accepts the following types of content:
- text (UTI: public.plain-text)
- photos (UTI: public.image)
- videos (UTI: public.movie)
- audio notes and music files (UTI: public.audio)
- PDF documents (UTI: com.adobe.pdf)
- contact cards (UTI: public.vcard)
- web URLs (UTI: public.url)
Note: Editing when sharing from another app isn’t supported. If you’d like to make changes to your files before sharing them, you’ll need to first make changes in the app.
File size limits
You can upload up to 30 files at a time. The file size limits are:
- All Files: 2 GB
- Videos: 200 MB
- Images: 16 MB