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?
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];
}
Yes you can through :
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>
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
}
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];
}
No This is not legal. you cant use watsapp in your app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.