Pārlūkot izejas kodu

add open email app

alqindiirsyam 1 gadu atpakaļ
vecāks
revīzija
7101debaa8

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

@@ -49,6 +49,10 @@
     <key>LSApplicationQueriesSchemes</key>
     <array>
          <string>whatsapp</string>
+         <string>googlegmail</string>
+         <string>ms-outlook</string>
+         <string>readdle-spark</string>
+         <string>ymail</string>
     </array>
 	<key>UIAppFonts</key>
 	<array>

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

@@ -37,6 +37,10 @@
     <key>LSApplicationQueriesSchemes</key>
     <array>
          <string>whatsapp</string>
+         <string>googlegmail</string>
+         <string>ms-outlook</string>
+         <string>readdle-spark</string>
+         <string>ymail</string>
     </array>
 	<key>UIAppFonts</key>
 	<array>

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

@@ -698,6 +698,10 @@ public class APIS: NSObject {
             }
         }
     }
+    
+    public static func openMail() {
+        Nexilis.openmailAction()
+    }
 }
 
 extension UINavigationController {

+ 20 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -822,6 +822,26 @@ public class Nexilis: NSObject {
         }
     }
     
+    static func openmailAction() {
+        if let googleUrl = NSURL(string: "googlegmail://"), UIApplication.shared.canOpenURL(googleUrl as URL) {
+            openMail(googleUrl)
+        } else if let mailURL = NSURL(string: "message://"), UIApplication.shared.canOpenURL(mailURL as URL) {
+            openMail(mailURL)
+        } else if let outlookURL = NSURL(string: "ms-outlook://"), UIApplication.shared.canOpenURL(outlookURL as URL) {
+            openMail(outlookURL)
+        } else if let yahooURL = NSURL(string: "ymail://"), UIApplication.shared.canOpenURL(yahooURL as URL) {
+            openMail(yahooURL)
+        } else if let sparkUrl = NSURL(string: "readdle-spark://"), UIApplication.shared.canOpenURL(sparkUrl as URL) {
+            openMail(sparkUrl)
+        } else {
+            // showAlert
+        }
+    }
+    
+    private static func openMail(_ url: NSURL) {
+        UIApplication.shared.open(url as URL, options: [:], completionHandler: nil)
+    }
+    
     static var alertChangeProfile = LibAlertController()
     public static func checkIsChangePerson() -> Bool {
         let isChangeProfile = Utils.getSetProfile()