Firebase Google Connexion on iOS
Introduction
Section titled “Introduction”This Guide will Aide you integrate Google Sign-In with Firebase Authentication on iOS. I assume you have already completed the general Firebase Google Configuration.
I will assume that you have not yet created your iOS Application in the Firebase Console. If you have, your steps will be slightly different.
Configuration Steps
Section titled “Configuration Steps”-
Go to your project Aperçu over at console.cloud.google.com

-
Click on the
Add appbutton
It is possible that you will have to look here for this button. This applies only if you have already created a different Application in the Firebase Console.

-
Select
iOS
-
Fill the first part of the form
- Fill the
Apple bundle ID- Open Xcode at your app using
npx cap open ios - Double click on
App
- Ensure that you are on
Targets -> App
- Find your
Bundle Identifier
The ID shown here will differ from the one I will use for the rest of the guide. I will use
app.capgo.plugin.SocialLoginfor the rest of the guide. - Copy the
Bundle Identifierand paste it in the Firebase console
- Open Xcode at your app using
- Click on the
Register appbutton
- Fill the
-
Skip the
Download config filestep
-
Skip the
Add firebase SDKstep
-
Skip the
Add initialization codestep
-
Click on the
Continue to consolebutton
-
Get your iOS client ID and your
YOUR_DOT_REVERSED_IOS_CLIENT_ID-
Go to Google Cloud Console at console.cloud.google.com
-
Find your project
- Click on the project selector

- Search up your project by the exact name of your Firebase project and click on it. In my case, it is
sociallogin-tutorial-app.
- Click on the project selector
-
Open the search bar and open
credentials- Open the Recherche bar

- Search for
credentialsand click on theAPIs and Servicesone (number 2 on the screenshot)
- Open the Recherche bar
-
Click on the
iOS client for [YOUR_APP_ID] (auto created by Google Service)one. In my case, it issociallogin-tutorial-app.
-
Copy the
Client IDas well as theiOS URL scheme. This will be respectively youriOSClientIdandYOUR_DOT_REVERSED_IOS_CLIENT_ID.You will pass the
iOSClientIdin theinitializemethod of the plugin, while you will use theYOUR_DOT_REVERSED_IOS_CLIENT_IDin theInfo.plistfile of your app, as explained in the next part of this guide.
-
-
Get your web client ID
- Go back to the Firebase console and go to
Build->Authentication
- Click on the
Sign-in methodbutton
- Click on the
Googleprovider
- Click on the
Web SDK configurationbutton
- Copy the
Web client ID. This will be yourwebClientIdin theinitializemethod of the plugin.
- Go back to the Firebase console and go to
-
Modify your Application’s Info.plist
-
Open Xcode and find the
Info.plistfile
-
Right click this file and open it as source code

-
At the bottom of your
Plistfile, you will see a</dict>tag
-
Insert the following fragment just before the closing
</dict>tag
<key>CFBundleURLTypes</key><array><dict><key>CFBundleURLSchemes</key><array><string>YOUR_DOT_REVERSED_IOS_CLIENT_ID</string></array></dict></array><key>GIDClientID</key><string>YOUR_IOS_CLIENT_ID.apps.googleusercontent.com</string> -
Change the
YOUR_DOT_REVERSED_IOS_CLIENT_IDto the value copied in step 9 (the iOS URL scheme)
Ensure that this value STARTS with
com.googleusercontent.apps
-
-
Change the
YOUR_IOS_CLIENT_IDto the iOS Client ID you copied in step 9 -
Save the file with
Command + S -
Modify the
AppDelegate.swift-
Open the AppDelegate

-
Insert
import GoogleSignInat the top of the file
-
Find the
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:])function
-
Modify the function to look like this
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {// Called when the app was launched with a url. Feel free to add additional processing here,// but if you want the App API to support tracking app url opens, make sure to keep this callvar handled: Boolhandled = GIDSignIn.sharedInstance.handle(url)if handled {return true}return ApplicationDelegateProxy.shared.application(app, open: url, options: options)}
-
Save the file with
Command + S
-
-
Using the Google Connexion in your Application
At this step, you are ready to use the Google Connexion in your Application. Please use the authUtils.ts file of the Exemple Application to authenticate with Google.
The Utilisateur will be automatically created in Firebase Auth on first sign-in
Dépannage
Section titled “Dépannage”If authentication hangs or fails:
- Verify the
idTokenaudience matches your Firebase web client ID - Vérifier that Google Sign-In is enabled in Firebase Console
- Ensure Info.plist has the correct URL schemes and GIDClientID
- Verify
iOSServerClientIdmatches your web client ID - Review the Exemple Application code for Référence