Whatsapp URL架构将消息发送到电话号码

Fel*_*lix 1 html url whatsapp

是否可以将whatsapp消息发送到未存储在通讯录中的特定whatsapp帐户(电话号码)?

想在我的网站上设置whatsapp网址方案,以通过whatsapp提供直接联系。

小智 5

有可能!尝试使用swift 3和xcode 8.3.2。

    let date = Date()
    let msg = "Hi my dear friends\(date)"
    let urlWhats = "whatsapp://send?phone=phoneNumber&abid=phoneNumber&text=hi"
    if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
        if let whatsappURL = NSURL(string: urlString) {
            if UIApplication.shared.canOpenURL(whatsappURL as URL) {
                UIApplication.shared.openURL(whatsappURL as URL)
            } else {
                print("please install watsapp")
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)