|
@@ -701,12 +701,23 @@ public class APIS: NSObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static func sendWhatsapp(message: String) {
|
|
|
- var urlString = message
|
|
|
- var urlStringEncoded = urlString.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
|
|
|
- var url = NSURL(string: "whatsapp://send?text=\(urlStringEncoded!)")
|
|
|
- if UIApplication.shared.canOpenURL(url! as URL) {
|
|
|
- UIApplication.shared.open(url! as URL, options: [:]) { (success) in
|
|
|
+ public static func sendSMS(phoneNumber: String, message: String = ""){
|
|
|
+ let formattedNumber = phoneNumber.replacingOccurrences(of: "-", with: "")
|
|
|
+ let urlStringEncoded = message.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
|
|
|
+ let paramMessage = message.isEmpty ? "" : "&body=\(urlStringEncoded!)"
|
|
|
+ let url = URL(string: "sms:\(formattedNumber)\(paramMessage)")
|
|
|
+ if UIApplication.shared.canOpenURL(url!) {
|
|
|
+ UIApplication.shared.open(url!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static func sendWhatsapp(phoneNumber: String, message: String = "") {
|
|
|
+ let formattedNumber = phoneNumber.replacingOccurrences(of: "+", with: "").replacingOccurrences(of: "-", with: "")
|
|
|
+ let urlStringEncoded = message.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed)
|
|
|
+ let paramMessage = message.isEmpty ? "" : "?text=\(urlStringEncoded!)"
|
|
|
+ let url = URL(string: "https://wa.me/\(formattedNumber)\(paramMessage)")
|
|
|
+ if UIApplication.shared.canOpenURL(url!) {
|
|
|
+ UIApplication.shared.open(url!, options: [:]) { (success) in
|
|
|
if success {
|
|
|
//print("WhatsApp accessed successfully")
|
|
|
} else {
|