Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sms for ios #203

Merged
merged 1 commit into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Notifications X X X X
Text to speech X X X X X
Email (open mail client) X X X X X
Vibrator X X
Sms (send messages) X
Sms (send messages) X X
Compass X X
Unique ID X X X X X
Gyroscope X X
Expand Down
48 changes: 48 additions & 0 deletions plyer/platforms/ios/sms.py
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()