I am trying to implement Google OAuth in my iOS application. However, URLs like https://accounts.google.com/ServiceLogin?service=mail&passive=true&continue=https://mail.google.com/mail/?view&scc=1<mpl=ecobh&nui=5&btmpl=mobile&emr=1&osid=1#
result in "Safari can't open the page because the network connection was lost" when opened in the iOS simulator.
What should I do?
Note, this happens when I navigate to the URLs in the simulator's browser, so I don't think it's an issue with my code. But here's the code:
const hasPlayServices = await GoogleSignin.hasPlayServices({ showPlayServicesUpdateDialog: true });
console.log('hasPlayServices', hasPlayServices);
const signInResult = await GoogleSignin.signIn();
console.log('signInResult', signInResult);
const idToken = signInResult.data?.idToken;
if (!idToken) {
throw new Error('No ID token found');
}
// Create a Google credential with the token
const googleCredential = GoogleAuthProvider.credential(idToken);
// Sign-in the user with the credential
return signInWithCredential(getAuth(), googleCredential);
I fixed this by downgrading my iOS simulator from iOS 18 to iOS 16.
I found that after trying to visit a Google oAuth link generated through expo-auth-session, it would then block me from being able to visit google.com even through the Safari app in the Simulator!
Clearing Safari's cache would let me visit once in iOS 18 simulator before blocking it again. I found a similar note here: https://github.com/firebase/flutterfire/issues/13420