gpt4 book ai didi

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

转载 作者:技术小花猫 更新时间:2023-10-29 10:28:46 26 4
gpt4 key购买 nike

我试图在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com