-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
''' | ||
IOS Sms | ||
---------- | ||
''' | ||
|
||
try: | ||
from urllib.parse import quote | ||
except ImportError: | ||
from urllib import quote | ||
|
||
from plyer.facades import Sms | ||
from pyobjus import autoclass, objc_str | ||
from pyobjus.dylib_manager import load_framework | ||
|
||
NSURL = autoclass('NSURL') | ||
NSString = autoclass('NSString') | ||
UIApplication = autoclass('UIApplication') | ||
load_framework('/System/Library/Frameworks/MessageUI.framework') | ||
|
||
|
||
class IOSSms(Sms): | ||
|
||
def _send(self, **kwargs): | ||
''' | ||
This method provides sending messages to recipients. | ||
Expects 2 parameters in kwargs: | ||
- recipient: String type | ||
- message: String type | ||
Opens a mesage interface with recipient and message information. | ||
''' | ||
recipient = kwargs.get('recipient') | ||
message = kwargs.get('message') | ||
url = "sms:" | ||
if recipient: | ||
# Apple has not supported multiple recipients yet. | ||
url += str(recipient) | ||
if message: | ||
# Apple has to supported it yet. | ||
pass | ||
|
||
nsurl = NSURL.alloc().initWithString_(objc_str(url)) | ||
UIApplication.sharedApplication().openURL_(nsurl) | ||
|
||
|
||
def instance(): | ||
return IOSSms() |