Reputation: 1032
I've been trying to implement google_sign_in library for almost two days now. I have done all necessary configurations from both localhost and the firebase console.
Dependencies:
firebase_analytics: ^5.0.2
firebase_auth: ^0.14.0+5
cloud_firestore: ^0.13.5
flutter_facebook_login: ^3.0.0
mvc_pattern: ^5.0.0
flutter_screenutil: ^0.5.3
google_sign_in: ^4.4.4
Below is the _googleSignUp()
custom function.
Future<void> _googleSignUp() async {
try {
final GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/contacts.readonly',
],
hostedDomain: '',
clientId: '',
);
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
idToken: googleAuth.accessToken, accessToken: googleAuth.idToken);
final FirebaseUser user =
(await _auth.signInWithCredential(credential)).user;
print('Current user: ${user.displayName}');
return user;
} catch (e) {
print(e.message);
}
}
The problem is, whenever I trigger the _googleSignUp()
funtion with a button
click, I keep getting this log below and then nothing happens.
I/flutter (31065): No implementation found for method init on channel plugins.flutter.io/google_sign_in
Developers how do we fix this? Thank you.
Upvotes: 0
Views: 377
Reputation: 1
What worked for me is changing the AppDelegate.swift file in the ios/Runner folder to:
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Upvotes: 0
Reputation: 2412
After dealing with this problem for an entire day, I realized the google_sign_in throws that exception if you also have the flutter_facebook_login plugin but haven't configured it as per these instructions.
Nonsensical error message had me going in circles.
Upvotes: 1
Reputation: 80914
Upgrade the flutter_auth plugin to the latest version:
dependencies:
firebase_auth: ^0.16.0
https://pub.dev/packages/firebase_auth#-installing-tab-
Upvotes: 0