Skip to content

Commit

Permalink
Merge pull request #203 from kiok46/sms_for_ios
Browse files Browse the repository at this point in the history
add sms for ios
  • Loading branch information
akshayaurora authored Aug 15, 2016
2 parents a648fe3 + acf97f6 commit a8cbfe8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
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()

0 comments on commit a8cbfe8

Please sign in to comment.