使用Google One Tap时,"suppressed_by_user"是什么意思? [英] What does `suppressed_by_user` mean when using Google One Tap?

查看:150
本文介绍了使用Google One Tap时,"suppressed_by_user"是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让用户点击登录时出现一次点击,下面的代码在页面加载后立即运行时效果很好,但是如果我尝试使其在单击时运行,则会出现错误suppressed_by_user错误我没有正在运行的广告阻止插件,我也不知道suppressed_by_user意味着什么?

I am trying to get the one tap to appear when the user clocks sign in, The below code works just fine when It runs as soon as the page loads but if I try to get it run on click then I get the error suppressed_by_user error I don't have an advert blocking plugin running and I don't know what suppressed_by_user could mean?

此处的文档详细说明了错误但是请不要解释造成它的原因或解决方法.

docs here detail the error but don't explain what caused it or how to fix it.

<script src="https://accounts.google.com/gsi/client"></script>
... 
  const signin = () => {
    const handleCredentialResponse = (response: any) => {
      const credential = response.credential;
      const getDetails = async () => {
        const params = new window.URLSearchParams({ credential });
        const url = `${process.env.REACT_APP_API_BASE_URL}/google?${params}`;
        const response = await fetch(url, { method: "GET" });
        const data = await response.json();
        setLoggedIn(true);
        setState({ ...state, participant: data.participant });
      };
      getDetails();
    };
    if (state && state.participant && state.participant.id) {
      setLoggedIn(true);
    } else {
      const client_id = process.env.REACT_APP_GOOGLE_CLIENT_ID;
      const callback = handleCredentialResponse;
      const auto_select = false;
      const cancel_on_tap_outside = false;
      google.accounts.id.initialize({ client_id, callback, auto_select, cancel_on_tap_outside });
      google.accounts.id.prompt((notification: any) => {
        console.log(notification); // rl {g: "display", h: false, j: "suppressed_by_user"}
        console.log(notification.getNotDisplayedReason()); // suppressed_by_user
      });
    }
  };
...
<div className="center--main-join" onClick={signin}>Sign in or Join</div>

推荐答案

这意味着用户之前已经手动关闭了一键式"提示,从而触发了冷静"功能(如记录在:

It means user has mannually closed the One Tap prompt before, which triggered the Cool Down feature (as documentated at: https://developers.google.com/identity/one-tap/web/guides/features#exponential_cool_down).

在冷却期间,一键式提示被抑制.

During the cool down period, One Tap prompt is suppressed.

这篇关于使用Google One Tap时,"suppressed_by_user"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆