Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Google One Tap时,“被用户压制”是什么意思?_Javascript_Reactjs_Google Authentication - Fatal编程技术网

Javascript 使用Google One Tap时,“被用户压制”是什么意思?

Javascript 使用Google One Tap时,“被用户压制”是什么意思?,javascript,reactjs,google-authentication,Javascript,Reactjs,Google Authentication,我试图在用户登录时显示一次点击,下面的代码在页面加载后立即运行时效果很好,但如果我尝试在单击时运行它,则会出现错误supprested\u by_user错误我没有运行广告阻止插件,我不知道supprested\u by_user可能意味着什么 详细说明错误,但不要解释导致错误的原因或如何修复错误 <script src="https://accounts.google.com/gsi/client"></script> ... const signin = ()

我试图在用户登录时显示一次点击,下面的代码在页面加载后立即运行时效果很好,但如果我尝试在单击时运行它,则会出现错误
supprested\u by_user
错误我没有运行广告阻止插件,我不知道
supprested\u by_user
可能意味着什么

详细说明错误,但不要解释导致错误的原因或如何修复错误

<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>

... 
常量符号=()=>{
常量handleCredentialResponse=(响应:任意)=>{
const credential=response.credential;
const getDetails=async()=>{
const params=new window.URLSearchParams({credential});
constURL=`${process.env.REACT\u APP\u API\u BASE\u url}/google?${params}`;
const response=wait fetch(url,{method:“GET”});
const data=wait response.json();
setLoggedIn(真);
setState({…状态,参与者:data.participant});
};
getDetails();
};
if(state&&state.participant&&state.participant.id){
setLoggedIn(真);
}否则{
const client_id=process.env.REACT_APP_GOOGLE_client_id;
const callback=handleCredentialResponse;
const auto_select=false;
const cancel\u on\u tap\u outside=false;
初始化({client\u id,callback,auto\u select,cancel\u on\u tap\u outside});
google.accounts.id.prompt((通知:any)=>{
console.log(通知);//rl{g:“显示”,h:false,j:“被用户抑制”}
console.log(notification.getNotDisplayedReason());//被用户抑制
});
}
};
...
登录或加入

这意味着用户之前手动关闭了一次点击提示,触发了冷却功能(如所述:)

在冷却期间,一次轻触提示被抑制