Try Sign-In for iOS

Use our iOS sample app to see how Sign-In works, or add Sign-In to your existing app.

To use this sample, make sure you have Xcode and CocoaPods.

Get the project

Start with the sample using the following command from a terminal:

pod try GoogleSignIn

CocoaPods will clone the sample project from GitHub and open it in Xcode.

Get an OAuth client ID

Click the button below to create a new Google API project and get an iOS client ID for the project. When prompted, specify com.google.samples.quickstart.SignInExample as the bundle ID.

Create an OAuth client ID

After you create the OAuth client ID, copy it over the placeholder text in AppDelegate.m:

[GIDSignIn sharedInstance].clientID = @"YOUR_CLIENT_ID";

Set the callback URL type

Before Sign-In can run, you need to set up a URL type to handle the callback. In your Xcode project's Info tab, under the URL Types section, find the URL Schemes box containing the string YOUR_REVERSED_CLIENT_ID. Replace this string with your reversed client ID—your client ID with the order of the dot-delimited fields reversed. For example:

com.googleusercontent.apps.1234567890-abcdefg

Run the application

Now you're ready to build and run the sample app from Xcode.

Select the SignInExample target then start the sample application on a device or in the iOS simulator by clicking the run button for the workspace.

How it works

Add a GIDSignInButton view to your app in a storyboard, a XIB file, or programmatically. In the app delegate, implement the signIn method that will be called when the sign-in button is tapped.

- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
  // Perform any operations on signed in user here.
  NSString *userId = user.userID;                  // For client-side use only!
  NSString *idToken = user.authentication.idToken; // Safe to send to the server
  NSString *fullName = user.profile.name;
  NSString *givenName = user.profile.givenName;
  NSString *familyName = user.profile.familyName;
  NSString *email = user.profile.email;
  // ...
}
      

Next steps

If you want to see how you can implement Google Sign-In in your own app, take a look at our implementation guide.

Add Sign-In to your app

Did you have a good experience? Run into trouble? Let us know!