Google Connexion on iOS
Introduction
Section titled “Introduction”In this Guide, you will learn how to Configuration Google Connexion with Capgo Social Connexion for iOS. I assume that you have already read the general Configuration Guide.
Using Google Connexion on iOS
Section titled “Using Google Connexion on iOS”In this part, you will learn how to Configuration Google Connexion in iOS.
-
Créer an iOS client ID in the Google console
-
Click on the Recherche bar

-
Search for
credentialsand click on theAPIs and Servicesone (number 2 on the screenshot)
-
Click on the
create credentials
-
Select
OAuth client ID
-
Select the
Application typetoiOS
-
Find the Bundle ID
-
Open Xcode
-
Double click on
App
-
Ensure that you are on
Targets -> App
-
Find your
Bundle Identifier
-
Go back to the Google Console and paste your
Bundle IdentifierintoBundle ID
-
-
Optionally, add your
App Store IDorTeam IDinto the client ID if you have published your app to App Store -
After filling all the details, click
create
-
Click
OK
-
Open the newly created iOS client

-
Copy the following data

The
nr. 1in this image will later become theiOSClientIdin theinitializecall.The
nr. 2in this image will later becomeYOUR_DOT_REVERSED_IOS_CLIENT_ID
-
-
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> -
Change the
YOUR_DOT_REVERSED_IOS_CLIENT_IDto the value copied in the previous step
Ensure that this value STARTS with
com.googleusercontent.apps -
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
-
-
Configuration Google Connexion in your JavaScript/TypeScript code
-
Import
SocialLoginandCapacitorimport { SocialLogin } from '@capgo/capacitor-social-login';import { Capacitor } from '@capacitor/core'; -
Call the Initialiser method (this should be called only once)
Basic setup (online mode - recommended for most apps):
// onMounted is Vue specificonMounted(() => {SocialLogin.initialize({google: {iOSClientId: '673324426943-redacted.apps.googleusercontent.com',mode: 'online' // Default mode}})})Advanced setup with additional client IDs:
onMounted(() => {SocialLogin.initialize({google: {webClientId: 'YOUR_WEB_CLIENT_ID', // Optional: for web platform supportiOSClientId: 'YOUR_IOS_CLIENT_ID', // Required: from step 1iOSServerClientId: 'YOUR_WEB_CLIENT_ID', // Optional: same as webClientId, needed for some advanced featuresmode: 'online' // 'online' or 'offline'}})})Client ID Requirements:
iOSClientId: Required - Must end withgoogleusercontent.com(from step 1 above)webClientId: Optional - Only needed if you also support web platform or need advanced featuresiOSServerClientId: Optional - Should be the same value aswebClientIdwhen provided
For advanced setup with
webClientIdandiOSServerClientId, see the web setup guide for creating these credentials.About offline mode: When using
mode: 'offline', the login response will not contain user data directly. Instead, you’ll receive a server auth code that must be exchanged for user information via your backend server. See the general setup guide for implementation details. -
Implement the Connexion function. Créer a button and run the following code on click
For online mode:
const res = await SocialLogin.login({provider: 'google',options: {}})// handle the response - contains user dataconsole.log(JSON.stringify(res))For offline mode:
const res = await SocialLogin.login({provider: 'google',options: {forceRefreshToken: true // Recommended for offline mode}})// res contains serverAuthCode, not user data// Send serverAuthCode to your backend to get user informationconsole.log('Server auth code:', res.result.serverAuthCode)
-
-
Test your Application
-
Build your app and run
cap sync -
If you’ve done everything correctly, you should see the Google Connexion flow working properly

-
The language in the Google prompt depends on your Appareil’s language Paramètres.
Known Problems
Section titled “Known Problems”Privacy Screen Plugin Incompatibility
Section titled “Privacy Screen Plugin Incompatibility”The Google Connexion plugin is incompatible with @capacitor/privacy-screen. When using both plugins together, the Google Connexion WebView will be interrupted by the privacy screen.
Workaround: Call await PrivacyScreen.disable(); before calling the login function:
import { PrivacyScreen } from '@capacitor/privacy-screen';import { SocialLogin } from '@capgo/capacitor-social-login';
await PrivacyScreen.disable();await SocialLogin.login({ provider: 'google', options: {}});