Integrating GoogleSigin in iOS (Swift)

Updated 12 December 2023

Save
Integrating GoogleSigin in iOS (Swift)

In iOS we can login into the app through Social account, and then we don’t need to fill a long form to register into the app, let’s see below integrating GoogleSigin in iOS (Swift).

GoogleSignIn SDK installation

First, we need to install Google Sign-in pod.

Here’s how your Podfile should look like:

Installing Google Sign-in pod

 Creating OAuth client ID for GoogleSignIn

After the SDK installation, you will need an OAuth client ID and an iOS URL scheme so that you can continue with the configuration in Xcode.

Now open Google APIs Console and create a project for your sample app. If you have already created a project, you can also select it from the project list.

Google APIs Console for creating the project

After creating a project, we also need to configure the OAuth consent screen. Follow the steps as shown in the image below to choose your app user type and then create the OAuth consent screen.

configure the OAuth consent screen

In the OAuth consent screen information page, fill in the application name, and then click “save”. This application name will be the name being shown in the Google Sign-in form when a user tries to sign in using your app.

After finishing configuring the OAuth consent screen, it’s time to create the OAuth client ID. Please check the below image to navigate to the OAuth client ID creation page.

Once you reach the OAuth client ID creation page, go ahead and select “iOS” as application type, fill in the name and also your sample app bundle ID, and then click “create”.

OAuth client ID creation page

Copy the OAuth client ID and iOS URL scheme you just created and save them, you will need both of them in just a bit.

OAuth client ID and iOS URL scheme

 GoogleSignIn SDK configuration in Xcode

Step1: Open project in xcode, select target and in Info section add iOS URL scheme in URL Types

GoogleSignIn SDK configuration in Xcode

Step2: Now, open AppDelegate class and import GoogleSignIn module.

Step3: After that, add below code into application(_:didFinishLaunchingWithOptions:) method.

Step4: Then just after application(_:didFinishLaunchingWithOptions:), add below method

Finally, the GoogleSignIn is implemented in our project, now we can run it and check GoogleSignIn.

As, we can see integrating GoogleSigin in iOS (Swift) is so easy, for more detailed information please check here.

Also check Google Signin implementation in objective-c here.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • Swapnil Kada
    • jitendra kumar (Moderator)
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home