'suppressed_by_user'是什么意思,使用Google One Tap吗?

问题描述 投票:0回答:1

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

[suppressed_by_user详细说明了错误,但不解释导致错误的原因或解决方法。

docs here
javascript reactjs google-authentication
1个回答
1
投票

这表示用户之前已经手动关闭了“一键式”提示,这触发了“冷却”功能(如<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> 所示)。

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

© www.soinside.com 2019 - 2024. All rights reserved.