【问题标题】:Can I use whatsapp in my app for sending message我可以在我的应用程序中使用 whatsapp 发送消息吗
【发布时间】:2013-02-22 08:22:09
【问题描述】:

我想在我的应用程序中使用 whatsapp 向其他手机发送消息。我在 Github 上看到了这个用于 whatsapp 的公共 API,here。但我没有找到适用于 iOS 的 API。那么可以在iOS应用程序中使用whatsapp吗?那合法吗?我在哪里可以找到适用于 iOS 的 whatsapp 的公共 API?

【问题讨论】:

    标签: iphone ios whatsapp


    【解决方案1】:

    是的,您可以使用 whatsapp 通过您的 ios 应用程序发送文本/图像。 有两种方法可以做到这一点 1. URL方案

    NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
    if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
        [[UIApplication sharedApplication] openURL: whatsappURL];
    }
    
    1. UIDocument 交互 请参阅下面的链接 http://www.whatsapp.com/faq/en/iphone/23559013

    【讨论】:

      【解决方案2】:

      是的,你可以通过:

      1. 网址方案
      2. UIDocumentInteraction

      正如@NSAnant 提到的

      如果您正在编写混合应用程序(Cordova、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>
      

      【讨论】:

        【解决方案3】:

        就这么简单。希望它有所帮助;-)

        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
        }
        

        【讨论】:

          【解决方案4】:

          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];
          }
          

          【讨论】:

            【解决方案5】:

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

            【讨论】:

            • 但在 github 的那个链接中是 php 的公共 api。
            • 不,API 不公开,Github 上的代码是逆向工程的。因此,您可以查看事情的运作方式是合法的。但在您的应用中使用是不合法的。
            • 苹果肯定会拒绝应用
            • 你可以看看这个链接:whatsapp.com/faq/en/iphone/23559013
            猜你喜欢
            • 2015-04-30
            • 2015-09-23
            • 2017-04-08
            • 1970-01-01
            • 1970-01-01
            • 2014-09-07
            • 2020-06-25
            • 2019-08-03
            • 1970-01-01
            相关资源
            最近更新 更多