소스 검색

add API Whatsapp

alqindiirsyam 2 년 전
부모
커밋
7c1874bf55

+ 4 - 0
appbuilder-ios/AppBuilder/AppBuilder/Info.plist

@@ -46,6 +46,10 @@
 	<array>
 		<string>INSendMessageIntent</string>
 	</array>
+    <key>LSApplicationQueriesSchemes</key>
+    <array>
+         <string>whatsapp</string>
+    </array>
 	<key>UIAppFonts</key>
 	<array>
 		<string>Poppins-Light.ttf</string>

+ 4 - 0
appbuilder-ios/DigiXLite/DigiXLite/Info.plist

@@ -34,6 +34,10 @@
 	<string>Get File Photos from Local Dictionary for Send Message and Content Creation.</string>
 	<key>NSSpeechRecognitionUsageDescription</key>
 	<string>Service nuSDK.</string>
+    <key>LSApplicationQueriesSchemes</key>
+    <array>
+         <string>whatsapp</string>
+    </array>
 	<key>UIAppFonts</key>
 	<array>
 		<string>fonts/Poppins-Light.ttf</string>

+ 15 - 0
appbuilder-ios/DigiXLite/DigiXLite/Source/APIS.swift

@@ -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 {

+ 4 - 0
appbuilder-ios/NexilisLite/NexilisLite/Info.plist

@@ -34,6 +34,10 @@
 	<string>Get File Photos from Local Dictionary for Send Message and Content Creation.</string>
 	<key>NSSpeechRecognitionUsageDescription</key>
 	<string>Service nuSDK.</string>
+    <key>LSApplicationQueriesSchemes</key>
+    <array>
+         <string>whatsapp</string>
+    </array>
 	<key>UIAppFonts</key>
 	<array>
 		<string>fonts/Poppins-Light.ttf</string>

+ 15 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/APIS.swift

@@ -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 {