在Android中实施自动短信验证的简单方法

There are many ways to do the verification process in an Android application. One of the best way is using SMS verification. Since we all know most mobile phone users have a phone number for their phone.

有许多方法可以在Android应用程序中执行验证过程。 最好的方法之一是使用SMS验证。 众所周知,大多数手机用户都有其手机的电话号码。

But, input the code that we received from SMS isn’t user friendly. You have to view all the messages in your phone and see the code on it, then back again to the app to input the code. We need “something” that can read those messages and get the code then fill in the field automatically.

但是,输入我们从SMS收到的代码不是用户友好的。 您必须查看手机中的所有消息并查看其中的代码,然后再次返回到应用程序以输入代码。 我们需要可以读取这些消息并获取代码的“东西”,然后自动填写该字段。

Actually, there are many ways to automatically fill the OTP field by reading the message in our phone using READ_SMS permission. But, Google has strictly prohibited the usage of that permission for security purposes. You can read the full explanation here.

实际上,有很多方法可以通过使用READ_SMS权限在手机中读取消息来自动填写OTP字段。 但是,Google出于安全目的严格禁止使用该权限。 您可以在此处阅读完整的说明

Since we can’t use the READ_SMS permission anymore, Google has given some other choices to implement automatic SMS verification using SMS Verification API which includes the automatic and one-tap SMS verification. Let’s find out how they work!

由于我们无法再使用READ_SMS权限,因此Google提供了其他一些选择,以使用SMS验证API实现自动SMS验证,该API包括自动和一键式SMS验证。 让我们找出它们是如何工作的!

自动短信验证 (Automatic SMS Verification)

Image for post
Automatic SMS Verification Flow
自动短信验证流程

The automatic SMS verification is the best way to do the SMS verification. Because, users don’t have to do any action and just wait until the verification process is complete. Also, it doesn’t require any permission, but you have to make sure that you follow these criterias:

自动SMS验证是进行SMS验证的最佳方法。 因为,用户无需执行任何操作,只需等待验证过程完成即可。 另外,它不需要任何许可,但是您必须确保遵循以下条件:

  1. Messages that are sent to the user’s device must be no longer than 140 bytes.

    发送到用户设备的消息不得超过140个字节。
  2. Message must contains a one-time code that user’s will send back to the server.

    消息必须包含一个一次性代码,用户的一次性代码将发送回服务器。
  3. Message must contain an 11-character hash string.

    邮件必须包含11个字符的哈希字符串

Now, let’s impleme

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值