My site is implementing Google Sign-In with the code below and it's working pretty well.
When I try to do it in the mobile version, it works, but I don't get the answer of sign in. I guess it's because mobile version doesn't show a popup but a new tab (Facebook has the same behavior as well...)
How should I proceed to get it to work in the mobile version too?
gapi.load('auth2', function() {});
$(function() {
$("#btn-google-login").on('click', function() {
var proccedLogin = function(resp) {
// my continue code...
}
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
client_id: $('meta[name="google-signin-client_id"]').attr('content'),
cookiepolicy: 'single_host_origin',
prompt: 'consent',
immediate: false
}, function() {});
auth2.signIn()
.then(proccedLogin)
.catch(function(error) {
alert(JSON.stringify(error, undefined, 2))
})
}) // btn google click
})
P.S. The error I get is 'popup_closed_by_user', but I didn't closed the tab by my own.
Edit
Now I'm getting 'popup_blocked_by_browser'. I followed some changes described in the link below but it just returns the same error...
detect error: "popup_blocked_by_browser" for google auth2 in javascript