使用 Google 一键时,`suppressed_by_user` 是什么意思?
What does `suppressed_by_user` mean when using Google One Tap?
我试图在用户登录时显示一次点击,下面的代码在页面加载 运行s 时工作正常,但如果我尝试获取它 运行 单击然后我收到错误 suppressed_by_user
错误我没有广告拦截插件 运行ning 我不知道 suppressed_by_user
是什么意思?
docs here 详细说明错误,但不解释错误原因或解决方法。
<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>
这意味着用户之前手动关闭了 One Tap 提示,这触发了冷却功能(记录在:https://developers.google.com/identity/one-tap/web/guides/features#exponential_cooldown)。
在冷却期间,一键提示被抑制。
我试图在用户登录时显示一次点击,下面的代码在页面加载 运行s 时工作正常,但如果我尝试获取它 运行 单击然后我收到错误 suppressed_by_user
错误我没有广告拦截插件 运行ning 我不知道 suppressed_by_user
是什么意思?
docs here 详细说明错误,但不解释错误原因或解决方法。
<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>
这意味着用户之前手动关闭了 One Tap 提示,这触发了冷却功能(记录在:https://developers.google.com/identity/one-tap/web/guides/features#exponential_cooldown)。
在冷却期间,一键提示被抑制。