diff --git a/packages/firebase_auth/CHANGELOG.md b/packages/firebase_auth/CHANGELOG.md index 068c6fa9cc45..137bb48a3939 100644 --- a/packages/firebase_auth/CHANGELOG.md +++ b/packages/firebase_auth/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0 + +* **Breaking Change**: Method FirebaseUser getToken was renamed to getIdToken. + ## 0.2.5 * Added support for linkWithCredential with Google credential diff --git a/packages/firebase_auth/android/src/main/java/io/flutter/firebaseauth/FirebaseAuthPlugin.java b/packages/firebase_auth/android/src/main/java/io/flutter/firebaseauth/FirebaseAuthPlugin.java index 870bd0ec604c..f86e868afed3 100755 --- a/packages/firebase_auth/android/src/main/java/io/flutter/firebaseauth/FirebaseAuthPlugin.java +++ b/packages/firebase_auth/android/src/main/java/io/flutter/firebaseauth/FirebaseAuthPlugin.java @@ -81,7 +81,7 @@ public void onMethodCall(MethodCall call, Result result) { case "signOut": handleSignOut(call, result); break; - case "getToken": + case "getIdToken": handleGetToken(call, result); break; case "linkWithEmailAndPassword": @@ -210,7 +210,7 @@ private void handleGetToken(MethodCall call, final Result result) { boolean refresh = arguments.get("refresh"); firebaseAuth .getCurrentUser() - .getToken(refresh) + .getIdToken(refresh) .addOnCompleteListener( new OnCompleteListener() { public void onComplete(@NonNull Task task) { diff --git a/packages/firebase_auth/example/lib/main.dart b/packages/firebase_auth/example/lib/main.dart index acd8c9312e54..37b1eaa66c28 100755 --- a/packages/firebase_auth/example/lib/main.dart +++ b/packages/firebase_auth/example/lib/main.dart @@ -43,7 +43,7 @@ class _MyHomePageState extends State { assert(user != null); assert(user.isAnonymous); assert(!user.isEmailVerified); - assert(await user.getToken() != null); + assert(await user.getIdToken() != null); if (Platform.isIOS) { // Anonymous auth doesn't show up as a provider on iOS assert(user.providerData.isEmpty); @@ -74,7 +74,7 @@ class _MyHomePageState extends State { assert(user.email != null); assert(user.displayName != null); assert(!user.isAnonymous); - assert(await user.getToken() != null); + assert(await user.getIdToken() != null); final FirebaseUser currentUser = await _auth.currentUser(); assert(user.uid == currentUser.uid); diff --git a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m index fd064fe7c41e..d86d26cd2253 100644 --- a/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m +++ b/packages/firebase_auth/ios/Classes/FirebaseAuthPlugin.m @@ -110,17 +110,17 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } else { [self sendResult:result forUser:nil error:nil]; } - } else if ([@"getToken" isEqualToString:call.method]) { + } else if ([@"getIdToken" isEqualToString:call.method]) { [[FIRAuth auth].currentUser - getTokenForcingRefresh:YES - completion:^(NSString *_Nullable token, NSError *_Nullable error) { - result(error != nil ? error.flutterError : token); - }]; + getIDTokenForcingRefresh:YES + completion:^(NSString *_Nullable token, NSError *_Nullable error) { + result(error != nil ? error.flutterError : token); + }]; } else if ([@"linkWithEmailAndPassword" isEqualToString:call.method]) { NSString *email = call.arguments[@"email"]; NSString *password = call.arguments[@"password"]; FIRAuthCredential *credential = - [FIREmailPasswordAuthProvider credentialWithEmail:email password:password]; + [FIREmailAuthProvider credentialWithEmail:email password:password]; [[FIRAuth auth].currentUser linkWithCredential:credential completion:^(FIRUser *user, NSError *error) { [self sendResult:result forUser:user error:error]; diff --git a/packages/firebase_auth/lib/firebase_auth.dart b/packages/firebase_auth/lib/firebase_auth.dart index 873bca52d560..927f78afc117 100755 --- a/packages/firebase_auth/lib/firebase_auth.dart +++ b/packages/firebase_auth/lib/firebase_auth.dart @@ -55,8 +55,8 @@ class FirebaseUser extends UserInfo { /// Obtains the id token for the current user, forcing a [refresh] if desired. /// /// Completes with an error if the user is signed out. - Future getToken({bool refresh: false}) { - return FirebaseAuth.channel.invokeMethod('getToken', { + Future getIdToken({bool refresh: false}) { + return FirebaseAuth.channel.invokeMethod('getIdToken', { 'refresh': refresh, }); } diff --git a/packages/firebase_auth/pubspec.yaml b/packages/firebase_auth/pubspec.yaml index d07422be4f9b..12430d6d62fe 100755 --- a/packages/firebase_auth/pubspec.yaml +++ b/packages/firebase_auth/pubspec.yaml @@ -3,7 +3,7 @@ name: firebase_auth description: Firebase Auth plugin for Flutter. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_auth -version: 0.2.5 +version: 0.3.0 flutter: plugin: diff --git a/packages/firebase_auth/test/firebase_auth_test.dart b/packages/firebase_auth/test/firebase_auth_test.dart index 9989a7f3cb74..acff8f67ca04 100755 --- a/packages/firebase_auth/test/firebase_auth_test.dart +++ b/packages/firebase_auth/test/firebase_auth_test.dart @@ -32,7 +32,7 @@ void main() { FirebaseAuth.channel.setMockMethodCallHandler((MethodCall call) async { log.add(call); switch (call.method) { - case "getToken": + case "getIdToken": return kMockIdToken; break; case "startListeningAuthState": @@ -71,14 +71,15 @@ void main() { test('signInAnonymously', () async { final FirebaseUser user = await auth.signInAnonymously(); verifyUser(user); - expect(await user.getToken(), equals(kMockIdToken)); - expect(await user.getToken(refresh: true), equals(kMockIdToken)); + expect(await user.getIdToken(), equals(kMockIdToken)); + expect(await user.getIdToken(refresh: true), equals(kMockIdToken)); expect( log, equals([ const MethodCall('signInAnonymously'), - const MethodCall('getToken', const {'refresh': false}), - const MethodCall('getToken', const {'refresh': true}), + const MethodCall( + 'getIdToken', const {'refresh': false}), + const MethodCall('getIdToken', const {'refresh': true}), ]), ); }); diff --git a/packages/firebase_database/android/src/main/java/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.java b/packages/firebase_database/android/src/main/java/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.java index 1ac3c0549ac6..a8ac10ce2bab 100644 --- a/packages/firebase_database/android/src/main/java/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.java +++ b/packages/firebase_database/android/src/main/java/io/flutter/plugins/firebase/database/FirebaseDatabasePlugin.java @@ -274,7 +274,8 @@ public void onMethodCall(final MethodCall call, final Result result) { case "DatabaseReference#update": { Map arguments = call.arguments(); - Map value = (Map) arguments.get("value"); + @SuppressWarnings("unchecked") + Map value = (Map) arguments.get("value"); DatabaseReference reference = getReference(arguments); reference.updateChildren(value, new DefaultCompletionListener(result)); break;