我已经检查了此问题上的其他几个问题,并为whatsapp安装了LSApplicationQueriesScheme
,但是仍然不允许我的应用程序与whatsapp共享。
这是我的Info.plist
文件的屏幕截图:
这是我分享的whatsapp代码。我希望获得一些帮助。我已经检查了其他Stack Overflow问题,但并没有帮助。
@IBAction func shareWhattsappButtonTapped(_ sender: UIButton) {
let shareMessage = "Hola! Estoy buscando a mi \(posts!.petType) que es de raza \(posts!.breed). La ultima vez que lo vimos fue en \(posts?.address). Ayudenme a encontrarlo porfavor! Subi la foto con toda la información a Gastet. Pueden verlo aquí: https://itunes.apple.com/mx/app/gastet/id1407059324?l=en&mt=8"
shareWhatssapp(message: shareMessage)
}
func shareWhatssapp(message: String) {
let msg = message
let urlWhats = "whatsapp://send?text=\(msg)"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
if let whatsappURL = NSURL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL as URL ) {
UIApplication.shared.open(whatsappURL as URL)
}
}
}
}
答案 0 :(得分:1)
这是我设法解决whatssapp问题的方法:
func shareWhatssapp(message: String) {
let msg = message
let urlWhats = "whatsapp://send?text=\(msg)"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) {
if let whatsappURL = NSURL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL as URL ) {
UIApplication.shared.open(whatsappURL as URL)
}
}
}
}
答案 1 :(得分:0)
在您的 Info.plist 中,您忘记了“LSApplicationQueriesSchemes”末尾的“s”
LSApplicationQueriesScheme
LSApplicationQueriesSchemes