【发布时间】:2016-09-25 12:48:39
【问题描述】:
我正在尝试向存储在全局变量中的收件人号码发送 whatsapp 消息!
通过使用这个简单的代码:
let whatsAppUrl = NSURL(string: "whatsapp:\(globalPhone)")
if UIApplication.shared.canOpenURL(whatsAppUrl as! URL) {
UIApplication.shared.openURL(whatsAppUrl as! URL)
}
else {
let errorAlert = UIAlertView(title: "Sorry", message: "You can't send a message to this number", delegate: self, cancelButtonTitle:"Ok")
errorAlert.show()
}
我总是收到警报消息,否则就是这样! 虽然这个数字总是真实的! 可能是url语法错误?
在控制台中:
canOpenURL: failed for URL: "whatsapp:0534260282" -
"This app is not allowed to query for scheme whatsapp"
这是正确的方法吗? 或者这种方式只是为了分享,通过Whatsapp发短信?
【问题讨论】:
标签: swift url social-networking whatsapp