2013-03-07 105 views

回答

9

是的,你可以使用whatsapp通过你的iOS发送文本/图像的应用程序。 有做两种方式这样 1. URL方案

NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"]; 
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { 
    [[UIApplication sharedApplication] openURL: whatsappURL]; 
} 
  • UIDocumentInteraction 见下文 http://www.whatsapp.com/faq/en/iphone/23559013
  • -1

    否这是不合法的。你不能在你的应用程序中使用watsapp。

    +0

    但在该github的链接是PHP的公共API。 – 2013-03-07 08:12:28

    +0

    没有API不公开,Github上的代码被逆向设计。因此在法律允许你看到事情是如何工作的。但在您的应用中使用不合法。 – rckoenes 2013-03-07 08:16:19

    +0

    和苹果肯定会拒绝应用程序 – 2013-03-07 09:14:09

    0

    的链路是如此简单。希望它可以帮助;-)

    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 
    } 
    
    2

    是的,你可以通过:

    1. URL方案
    2. UIDocumentInteraction

    由于@NSAnant万一你被编码提到

    一个混合应用程序(科尔多瓦,phonegap等)一个简单的锚点与来自WhatsApp常见问题解答的URL方案会解决这个问题(integrate WhatsApp into my app)

    <a href="whatsapp://send?text=666isthenumberofthebeast" id="my_button" class="button_default button_color">Send Whatsapp Friendly Message</a> 
    
    0

    的iOS 9:你需要的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> 
    

    设置密钥组密钥之后,下面的代码中的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]; 
    } 
    
    相关问题