react on incoming sms on an iPhone
Asked Answered
W

4

3

After researching the possibility to read incoming sms programmatically i realize that it is not possible on a standard iPhone.

I am researching an application which should have the following sequence for action:

  1. User#1 send an sms to User#2 with a specific keyword, maybe &&XX&&
  2. User#2 receives the sms and based on the keyword something should be triggered

Given that it is not possible to get the phone to act on the sms-based keywork automatically it may be possible to trigger something manually when the sms is received and us the sms as input.

My question is if someone have any ideas what is possible or/and what the best method would be to use the sms as input in the simplest possible way.

Windward answered 14/8, 2011 at 16:11 Comment(0)
C
4

No, on a non-jailbroken phone, you cannot get any data on SMS messages or phone calls. They are entirely walled off from your application.

Chiba answered 14/8, 2011 at 16:28 Comment(0)
V
4

I'm pretty sure that it can only be done on jailbroken phones.

Put this launchd plist in /System/Library/LaunchDaemons. It will trigger the script whenever the sms database changes.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>com.billybob.SMSremote</string>
 <key>ProgramArguments</key>
 <array>
 <string>/usr/sbin/script</string>
 </array>
 <key>Nice</key>
 <integer>20</integer>
 <key>WatchPaths</key>
 <array>
 <string>/private/var/mobile/Library/SMS/sms.db</string>
 </array>
</dict>
</plist>

For the script I'd use something like the following to determine if there is a message containing the string:

sqlite3 /var/mobile/Library/SMS/sms.db "select 'String Found' from message where text like '&&XX&&' order by date desc limit 1"

for the whole script maybe

case $( sqlite3 /var/mobile/Library/SMS/sms.db "select 'String Found' from message where text like '&&XX&&' order by date desc limit 1" ) in 'String Found') sqlite3 /var/mobile/Library/SMS/sms.db "delete * from message where text like '&&XX&&'" ; commandscript;;esac

In order words when the string is found, delete all messages containing the string and execute the commandscript.

Of course you need a jailbroken phone and sqlite from cydia. The same process could be done on the other databases as well. I'm not sure how you would go about doing this without a shell script but I'm sure it's possible. I haven't tested the script yet so you might want to make a copy of your sms.db before trying.

Vilify answered 14/11, 2011 at 10:59 Comment(1)
Welcome on SO, this is a very good post. :) I suggest that you have a look to the FAQ : stackoverflow.com/faq to learn more about this awesome community!Cretinism
R
3

Yes, but manually via user interaction, not automatically. Have your app register a URL handler. Then if the user taps on a URL of that form inside an SMS message, your app will be triggered.

Rodent answered 14/8, 2011 at 18:37 Comment(0)
E
0

If there is no api to read incoming sms in iphone, then how is whatsapp activation code works while installation. FYI, While installing whatsapp in iphone, An activation code is sent to your entered mobile number which then automatically used by whatsapp for registration. So somehow they read the incoming sms and use it for registration. If it is the case, how is it done? Thank you.

Escurial answered 20/8, 2015 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.