admin管理员组

文章数量:1022944

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=""></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>

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./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>
Share Improve this question edited Apr 13, 2020 at 6:26 Bill asked Apr 13, 2020 at 6:21 BillBill 5,15018 gold badges93 silver badges153 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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

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

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=""></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>

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./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>
Share Improve this question edited Apr 13, 2020 at 6:26 Bill asked Apr 13, 2020 at 6:21 BillBill 5,15018 gold badges93 silver badges153 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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

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

本文标签: javascriptWhat does suppressedbyuser mean when using Google One TapStack Overflow