我正在使用此代码:
Code
消息错误到控制台:
…Failed for URL: “whatsapp://send?text=Check” – error: “This app is
not allowed to query for scheme whatsapp”
谢谢
解决方法 你应该试试这个:注意:您必须在设备中安装whatsapp app.
斯威夫特3
var documentInteractionController: UIdocumentInteractionController = UIdocumentInteractionController()@IBAction func whatsappShareText(_ sender: AnyObject){ let originalString = "First Whatsapp Share" let escapedString = originalString.addingPercentEnCoding(withAllowedCharacters:CharacterSet.urlqueryAllowed) let url = URL(string: "whatsapp://send?text=\(escapedString!)") if UIApplication.shared.canopenURL(url! as URL) { UIApplication.shared.open(url! as URL,options: [:],completionHandler: nil) }}@IBAction func whatsappSharelink(_ sender: AnyObject){ let originalString = "https://www.Google.co.in" let escapedString = originalString.addingPercentEnCoding(withAllowedCharacters:CharacterSet.urlqueryAllowed) let url = URL(string: "whatsapp://send?text=\(escapedString!)") if UIApplication.shared.canopenURL(url! as URL) { UIApplication.shared.open(url! as URL,completionHandler: nil) }}
在您的应用“info.pList”中添加此代码
<key>LSApplicationQuerIEsSchemes</key><array> <string>whatsapp</string></array>总结
以上是内存溢出为你收集整理的swift3 – 如何在Swift 3中发送消息并链接到WhatsApp?全部内容,希望文章能够帮你解决swift3 – 如何在Swift 3中发送消息并链接到WhatsApp?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)