|
@@ -683,6 +683,21 @@ public class APIS: NSObject {
|
|
|
UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: nil)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ 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
|
|
|
+ if success {
|
|
|
+ print("WhatsApp accessed successfully")
|
|
|
+ } else {
|
|
|
+ print("Error accessing WhatsApp")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
extension UINavigationController {
|