This is a comprehensive list of the breaking changes introduced in the major version releases of Capacitor Firebase Authentication plugin.
- The Firebase Javascript SDK has been updated to
11.2.0
.
- On Android, the
facebookLoginVersion
variable has been updated to18.0.0
. - On Android, the
firebaseAuthVersion
variable has been updated to23.1.0
. - On Android, the
playServicesAuthVersion
variable has been updated to20.7.0
.
On Android, the accessToken
and serverAuthCode
are now only requested when the scopes
option is set.
Error codes are now prefixed with auth/
to be consistent with the Firebase Web SDK.
- The Firebase Javascript SDK has been updated to
10.9.0
.
- On Android, the
firebaseAuthVersion
variable has been updated to22.3.1
. - On Android, the
playServicesAuthVersion
variable has been updated to21.0.0
. - On Android, the
facebookLoginVersion
variable has been updated to16.3.0
.
This plugin now supports Capacitor 5 only. Please run npx cap sync
after updating this package.
If you want to use this plugin with Capacitor 4, please install version 1.4.0
:
npm i @capacitor-firebase/[email protected]
Errors generated by the Firebase SDK now contain a code
property.
This can be used to identify the specific Firebase Authentication error.
try {
const result = await FirebaseAuthentication.signInWithEmailAndPassword({
email: '[email protected]',
password: '1234',
});
console.log(result.user);
} catch (error) {
if (error.code === 'wrong-password') {
alert('The password is invalid or the user does not have a password.');
}
}
On Android, error messages were previously generated with getLocalizedMessage
. They are no longer localized and are generated with getMessage
instead.
You should therefore check your error handling.
Deprecated parameters were removed from the API for Phone Number Sign-In and a new method confirmVerificationCode(...)
was added.
Before:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithPhoneNumber = async () => {
const { verificationId } = await FirebaseAuthentication.signInWithPhoneNumber(
{
phoneNumber: '123456789',
},
);
const verificationCode = window.prompt(
'Please enter the verification code that was sent to your mobile device.',
);
const result = await FirebaseAuthentication.signInWithPhoneNumber({
verificationId,
verificationCode,
});
return result.user;
};
Now:
import { FirebaseAuthentication } from '@capacitor-firebase/authentication';
const signInWithPhoneNumber = async () => {
return new Promise(async resolve => {
// Attach `phoneCodeSent` listener to be notified as soon as the SMS is sent
await FirebaseAuthentication.addListener('phoneCodeSent', async event => {
// Ask the user for the SMS code
const verificationCode = window.prompt(
'Please enter the verification code that was sent to your mobile device.',
);
// Confirm the verification code
const result = await FirebaseAuthentication.confirmVerificationCode({
verificationId: event.verificationId,
verificationCode,
});
resolve(result.user);
});
// Attach `phoneVerificationCompleted` listener to be notified if phone verification could be finished automatically
await FirebaseAuthentication.addListener(
'phoneVerificationCompleted',
async event => {
resolve(event.result.user);
},
);
// Start sign in with phone number and send the SMS
await FirebaseAuthentication.signInWithPhoneNumber({
phoneNumber: '123456789',
});
});
};
This plugin now supports Capacitor 4 only. Please run npx cap sync
after updating this package.
If you want to use this plugin with Capacitor 3, please install version 0.5.1
:
npm i @capacitor-firebase/[email protected]
Using the providers
configuration option you can select which providers (Google, Facebook, ...) should be loaded by the plugin.
Previously, all providers were loaded by default.
From now on, no providers will be loaded by default.
Please set the providers
configuration option and specify all providers you use.
Example (capacitor.config.ts
):
/// <reference types="@capacitor-firebase/authentication" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
FirebaseAuthentication: {
skipNativeAuth: false,
providers: ['apple.com', 'facebook.com'],
},
},
};
export default config;
Class referenced in the manifest, com.facebook.FacebookActivity, was not found in the project or the libraries [MissingClass]
.
Check out this comment in that case: issues/117#issuecomment-1208612107.
Add the following string
element to android/app/src/main/res/values/strings.xml
after the resources
element:
<string name="facebook_app_id">[APP_ID]</string>
<string name="fb_login_protocol_scheme">fb[APP_ID]</string>
+ <string name="facebook_client_token">[CLIENT_TOKEN]</string>
Add the following meta-data
element to android/app/src/main/AndroidManifest.xml
inside the application
element:
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
+<meta-data
+ android:name="com.facebook.sdk.ClientToken"
+ android:value="@string/facebook_client_token"/>