Android Jetpack Compose 中的 Google One-Tap

huangapple go评论76阅读模式
英文:

Android Google One-Tap in Jetpack Compose

问题

我将"Exception: com.google.android.gms.common.api.ApiException: 16: The caller has been temporarily blocked due to too many canceled sign-in prompts."翻译成中文:

异常: com.google.android.gms.common.api.ApiException: 16: 由于取消的登录提示过多,呼叫者已被暂时阻止。

如何解决这个问题?
Android Google One-Tap 异常

英文:

I integrated one tap into my app and it was working fine. To do some experimenting, I was clicking the button and then canceling. Now when I click the button, nothing appears on the screen and I get an Exception.

> Exception: com.google.android.gms.common.api.ApiException: 16: The caller has been temporarily blocked due to too many canceled sign-in prompts.

How can I solve this problem?

Android Google One-Tap Exception

答案1

得分: 0

> 我一直在点击按钮然后取消。

是的,你做了太多次了。这确实是你收到错误的原因。在官方文档和这篇文章中都提到了反复执行此类操作会引发异常:

> 如果用户拒绝登录,调用 getSignInCredentialFromIntent() 将抛出一个带有 CommonStatusCodes.CANCELED 状态代码的 ApiException

文档中还提到:

> 当发生这种情况时,你应该暂时禁用一键登录界面,以免多次提示用户。

因为我知道你遵循了这个资源,并且你正在Android中实施这个功能,解决这个问题的关键也在文档中:

> 以下示例通过在Activity上设置一个属性来实现此目的,该属性用于确定是否为用户提供一键登录选项;但是,你也可以将一个值保存到SharedPreferences或使用其他方法。

> 重要的是要实施自己的一键登录提示速率限制。如果不这样做,如果用户连续取消了多个提示,那么一键登录客户端将在接下来的24小时内不再提示用户。

因此,你必须等待24小时,直到你再次被允许使用此功能。

但是,如果你不想等待24小时,请查看文档中的注释:

> 如果在开发过程中遇到这个24小时的冷却期,你可以通过清除Google Play服务的应用存储来重置冷却。另外,在测试设备和/或模拟器上切换此冷却开关,只需打开拨号应用并输入以下代码:##66382723##。提交后,不会有任何反馈,但你的拨号应用将清除所有输入并可能关闭。此后,冷却应该已经关闭。要重新打开它,请再次输入相同的代码。

英文:

> I was clicking the button and then canceling.

Yes, you did that too many times. That's indeed the reason why you got that error. In the official documentation and this article, is mentioned that such practices that are performed repeatedly will throw an exception:

> If the user declined to sign in, the call to getSignInCredentialFromIntent() will throw an ApiException with a CommonStatusCodes.CANCELED status code.

Also in the docs is mentioned that:

> When this happens, you should temporarily disable the One Tap sign-in UI so you don't annoy your users with repeated prompts.

Since I know that you followed this resource, and you're implementing this in Android, the key to solving this problem lies in the documentation too:

> The following example accomplishes this by setting a property on the Activity, which it uses to determine whether to offer the user One Tap sign-in; however, you could also save a value to SharedPreferences or use some other method.

> It's important to implement your own rate limiting of One Tap sign-in prompts. If you don't, and a user cancels several prompts in a row, the One Tap client will not prompt the user for the next 24 hours.

So you have to wait 24 hours until this you're whitelisted again.

However, if you don't want to wait 24 hours, check the note in the docs that says:

> If you encounter this 24-hour cooldown period during development, you can reset the cooldown by clearing Google Play services' app storage. Alternatively, to toggle on/off this cooldown on a test device and/or emulator alike, simply go to the Dialer app and input the following code: ##66382723##. Upon submission, there will be no feedback, but your dialer will clear all input and may close. The cooldown should be toggled off after this. To toggle it back on, input the same code again.

huangapple
  • 本文由 发表于 2023年7月12日 22:31:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76671700.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定