I want to use whatsapp in my app to send message to other phone. I have seen this public API for whatsapp on Github, here. But I dont find that API for iOS. So is that possible to use whatsapp in iOS app? And is that legal? And where can I find public API of whatsapp for iOS?
Asked
Active
Viewed 1.6k times
5 Answers
11
yes, you can use the whatsapp for sending text/ images through you ios app. there are two ways to do so 1. URL scheme
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
- UIDocumentInteraction see the link below http://www.whatsapp.com/faq/en/iphone/23559013

NSAnant
- 816
- 8
- 18
2
Yes you can through :
- URL scheme
- UIDocumentInteraction
As @NSAnant mentioned
Just in case you are coding an hybrid app (Cordova,phonegap,etc) a simple anchor with the URL Scheme from Whatsapp FAQ will solve the issue (integrate WhatsApp into my app)
<a href="whatsapp://send?text=666isthenumberofthebeast" id="my_button" class="button_default button_color">Send Whatsapp Friendly Message</a>

d1jhoni1b
- 7,497
- 1
- 51
- 37
0
Is as simple as this. Hope it helps ;-)
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%20world"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
//WhatsApp is installed in your device and you can use it.
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {
//WhatsApp is not installed or is not available
}

jobima
- 5,790
- 1
- 20
- 18
0
in iOS 9 : you need to Set key in info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fb-messenger-api</string>
<string>twitter</string>
<string>whatsapp</string>
<string>wechat</string>
<string>line</string>
<string>instagram</string>
<string>kakaotalk</string>
<string>mqq</string>
<string>vk</string>
<string>comgooglemaps</string>
</array>
After set key, below code is working in iOS 9.
NSString * msg = @"mahesh";
NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}

Mahesh Cheliya
- 1,334
- 1
- 16
- 21
-2
No This is not legal. you cant use watsapp in your app.

Monish Bansal
- 509
- 3
- 15
-
but in that link of github is public api for php. – Renish Dadhaniya Mar 07 '13 at 08:12
-
No the API is not public, the code on Github is reversed engineered. thus legal in away that you are allowed to see how things work. But not legal to use in your app. – rckoenes Mar 07 '13 at 08:16
-
And apple will reject app for sure – Monish Bansal Mar 07 '13 at 09:14
-
You could please look into this link : http://www.whatsapp.com/faq/en/iphone/23559013 – Sunil Targe Nov 06 '13 at 09:33