2013-03-07 67 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]; 
    } 
    
    相關問題