iOS 应用程序可以读取/访问 SMS 文本吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19603832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could an iOS application read/access SMS text?
提问by Saurabh Shukla
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?
我想实现一个 iOS 应用程序,它将使用 SMS 文本作为原始信息。我认为苹果不允许这样做。iOS 应用程序可以读取/访问 SMS 文本吗?或者我们有其他方法来做同样的事情吗?
Modification: Can we read service messages which are not saved in the SMS box like balance message?
修改:我们可以像余额消息一样读取没有保存在短信箱中的服务消息吗?
采纳答案by Pradhyuman sinh
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.
正确,您无法在标准的、未越狱的 iPhone 上访问这些。您应该向 Apple 提交错误,也许他们将来会改进 SMS 访问。
- Not possible
Check this
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
越狱后,应用程序会在以下位置打开 SQLite 数据库
/var/mobile/Library/SMS/sms.db and read the message table.
/var/mobile/Library/SMS/sms.db 并阅读消息表。
It contains, the date/time at which the message was received, the sender/recipient phone number and even the clear text of the message.
它包含收到消息的日期/时间、发件人/收件人的电话号码,甚至是消息的明文。
回答by J.Arji
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.
将这个launchd plist 放入/System/Library/LaunchDaemons.
它会在sms 数据库发生变化时触发脚本。
<?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
当然,你需要一个越狱的手机和来自 cydia 的 sqlite。同样的过程也可以在其他数据库上完成。我不确定如果没有 shell 脚本你会怎么做,但我确定这是可能的。我还没有测试过这个脚本,所以你可能想在尝试之前制作一份你的 sms.db 的副本。 https://stackoverflow.com/a/8120599/4731224