Basic Google Sign-In for Websites code not working in Internet Explorer 11

后端 未结 4 1859
终归单人心
终归单人心 2020-12-05 05:36

I am attempting to use Google Sign-In for Websites (https://developers.google.com/identity/sign-in/web/) and noticed that my solution is not working in Internet Explorer 11.

4条回答
  •  隐瞒了意图╮
    2020-12-05 06:00

    I've had success doing the following: Loading the script to initiate the Google button rendering etc. from $document.ready. (i.e.Whatever you have in the apis.google.com/js/client:platform.js?onload= x )

    e.g.

    
    

    Move startApp() to here:

    $(document).ready(function () {
        startApp();
    

    Where startApp() looks something like this:

    function startApp() {
        gapi.load('auth2', function () {
            gapi.client.load('plus', 'v1').then(function () {
                gapi.signin2.render('signin-button', {
                    scope: 'https://www.googleapis.com/auth/plus.login',
                    fetch_basic_profile: false
                });
                gapi.auth2.init({
                    fetch_basic_profile: false,
                    scope: 'https://www.googleapis.com/auth/plus.login'
                }).then(
                    function () {
                        console.log('init');
                        auth2 = gapi.auth2.getAuthInstance();
                        auth2.isSignedIn.listen(updateSignIn);
                        auth2.then(updateSignIn());
                    });
            });
        });
    }
    

提交回复
热议问题