18

I want to implement an iOS application which will use the SMS text as raw information. I think Apple does not allow this. Could an iOS application read/access SMS text? or do we have any other approach to do the same?

Modification: Can we read service messages which are not saved in the SMS box like balance message?

Saurabh Shukla
  • 1,368
  • 3
  • 14
  • 26

2 Answers2

17

Correct, you cannot access these on a standard, non-jailbroken iPhone. You should file a bug with Apple, perhaps they'll improve SMS access in the future.

  1. Not possible
  2. Check this

  3. For SMS sending through application allowed but for accessing inbox for sms/email not allowed.

It is only possible when the phone is Jailbreaked. There are many tools to jailbreak your phone.

Once Jailbreaked, an application cal open the SQLite database at

/var/mobile/Library/SMS/sms.db and read the message table.

It contains, the date/time at which the message was received, the sender/recipient phone number and even the clear text of the message.

Pradhyuman sinh
  • 3,936
  • 1
  • 23
  • 38
  • 4
    With some of the un-sandboxing of iOS 8.0, is this still the case? – Randyaa Dec 03 '14 at 23:32
  • I've seen some apps that intercept text messages (in a read only manner) as part of their reg flow. But haven't found anything on how to do this. – Andre Jun 05 '15 at 14:48
  • 4
    Hi Andre, which are those apps you are referring to? – Sid Sep 28 '15 at 07:27
  • On iOS 12 there is such option, see here: https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view – zvi Feb 17 '19 at 15:50
2

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. https://stackoverflow.com/a/8120599/4731224

Community
  • 1
  • 1
J.Arji
  • 631
  • 6
  • 18