ios - 快速打开特定号码的 Whatsapp

标签 ios whatsapp

我试图在 whatsapp 中打开一个特定的联系人聊天,但没有得到任何解决方案。请帮助我完全卡住了。我试过这个:

let whatsAppURL: NSURL = NSURL(string: "whatsapp://send?abid=\(primary)&;text=lOL;")!
        if UIApplication.sharedApplication().canOpenURL(whatsAppURL){
            UIApplication.sharedApplication().openURL(whatsAppURL)
        }

最佳答案

您可以向特定用户发送消息。

打开直接应用聊天 url

let urlWhats = "whatsapp://send?phone=+919789384445&abid=12354&text=Hello"
    if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
        if let whatsappURL = URL(string: urlString) {
            if UIApplication.shared.canOpenURL(whatsappURL!) {
                UIApplication.shared.openURL(whatsappURL!)
            } else {
                print("Install Whatsapp")
            }
        }
    }

Note:Country code (Ex:+91) is mandatory to open mobile number Chat

WebUrl 链接打开聊天

 let whatsappURL = URL(string: "https://api.whatsapp.com/send?phone=9512347895&text=Invitation")
    if UIApplication.shared.canOpenURL(whatsappURL) {
        UIApplication.shared.open(whatsappURL, options: [:], completionHandler: nil)
    }

检查下面的链接,

https://www.whatsapp.com/faq/en/general/26000030

注意:在info.plist中添加url scheme

<key>LSApplicationQueriesSchemes</key>
 <array>
    <string>whatsapp</string>
 </array>

关于ios - 快速打开特定号码的 Whatsapp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40535309/

相关文章:

ios - 如何在 iOS 运行时自定义子类实现?

ios - SVProgressHUD - 快速显示/隐藏控件会导致它在下次调用 showWithStatus 时不出现

ios - 在 iOS 9.1 中,从前景和背景中的 Assets 图像接收到的数据大小不同?

ios - Mapkit - 存在多边形时无法渲染过度缩放的自定义图 block

java - 以编程方式发送 Whatsapp 消息到特定号码

java - 将可绘制图像正确共享到其他应用程序(如果没有 FileProvider,将 PNG 共享到 Whatsapp 会失败)

ios - Powershell New-SelfSignedCertificate CA 不适用于 iOS 14.2

android - 使用 android.content.Intent.ACTION_SENDTO 启动 whatsapp

iphone - WhatsApp - 从 iOS 共享图像

html - 为 WhatsApp 链接共享提供图像