android - 如何使用 SMS Intent 关闭默认的短信应用程序以及如何获得发送成功消息的回调。(新政策更改备用)

标签 android authentication android-intent sms

根据新的 Google 权限限制 https://support.google.com/googleplay/android-developer/answer/9047303#alternatives,我正在使用 SMS Intent 发送短信以验证用户的电话号码.但问题是我无法关闭消息传递应用程序,也无法获得任何短信发送状态的回调。(即使从消息传递应用程序按回,也始终返回相同的结果代码)

我试过关闭应用程序,但它不起作用。

smsIntent.putExtra("exit_on_sent", true);

也跟着这个答案Sending SMS via an Intent and know if the SMS has been sent or not但同样需要 READ_SMS 权限。

对此没有合适的解决方案。

请建议我如何实现这个或任何其他替代解决方案。 我的应用程序需要发送短信来验证帐户。

最佳答案

自从 Google 关于发送和接收 SMS 的新政策以来,我的应用程序也遇到了类似的问题

不幸的是,许多 SMS 应用程序不支持 exit_on_sent。使用 startActivityForResult 打开短信默认应用程序不会返回不同的值,无论短信是否发送

最好的解决方案是在互联网上使用提供 API 来发送 SMS 的第三方服务(但它可能不是免费的)

我还尝试注册 SMS 内容观察器,如 Sending SMS via an Intent and know if the SMS has been sent or not 中所述 => 根据我的经验,即使未授予 READ_SMS 权限,也会引发 onChange 事件(除了崩溃的小米 ;-),但是发送的 SMS 的细节很少(你甚至不知道是否发送或接收短信)

然后对于自动读取短信,您可以有 2 个选项: - 使用 Google 的 SMS 检索器 API(参见 https://developers.google.com/identity/sms-retriever/) - 对于 API 26 及更高版本,使用 SmsManager.createAppSpecificSmsToken(参见 android sms verification without READ_SMS permission)

关于android - 如何使用 SMS Intent 关闭默认的短信应用程序以及如何获得发送成功消息的回调。(新政策更改备用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54456013/

相关文章:

java - 无法找到显式 Activity 类 {};你有没有在你的 AndroidManifest.xml 中声明这个 Activity

android - 为从 Play 商店安装的应用程序绘制覆盖权限

android - 图形断断续续

python-2.7 - Python Selenium 警报身份验证问题

authentication - 如何配置 Apache HttpClient 4.x 以使用特定的 Websphere SSL 别名?

java - 为什么 intent.resolveActivity(getPackageManager()) 会返回 null,即使有 Activity 来处理它?

android - 如何在eclipse中调试子项目中的Intent

android - 通过调用 startService 向服务发送消息

javascript - 在某些 REST API 上有选择地启用 HTTP 基本身份验证

android - 警报对话框 + Intent