在iOS 14.2上,window.gapi.auth2.getAuthInstance()为空

2022-07-13 00:00:00 javascript google-signin

安装登录页面

this.auth2 = window.gapi.auth2
.init({
client_id: process.env.GOOGLE_ID,
ux_mode: 'redirect',
redirect_uri: process.env.GOOGLE_LOGIN_REDIRECT, // https://domain/callback
scope: 'profile email',
prompt: 'select_account',
})
.then(() => {
let googleAuth = window.gapi.auth2.getAuthInstance();
googleAuth.signIn()
});
在回调页面中 window.gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse()仅在iOS 14.2中为空,但另一个版本是Work,Android也是Work。


解决方案

当UX_MODE为‘REDIRECT’时,除非禁用ITP,否则它不会工作。 https://www.simoahava.com/privacy/intelligent-tracking-prevention-ios-14-ipados-14-safari-14/

相关文章