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 Google

Select the option for SignInExample.xcodeproj from the prompt.

Get a configuration file

To use the sample, you need to provide some additional information to get a configuration file and finish setting up your project. Use the Bundle ID com.google.samples.quickstart.SignInExample for the sample.

After you complete the registration, download the GoogleServices-Info.plist file to add to your project.

Get a Configuration File

Add the configuration file to your project

Drag the GoogleService-Info.plist file you just downloaded into the root of your Xcode project and add it to all targets.

Run the application

Before Sign-In can run, you need to set up a URL type to handle the callback. In your project's Info tab, under the URL Types section, find the URL Schemes box containing the string ending with YOUR_CLIENT_ID. Replace this string with the value of the REVERSED_CLIENT_ID string in GoogleService-Info.plist.

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!