我想制作一个与Whatsapp共享音频/照片的应用。我怎样才能实现这个功能。当我按下分享按钮时,音频/照片应该从远程服务器下载并需要与whatsapp联系人分享。
我在swift中做这个应用程序。
答案 0 :(得分:0)
点击此链接:https://faq.whatsapp.com/en/iphone/23559013
这将是Swift 3.0中的一个示例函数:
func sendWhatsApp() {
let date = Date()
let msg = "Hi my dear friends\(date)"
let urlWhats = "whatsapp://send?text=\(msg)"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
if let whatsappURL = URL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL) {
UIApplication.shared.open(whatsappURL, options: [:], completionHandler: nil)
} else {
print("please install watsapp")
}
}
}
}