When I try to load google api client on apple devices, mobile or otherwise, it gives me an error and never calls the callback. However the problem does go away when an account is logged in. It appears on chrome simulating apple mobile devices, it appears on apple devices themselves, like iphone and macbook.
window._gapiOnLoad = function(){
alert("Never called on iphone");
}
var script = document.createElement('script');
script.onerror = function (e) {
alert("Also never called");
};
script.src = 'https://apis.google.com/js/client.js?onload=_gapiOnLoad';
document.body.appendChild(script);
Error:
Uncaught TypeError: t[u] is not a function
at Object.Oa.O.(anonymous function) [as loaded_0] (https://apis.google.com/js/client.js?onload=_gapiOnLoad:14:63)
at https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.54rvJIPTsq0.O/m=client/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AGLTcCPwWRWf9u-Qf5Xp2KlRIyI4hERCSA/cb=gapi.loaded_0:1:15
Related but not helpful and wrong: https://github.com/ionic-team/ionic/issues/10669
My webapp: https://brancher.io
Calling the script a second time seems to resolve the issue.
window._gapiOnLoad = function(){
alert("Is eventually called");
}
window.onerror = (e) => {
if (e == "Script error." && !gapi.client) {
loadScript();
}
}
loadScript()
function loadScript() {
var script = document.createElement('script');
script.src = 'https://apis.google.com/js/client.js?onload=_gapiOnLoad';
document.body.appendChild(script);
}