summaryrefslogtreecommitdiff
path: root/external/plyer/platforms/ios/email.py
diff options
context:
space:
mode:
Diffstat (limited to 'external/plyer/platforms/ios/email.py')
-rw-r--r--external/plyer/platforms/ios/email.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/external/plyer/platforms/ios/email.py b/external/plyer/platforms/ios/email.py
new file mode 100644
index 0000000..7e55e4e
--- /dev/null
+++ b/external/plyer/platforms/ios/email.py
@@ -0,0 +1,41 @@
+try:
+ from urllib.parse import quote
+except ImportError:
+ from urllib import quote
+
+from plyer.facades import Email
+from pyobjus import autoclass, objc_str
+from pyobjus.dylib_manager import load_framework
+
+load_framework('/System/Library/Frameworks/UIKit.framework')
+
+NSURL = autoclass('NSURL')
+NSString = autoclass('NSString')
+UIApplication = autoclass('UIApplication')
+
+
+class iOSXEmail(Email):
+ def _send(self, **kwargs):
+ recipient = kwargs.get('recipient')
+ subject = kwargs.get('subject')
+ text = kwargs.get('text')
+
+ uri = "mailto:"
+ if recipient:
+ uri += str(recipient)
+ if subject:
+ uri += "?" if not "?" in uri else "&"
+ uri += "subject="
+ uri += quote(str(subject))
+ if text:
+ uri += "?" if not "?" in uri else "&"
+ uri += "body="
+ uri += quote(str(text))
+
+ nsurl = NSURL.alloc().initWithString_(objc_str(uri))
+
+ UIApplication.sharedApplication().openURL_(nsurl)
+
+
+def instance():
+ return iOSXEmail()