简体   繁体   English

对 iPhone 上收到的短信做出反应

[英]react on incoming sms on an iPhone

After researching the possibility to read incoming sms programmatically i realize that it is not possible on a standard iPhone.在研究了以编程方式读取传入短信的可能性后,我意识到这在标准 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&&用户#1 使用特定关键字向用户#2 发送短信,可能是 &&XX&&
  2. User#2 receives the sms and based on the keyword something should be triggered用户#2 收到短信并根据关键字触发某些内容

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.我的问题是,如果有人知道什么是可能的或/以及以最简单的方式使用短信作为输入的最佳方法是什么。

No, on a non-jailbroken phone, you cannot get any data on SMS messages or phone calls.不,在未越狱的手机上,您无法获取任何有关 SMS 消息或电话的数据。 They are entirely walled off from your application.它们与您的应用程序完全隔离。

I'm pretty sure that it can only be done on jailbroken phones.我很确定它只能在越狱手机上完成。

Put this launchd plist in /System/Library/LaunchDaemons.将此已启动的 plist 放在 /System/Library/LaunchDaemons 中。 It will trigger the script whenever the sms database changes.每当 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.当然,你需要一部越狱手机和 cydia 的 sqlite。 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.我不确定在没有 shell 脚本的情况下你会如何 go 这样做,但我确信这是可能的。 I haven't tested the script yet so you might want to make a copy of your sms.db before trying.我还没有测试过这个脚本,所以你可能想在尝试之前复制你的 sms.db。

Yes, but manually via user interaction, not automatically.是的,但是通过用户交互手动进行,而不是自动进行。 Have your app register a URL handler.让您的应用注册一个 URL 处理程序。 Then if the user taps on a URL of that form inside an SMS message, your app will be triggered.然后,如果用户在 SMS 消息中点击该表单的 URL,您的应用程序将被触发。

If there is no api to read incoming sms in iphone, then how is whatsapp activation code works while installation.如果没有 api 来读取 iphone 中的传入短信,那么安装时 whatsapp 激活码是如何工作的。 FYI, While installing whatsapp in iphone, An activation code is sent to your entered mobile number which then automatically used by whatsapp for registration.仅供参考,在 iphone 中安装 whatsapp 时,激活码会发送到您输入的手机号码,然后 whatsapp 会自动使用该号码进行注册。 So somehow they read the incoming sms and use it for registration.所以他们以某种方式阅读传入的短信并将其用于注册。 If it is the case, how is it done?如果是这样,它是如何完成的? Thank you.谢谢你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM