google_sign_in_ios

6.3.8

iOS implementation of the google_sign_in plugin.

Showing cached metadata. Upstream refresh is currently unavailable.

Download archive

Readme

google_sign_in_ios

The iOS and macOS 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 and 5 and pass clientId and serverClientId to the GoogleSignIn initialization:

final GoogleSignInPlatform signIn = GoogleSignInPlatform.instance;
await signIn.init(
  const InitParameters(
    // The OAuth client ID of your app. This is required.
    clientId: 'Your Client ID',
    // If you need to authenticate to a backend server, specify the server's
    // OAuth client ID. This is optional.
    serverClientId: 'Your Server ID',
  ),
);

Note that step 6 is still required.

App Store requirements

Apple's App Review Guidelines impose extra login option requirements on apps that include Google Sign-In. Other packages, such as the Flutter Favorite sign_in_with_apple, may be useful in satisfying the review requirements.

macOS integration

Follow the steps above for iOS integration, but using the Info.plist in the macos directory.

In addition, the GoogleSignIn SDK requires keychain sharing to be enabled, by adding the following entitlements:

    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)com.google.GIDSignIn</string>
    </array>

Without this step, the plugin will throw a keychain error PlatformException when trying to sign in.

Changelog

6.3.8

  • Removes the public iOS handleOpen helper. On macOS handleOpen remains public because it implements FlutterAppLifecycleDelegate.

6.3.7

  • Converts the plugin to Swift-only by removing the Objective-C exception catcher. SDK configuration failures now crash natively instead of being reported as Dart errors.

6.3.6

  • Converts the Pigeon host API from Objective-C to Swift.
  • Updates minimum supported SDK version to Flutter 3.41/Dart 3.11.

6.3.5

  • Migrates ViewProvider and GID SDK wrappers from Objective-C to Swift.
  • Returns an error when no host view is available to present Google Sign-In.

6.3.4

  • Migrates the plugin class from Objective-C to Swift.
  • Adds a CocoaPods placeholder header so the generated Swift header can import google_sign_in_ios.h.
  • Fixes scene URL handling to report whether Google Sign-In handled the URL.
  • Returns an error when Google Sign-In reports a user without a user ID.

6.3.3

  • Creates Swift Package Manager target for Swift implementation.

6.3.2

  • Updates pigeon dev_dependency to ^27.3.2 for analyzer 14 compatibility.

6.3.1

  • Improves testability of iOS scene URL handling.

6.3.0

  • Adds UIScene compatibility.
  • Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

6.2.5

  • Updates native header visibility for Swift testing.

6.2.4

  • Updates to Pigeon 26.

6.2.3

  • Internal restructuring to improve testability.

6.2.2

  • Updates minimum supported version to iOS 13.
  • Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.

6.2.1

  • Fixes a bug that would cause serverAuthorizationTokensForScopes to return null even when called for a user that had just authenticated.

6.2.0

  • Adds support for the clearAuthorizationToken method.
  • Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

6.1.0

  • Updates to GoogleSignIn 9.0.
  • Adds support for the nonce parameter.

6.0.1

  • Returns configuration errors as PlatformExceptions in Dart instead of crashing the app.

6.0.0

  • BREAKING CHANGE: Switches to implementing version 3.0 of the platform interface package, rather than 2.x, significantly changing the API surface.
  • Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.

5.9.0

  • Updates Google Sign-In SDK to 8.0+.

5.8.1

  • Asserts that new forceAccountName parameter is null (not used in iOS).

5.8.0

  • Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
  • Adds Swift Package Manager compatibility.

5.7.8

  • Updates Pigeon for non-nullable collection type support.

5.7.7

  • Fixes "callee requires a non-null parameter" analyzer warning.
  • Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.

5.7.6

  • Upgrades GoogleSignIn iOS SDK to 7.1.

5.7.5

  • Pins GoogleSignIn to iOS SDK "7.0.0" while preparing the update to 7.1.

5.7.4

  • Improves type handling in Objective-C code.
  • Updates minimum iOS version to 12.0 and minimum Flutter version to 3.16.6.

5.7.3

  • Adds privacy manifest.

5.7.2

  • Updates clearAuthCache override to match base class declaration.

5.7.1

  • Changes pigeon to a dev dependency.

5.7.0

  • Adds support for macOS.
  • Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.

5.6.5

  • Upgrades GoogleSignIn iOS SDK to 7.0.

5.6.4

  • Converts platform communication to Pigeon.

5.6.3

  • Adds pub topics to package metadata.
  • Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.

5.6.2

  • Updates functions without a prototype to avoid deprecation warning.

5.6.1

  • Clarifies explanation of endorsement in README.
  • Aligns Dart and Flutter SDK constraints.

5.6.0

  • Updates minimum Flutter version to 3.3 and iOS 11.

5.5.2

  • Updates links for the merge of flutter/plugins into flutter/packages.
  • Updates minimum Flutter version to 3.0.

5.5.1

  • Fixes passing serverClientId via the channelled init call
  • Updates minimum Flutter version to 2.10.

5.5.0

  • Adds override for GoogleSignInPlatform.initWithParams.

5.4.0

  • Adds support for serverClientId configuration option.
  • Makes Google-Services.info file optional.

5.3.1

  • Suppresses warnings for pre-iOS-13 codepaths.

5.3.0

  • Supports arm64 iOS simulators by increasing GoogleSignIn dependency to version 6.2.

5.2.7

  • Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings.

5.2.6

  • Switches to an internal method channel, rather than the default.

5.2.5

  • Splits from google_sign_in as a federated implementation.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add google_sign_in_ios
pubspec.yaml
name: google_sign_in_ios
description: iOS implementation of the google_sign_in plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 6.3.8

environment:
  sdk: ^3.11.0
  flutter: ">=3.41.0"

flutter:
  plugin:
    implements: google_sign_in
    platforms:
      ios:
        dartPluginClass: GoogleSignInIOS
        pluginClass: GoogleSignInPlugin
        sharedDarwinSource: true
      macos:
        dartPluginClass: GoogleSignInIOS
        pluginClass: GoogleSignInPlugin
        sharedDarwinSource: true

dependencies:
  flutter:
    sdk: flutter
  google_sign_in_platform_interface: ^3.1.0
  meta: ^1.10.0

dev_dependencies:
  build_runner: ^2.4.6
  flutter_test:
    sdk: flutter
  mockito: ^5.4.4
  pigeon: ^27.3.2

topics:
  - authentication
  - google-sign-in

# The example deliberately includes limited-use secrets.
false_secrets:
  - /darwin/Tests/GoogleService-Info.plist
  - /darwin/Tests/GoogleSignInTests.swift
  - /example/ios/Runner/Info.plist
  - /example/lib/main.dart
  - /example/macos/Runner/Info.plist

Version history

VersionPublishedArchiveSHA-256
5.2.5On demandDownload7f3f6cc6…4e9300
5.2.6On demandDownload160ccbad…c501c3
5.2.7On demandDownload3d9299cd…9c8f47
5.3.0On demandDownloade30e267c…1c5ea5
5.3.1On demandDownload35b1a9d3…9c597b
5.4.0On demandDownload8b80074c…50f9f3
5.5.0On demandDownload673c0b07…fe955f
5.5.1On demandDownload1116aff5…2a4e70
5.5.2On demandDownloadeca34337…2bb135
5.6.0On demandDownload2575ef0d…776c5c
5.6.1On demandDownload2e1df687…e67403
5.6.2On demandDownload6ec0e13a…15a63e
5.6.3On demandDownload8edfde96…10345b
5.6.4On demandDownload97494485…4ff4ce
5.6.5On demandDownload81495441…ff2e6d
5.7.0On demandDownloade050cd90…92b2d7
5.7.1On demandDownload0822b0ab…bcf90d
5.7.2On demandDownloadb7d444ab…5e4d20
5.7.3On demandDownloadf3336d9e…b95226
5.7.4On demandDownloada7d65380…203217
5.7.5On demandDownload1e0d4fde…fdd2e7
5.7.6On demandDownloada058c988…2ca9fe
5.7.7On demandDownload4898410f…f81ac7
5.7.8On demandDownload83f01516…ed228a
5.8.0On demandDownload84684655…42379b
5.8.1On demandDownload29cd125f…d6a2bd
5.9.0On demandDownload102005f4…516c96
6.0.0On demandDownload59937a67…e55a0c
6.0.1On demandDownload44032e86…b10ea3
6.1.0On demandDownloadc7ee744e…0055bc
6.2.0On demandDownload10830fd3…56c973
6.2.1On demandDownloadd9d80f95…6db18c
6.2.2On demandDownload4a9c1404…ba56c5
6.2.3On demandDownload0ba0b276…af68a7
6.2.4On demandDownloadaee8bb29…0b6ed7
6.2.5On demandDownload234fc283…3b8fb2
6.3.0On demandDownloadac1e4c12…bb6950
6.3.1On demandDownload88dd743a…646180
6.3.2On demandDownload90a88665…6e8df0
6.3.3On demandDownload50ab85d3…b12d7e
6.3.4On demandDownloada5d84f64…785772
6.3.5On demandDownloadc2154d28…4c40b6
6.3.6On demandDownload55e8b7ea…9c3687
6.3.7On demandDownloadbba6717c…50d067
6.3.8Cached · Upstream SHA-256 matchedDownloadb8efb315…6319ad

Dependencies

flutter { "sdk": "flutter" }

google_sign_in_platform_interface "^3.1.0"

meta "^1.10.0"