tree: 133e9f35b54c16edb43bf3c97d1378304aec5e9a [path history] [tgz]
  1. example/
  2. ios/
  3. lib/
  4. pigeons/
  5. test/
  6. AUTHORS
  7. CHANGELOG.md
  8. LICENSE
  9. pubspec.yaml
  10. README.md
packages/google_sign_in/google_sign_in_ios/README.md

google_sign_in_ios

The iOS implementation of google_sign_in.

Usage

This package is endorsed, which means you can simply use google_sign_in normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.

However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.

iOS integration

  1. Create a Firebase project and register your application.
  2. Enable Google Sign-In for your Firebase project.
  3. Make sure to download a new copy of your project's GoogleService-Info.plist from step 2. Do not put this file in your project.
  4. Add the client ID from the GoogleService-Info.plist into your app's [my_project]/ios/Runner/Info.plist file.
    <key>GIDClientID</key>
    <!-- TODO Replace this value: -->
    <!-- Copied from GoogleService-Info.plist key CLIENT_ID -->
    <string>[YOUR IOS CLIENT ID]</string>
    
  5. If you need to authenticate to a backend server you can add a GIDServerClientID key value pair in your [my_project]/ios/Runner/Info.plist file.
    <key>GIDServerClientID</key>
    <string>[YOUR SERVER CLIENT ID]</string>
    
  6. Then add the CFBundleURLTypes attributes below into the [my_project]/ios/Runner/Info.plist file.
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<!-- TODO Replace this value: -->
			<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
			<string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
		</array>
	</dict>
</array>
<!-- End of the Google Sign-in Section -->

As an alternative to editing the Info.plist in your Xcode project, you can instead configure your app in Dart code. In this case, skip steps 4 to 5 and pass clientId and serverClientId to the GoogleSignIn constructor:

final GoogleSignIn googleSignIn = GoogleSignIn(
  // The OAuth client id of your app. This is required.
  clientId: 'Your Client ID',
  // If you need to authenticate to a backend server, specify its OAuth client. This is optional.
  serverClientId: 'Your Server ID',
);

Note that step 6 is still required.