Swift - 一次向多个联系人发送 WhatsApp 消息

时间:2021-01-17 16:30:35

标签: ios swift url contacts whatsapp

我想使用 Swift 一次向多个联系人(电话号码)发送 WhatsApp 消息。

我能够发送这样的自定义消息:

let alert = UIAlertController(title: nil, message: "Do you want to invite ... in WhatsApp?", preferredStyle: .alert)

let url = NSURL(string: "whatsapp://send?phone=123456789&text=Ich%20bin%20sehr%20an%20deinem%20Auto%20interessiert")

alert.addAction(UIAlertAction(title: "Sure!", style: .default) { action in
        if UIApplication.shared.canOpenURL(url! as URL) {
                    UIApplication.shared.open(url! as URL, options: [:]) { (success) in
                if !success {
                        let errorAlert = UIAlertController(title: "ERROR", message: "Can't open Whatsapp.", preferredStyle: .alert)
                        errorAlert.addAction(UIAlertAction(title: "Okay", style: .cancel))
                        self.present(errorAlert, animated: true)
                    }
                }
         }
})
alert.addAction(UIAlertAction(title: "No", style: .default) { action in
         self.dismiss(animated: true, completion: nil)
})
self.present(alert, animated: true)

但我想一次将消息发送给多个联系人(或电话号码)。这可能吗?

0 个答案:

没有答案