Migration Guide
Notice
This page is archived and might not reflect the latest version of the FlutterFire plugins.
We changed the way developers integrate Flutter applications with Firebase in mid 2020. If you're currently using FlutterFire and wish to upgrade to the latest recommended versions, follow this guide to help ease that process.
If you're starting a fresh project, you can ignore this page and follow the Getting Started documentation.
The table below shows the recommended package versions for each plugin this migration guide covers.
| Plugin | Version |
|---|---|
cloud_firestore | ^0.16.0 |
cloud_functions | ^0.9.0 |
firebase_auth | ^0.20.1 |
firebase_core | ^0.7.0 |
firebase_crashlytics | ^0.4.0 |
firebase_storage | ^7.0.0 |
firebase_messaging | ^8.0.0-dev.15 |
firebase_remote_config | ^0.8.0-dev.0 |
Breaking Changes & Deprecations#
Although breaking changes have been kept to a minimum, the substantial changes and improvements which have been made required us to break a few things (for the greater good). Where possible, we've deprecated some "old ways" of integrating FlutterFire, and you should aim to replace these deprecations as soon as possible.
Migration Steps#
1. Adding firebase_core#
The FlutterFire plugins now depend on the firebase_core plugin. The plugin is responsible for connecting your Flutter
application to your Firebase project(s), and without it all other plugins will not work.
Add the plugin to your pubspec.yaml file within your project:
2. Update Firebase Plugins#
Update the Firebase plugins you use in your project to versions that are compatible with the new firebase_core plugin.
Edit the plugin versions in your pubspec.yaml file within your project to match the versions below:
Install the updated plugins by running the following command from the project root:
We also recommend running flutter clean before continuing.
3. Platform Setup#
Even though you may have already set up your platform to connect with Firebase, we recommend following the new documentation steps for each platform to ensure everything is up-to-date.
Previously, it was possible to use FlutterFire without a "default" Firebase application. This has now changed, and all platforms now require an underlying default Firebase app to be registered. The platform specific guides below show you how to set up a default Firebase application:
A. Android Installation#
Ensure that the
com.google.gms:google-servicesplugin is up-to-date.- Update the version by changing the
classpath 'com.google.gms:google-services:4.3.3'line in yourandroid/build.gradlefile to use version4.3.3or higher.
- Update the version by changing the
Ensure your apps Gradle wrapper distribution version is v5 or higher, FlutterFire uses v5.6.2 for its examples.
- Update the version by changing the
distributionUrlvalue in your projectsandroid/gradle/wrapper/gradle-wrapper.propertiesfile.- e.g. setting to v5.6.2:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
- e.g. setting to v5.6.2:
- Update the version by changing the
Ensure that you're not manually importing any Firebase Android SDK dependencies in your
android/app/build.gradlefilesdependencies { ... }section.- e.g. remove any lines similar to:
implementation 'com.google.firebase:firebase-{PRODUCT}:{VERSION} - The reworked plugins now automatically manage the versions of the Firebase SDKs used internally, so these are no
longer required.
- See the overriding native sdk versions documentation if this is something you require.
- e.g. remove any lines similar to:
Crashlytics only: Remove the
maven { url 'https://maven.fabric.io/public' }line from your projectsandroid/build.gradlefile.Crashlytics only: Remove the
classpath 'io.fabric.tools:gradle:1.31.2'line from your projectsandroid/build.gradlefile.Crashlytics only: Remove the
apply plugin: 'io.fabric'line from your projectsandroid/app/build.gradlefile.Crashlytics only: Remove any dependencies referencing
*com.crashlytics.sdk.android:crashlytics*line from your projectsandroid/app/build.gradlefile (inside thedependencies { .. }block).Crashlytics only: Follow the new Android integration steps shown in the FlutterFire Crashlytics installation documentation .
Messaging only: Remove any dependencies referencing
*com.google.firebase:firebase-messaging*line from your projectsandroid/app/build.gradlefile (inside thedependencies { .. }block).Messaging only: If you added the previous versions
intent-filterto yourandroid/app/src/main/AndroidManifest.xmlfile, remove it:
- Messaging only: Messaging now supports v2 embedding, it's recommended that you upgrade your Flutter app to use v2 embedding if you haven't done so already.
- If your can't upgrade to v2 embedding yet, there are some additional manual steps you'll need to do before you can use messaging in your app. Please see the Android section of the FlutterFire Messaging documentation for more information.
- If you were using v1 embedding on the previous version of messaging then note that the java class name has changed
to
FlutterFirebaseMessagingBackgroundServicefromFlutterFirebaseMessagingServiceand you may need to update this in yourMainActivity.javafile.
B. iOS Installation#
These steps can also apply to macOS.
If you manually import Firebase and configure it via
[FIRApp configure];orFirebaseApp.configure()within your projectsios/{projectName}/AppDelegate{.m/.swift}file, you can now safely remove it - FlutterFire automatically handles this for you.Crashlytics only: Open your
ios/Runner.xcworkspaceworkspace file with Xcode.- From Xcode select
Runnerfrom the left-hand side project navigation. - Select the
Build Phasestab in the middle pane. - Find a script in the list of Build Phases that contains
${PODS_ROOT}/Fabric/runas the shell script. Once located, press thexon the right of the row to remove that script. If you can't find one then you can ignore this step.
- From Xcode select
Crashlytics only: Follow the new iOS integration steps shown in the FlutterFire Crashlytics installation documentation .
If you face CocoaPods issues when building, follow the steps below in the CocoaPods could not find compatible versions for pod section.
Messaging only: If you previously added the
FirebaseAppDelegateProxyEnabledkey with afalsevalue to yourInfo.plistto disable swizzling; you can now remove it, the plugin now supports multiple delegates and will internally forward to any other plugins that may have previously registered a delegate.Additionally, swizzling is now no longer used on iOS and the plugin calls
addApplicationDelegateon the FlutterPlugin Registrar instead. It is required for macOS however as the macOS registrar does not supportaddApplicationDelegate.
C. Web Installation#
4. Initialize FlutterFire#
To ensure each plugin has a consistent API and to enable the possibility of some new features, you are now required to initialize FlutterFire before performing any other Firebase related functionality.
The firebase_core package exposes a Firebase class, provides an
initializeApp method. This method should be called as soon as possible in
your application. It is responsible for ensuring the default app is ready, and bootstraps all additional FlutterFire
plugins which are installed.
To learn more, view the Initializing FlutterFire documentation.
Plugin Usage#
Each plugin now provides a consistent API for integrating with Firebase. The example below shows how
the cloud_firestore
package previously created a new instance vs the new way:
If you'd like to a plugin with a secondary Firebase application, use the instanceFor method instead:
To learn more about secondary Firebase app instances, view the Initializing secondary apps documentation.
Plugin Changes#
Core#
DEPRECATED:
FirebaseApp.configuremethod is now deprecated in favor of theFirebase.initializeAppmethod.DEPRECATED:
FirebaseApp.allAppsmethod is now deprecated in favor of theFirebase.appsproperty.- Previously,
allAppswas asynchronous & is now synchronous.
- Previously,
DEPRECATED:
FirebaseApp.appNamedmethod is now deprecated in favor of theFirebase.appmethod.BREAKING:
FirebaseApp.optionsgetter is now synchronous.FirebaseOptionshas been reworked to better match web property names:- DEPRECATED:
googleAppIDis now deprecated in favor ofappId. - DEPRECATED:
projectIDis now deprecated in favor ofprojectId. - DEPRECATED:
bundleIDis now deprecated in favor ofbundleId. - DEPRECATED:
clientIDis now deprecated in favor ofandroidClientId. - DEPRECATED:
trackingIDis now deprecated in favor oftrackingId. - DEPRECATED:
gcmSenderIDis now deprecated in favor ofmessagingSenderId. - Added support for
authDomain. - Added support for
trackingId. - Required properties are now
apiKey,appId,messagingSenderId&projectId.
- DEPRECATED:
Added support for deleting Firebase app instances via the
deletemethod onFirebaseApp.iOS: The default Firebase app is now automatically configured without needing to manually add Objective-C code to your iOS application.
Added support for returning consistent error messages from
firebase-dartplugin.- Any FlutterFire related errors now throw a
FirebaseException.
- Any FlutterFire related errors now throw a
Added a
FirebaseExceptionclass to handle all FlutterFire related errors.- Matching the web sdk, the exception returns a formatted "[plugin/code] message" message when thrown.
Added support for
setAutomaticDataCollectionEnabled&isAutomaticDataCollectionEnabledon aFirebaseAppinstance.Added support for
setAutomaticResourceManagementEnabledon aFirebaseAppinstance.Android: Gradle build tools updated to 3.5.0 from 3.3.0.
Android: Removed Gradle ‘hacks’ and upgrade Flutter SDK requirement from
>=1.12.13+hotfix.4to>=1.12.13+hotfix.5- based on PR https://github.com/flutter/plugins/pull/2651
Android: Switched to using Firebase BoM to manage SDK versions
Authentication#
Overall, Firebase Auth has been heavily reworked to bring it inline with the federated plugin setup along with adding new features, documentation and many more unit and end-to-end tests. The API has mainly been kept the same, however there are some breaking changes.
General:
- BREAKING: The
FirebaseUserclass has been renamed toUser. - BREAKING: The
AuthResultclass has been renamed toUserCredential. - NEW: The
ActionCodeSettingsclass is now consumable on all supporting methods.- NEW: Added support for the
dynamicLinkDomainproperty.
- NEW: Added support for the
- NEW: Added a new
FirebaseAuthExceptionclass (extendsFirebaseException).- All errors are now returned as a
FirebaseAuthException, allowing you to access the code & message associated with the error. - In addition, it is now possible to access the
emailandcredentialproperties on exceptions if they exist. - BREAKING: Error codes previously in the format
ERROR_WRONG_PASSWORDare now in the formatwrong-password.
- All errors are now returned as a
- BREAKING: The
FirebaseAuth- BREAKING: Accessing the current user via
currentUser()is now synchronous via thecurrentUsergetter. - BREAKING:
isSignInWithEmailLink()is now synchronous. - BREAKING:
EmailAuthProvider.providerIdis nowEmailAuthProvider.PROVIDER_ID. - DEPRECATED:
FirebaseAuth.fromApp()is now deprecated in favor ofFirebaseAuth.instanceFor(). - DEPRECATED:
onAuthStateChangedhas been deprecated in favor ofauthStateChanges(). - NEW: Added support for
idTokenChanges()stream listener. - NEW: Added support for
userChanges()stream listener.- The purpose of this API is to allow users to subscribe to all user events without having to manually hydrate
app state in cases where a manual reload was required (e.g.
updateProfile()).
- The purpose of this API is to allow users to subscribe to all user events without having to manually hydrate
app state in cases where a manual reload was required (e.g.
- NEW: Added support for
applyActionCode(). - NEW: Added support for
checkActionCode(). - NEW: Added support for
verifyPasswordResetCode(). - NEW: Added support for accessing the current language code via the
languageCodegetter. - NEW:
setLanguageCode()now supports providing anullvalue.- On web platforms, if
nullis provided the Firebase projects default language will be set. - On native platforms, if
nullis provided the device language will be used.
- On web platforms, if
- NEW:
verifyPhoneNumber()exposes aautoRetrievedSmsCodeForTestingproperty.- This allows developers to test automatic SMS code resolution on Android devices during development.
- NEW (iOS):
appVerificationDisabledForTestingsetting can now be set for iOS.- This allows developers to skip ReCaptcha verification when testing phone authentication.
- NEW (iOS):
userAccessGroupsetting can now be set for iOS & macOS.- This allows developers to share authentication states across multiple apps or extensions on iOS & macOS. For more information see the Firebase iOS SDK documentation.
- BREAKING: Accessing the current user via
User- BREAKING: Removed the
UpdateUserInfoclass when usingupdateProfilein favor of named arguments. - NEW: Added support for
getIdTokenResult(). - NEW: Added support for
verifyBeforeUpdateEmail(). - FIX: Fixed several iOS crashes when the Firebase SDK returned
nilproperty values. - FIX: Fixed an issue on Web & iOS where a user's email address would still show after unlinking the email/password provider.
- BREAKING: Removed the
UserCredential- NEW: Added support for accessing the user's
AuthCredentialvia thecredentialproperty.
- NEW: Added support for accessing the user's
AuthProvider&AuthCredential- DEPRECATED: All sub-class (e.g.
GoogleAuthProvider)getCredential()methods have been deprecated in favor ofcredential().- DEPRECATED:
EmailAuthProvider.getCredentialWithLink()has been deprecated in favor ofEmailAuthProvider.credentialWithLink().
- DEPRECATED:
- NEW: Supporting providers can now assign scope and custom request parameters.
- The scope and parameters will be used on web platforms when triggering a redirect or popup
via
signInWithPopup()orsignInWithRedirect().
- The scope and parameters will be used on web platforms when triggering a redirect or popup
via
- DEPRECATED: All sub-class (e.g.
Crashlytics#
- BREAKING: Removal of Fabric SDKs and migration to the new Firebase Crashlytics SDK.
- BREAKING: The following methods have been removed as they are no longer available on the Firebase Crashlytics SDK:
setUserEmailsetUserNamegetVersionisDebuggable
- BREAKING:
lognow returns a Future. Callinglognow sends logs immediately to the underlying Crashlytics SDK instead of pooling them in Dart. - BREAKING: the methods
setInt,setDouble,setStringandsetBoolhave been replaced bysetCustomKey.setCustomKeyreturns a Future. CallingsetCustomKeynow sends custom keys immediately to the underlying Crashlytics SDK instead of pooling them in Dart.
- DEPRECATED:
enableInDevModehas been deprecated, useisCrashlyticsCollectionEnabledandsetCrashlyticsCollectionEnabledinstead. - DEPRECATED:
Crashlyticshas been deprecated, useFirebaseCrashlyticsinstead. - NEW: Custom keys that are automatically added by FlutterFire when calling
reportErrorare now prefixed withflutter_error_. - NEW: Calling
.crash()on Android & iOS/macOS now reports a custom named exception to the Firebase Console. This allows you to easily locate test crashes.- Name:
FirebaseCrashlyticsTestCrash. - Message:
This is a test crash caused by calling .crash() in Dart..
- Name:
- NEW:
recordErrornow uses a named native exception when reporting to the Firebase Console. This allows you to easily locate errors originating from Flutter.- Name:
FlutterError.
- Name:
- NEW: Added support for
checkForUnsentReports.- Checks a device for any fatal or non-fatal crash reports that haven't yet been sent to Crashlytics.
- See reference API docs for more information.
- NEW: Added support for
deleteUnsentReports.- If automatic data collection is disabled, this method queues up all the reports on a device for deletion.
- See reference API docs for more information.
- NEW: Added support for
didCrashOnPreviousExecution.- Checks whether the app crashed on its previous run.
- See reference API docs for more information.
- NEW: Added support for
sendUnsentReports.- If automatic data collection is disabled, this method queues up all the reports on a device to send to Crashlytics.
- See reference API docs for more information.
- NEW: Added support for
setCrashlyticsCollectionEnabled.- Enables/disables automatic data collection by Crashlytics.
- See reference API docs for more information.
- NEW: Added support for
isCrashlyticsCollectionEnabled.- If the current Crashlytics instance is collecting reports - if false, then no crash reporting data is sent to Firebase.
- See reference API docs for more information.
- FIX: Fixed a bug that prevented keys from being set on iOS devices.
Firestore#
Along with the below changes, the plugin has undergone a quality of life update to better support exceptions thrown. Any
Firestore specific errors now return a FirebaseException (see Core changes), allowing you to directly access the code
(e.g. permission-denied) and message.
FirebaseFirestore:- NEW: Add
useFirestoreEmulator(String host, int port)support. - BREAKING: Calling
settings()now accepts aSettingsinstance. - DEPRECATED: Calling
document()is deprecated in favor ofdoc(). - DEPRECATED: Calling
Firestore(app: app)is now deprecated. UseFirebaseFirestore.instanceorFirebaseFirestore.instanceForinstead. - BREAKING:
enablePersistencehas now been removed, seesettings()instead. - NEW: Add
clearPersistence()support. - NEW: Add
disableNetwork()support. - NEW: Add
enableNetwork()support. - NEW: Add
snapshotInSync()support. - NEW: Add
terminate()support. - NEW: Add
waitForPendingWrites()support.
- NEW: Add
CollectionReference:- BREAKING: Getting a collection parent document via
parent()has been changed to a getterparent. - DEPRECATED: Calling
document()is deprecated in favor ofdoc().
- BREAKING: Getting a collection parent document via
Query:- BREAKING: The internal query logic has been overhauled to better assert invalid queries locally.
- BREAKING:
getDocuments/gethas been updated to accept an instance ofGetOptions(see below). - DEPRECATED: Calling
getDocuments()is deprecated in favor ofget(). - NEW: Query methods are now chainable.
- NEW: It is now possible to call same-point cursor based queries without throwing (e.g. calling
endAt()and thenendBefore()will replace the "end" cursor query with theendBefore). - NEW: Added support for
limitToLast.
QuerySnapshot:- DEPRECATED:
documentshas been deprecated in favor ofdocs. - DEPRECATED:
documentChangeshas been deprecated in favor ofdocChanges. - NEW:
docsnow returns aList<QueryDocumentSnapshot>vsList<DocumentSnapshot>. This doesn't break existing functionality.
- DEPRECATED:
DocumentReference:- BREAKING:
setData/sethas been updated to accept an instance ofSetOptions(see below, supportsmergeFields). - BREAKING:
get()has been updated to accept an instance ofGetOptions(see below). - BREAKING: Getting a document parent collection via
parent()has been changed to a getterparent. - DEPRECATED:
documentIDhas been deprecated in favor ofid. - DEPRECATED:
setData()has been deprecated in favor ofset(). - DEPRECATED:
updateData()has been deprecated in favor ofupdate().
- BREAKING:
DocumentSnapshot:- BREAKING: Getting a snapshots' data via the
datagetter is now done via thedata()method. - DEPRECATED:
documentIDhas been deprecated in favor ofid. - NEW: Added support for fetching nested snapshot data via the
get()method. If no data exists at the given path, aStateErrorwill be thrown.
- BREAKING: Getting a snapshots' data via the
DocumentChange:- DEPRECATED: Calling
document()is deprecated in favor ofdoc().
- DEPRECATED: Calling
WriteBatch:- BREAKING:
setData/setnow supportsSetOptionsto merge data/fields (previously this accepted aMap). - DEPRECATED:
setData()has been deprecated in favor ofset(). - DEPRECATED:
updateData()has been deprecated in favor ofupdate().
- BREAKING:
Transaction:- BREAKING: Transactions have been overhauled to address a number of issues:
- Values returned from the transaction will now be returned from the Future. Previously, only primitive values (
e.g.
String) were supported. It is now possible to return values such as aDataSnapshot. - When manually throwing an exception, the context was lost and a generic
PlatformExceptionwas thrown. You can now throw & catch on any exceptions. - The modify methods on a transaction (
set,delete,update) were previously Futures. This has been updated to better reflect how transactions should behave - they are now synchronous and are executed atomically once the transaction handler block has finished executing.
- Values returned from the transaction will now be returned from the Future. Previously, only primitive values (
e.g.
- BREAKING: Transactions have been overhauled to address a number of issues:
FieldPath:- NEW: The constructor has now been made public to accept a
ListofStringvalues. Previously field paths were accessible only via a dot-notated string path. This meant attempting to access a field in a document with a.in the name (e.g.foo.bar@gmail.com) was impossible.
- NEW: The constructor has now been made public to accept a
GetOptions: New class created to support how data is fetched from Firestore (server, cache, serverAndCache).SetOptions: New class created to bothmergeandmergeFieldswhen setting data on documents.GeoPoint:- BREAKING: Added latitude and longitude validation when constructing a new
GeoPointinstance.
- BREAKING: Added latitude and longitude validation when constructing a new
Functions#
FirebaseFunctions:- DEPRECATED:
useFunctionsEmulator({required String origin})parameters have been changed in line with every other package emulator API;useFunctionsEmulator(String host, int port). - DEPRECATED: Class
CloudFunctionsis now deprecated. UseFirebaseFunctionsinstead. - DEPRECATED: Calling
CloudFunctions.instanceorCloudFunctions(app: app, region: region)is now deprecated. UseFirebaseFunctions.instanceorFirebaseFunctions.instanceFor(app: app, region: region)instead. - DEPRECATED: Calling
getHttpsCallable(functionName: functionName)is deprecated in favor ofhttpsCallable(functionName) - DEPRECATED:
CloudFunctionsExceptionis deprecated in favor ofFirebaseFunctionsException. - NEW:
FirebaseFunctionsExceptionnow exposes adetailsproperty to retrieve any additional data provided with the exception returned by an HTTPS callable function. - NEW: Internally, instances of
FirebaseFunctionsare now cached and lazily loaded. - NEW:
httpsCallableaccepts an instance ofHttpsCallableOptions(see below).
- DEPRECATED:
HttpsCallable:- DEPRECATED: Setting
timeoutis deprecated in favor of usingHttpsCallableOptions(see below).
- DEPRECATED: Setting
HttpsCallableResult:- BREAKING:
datais now read-only, only its getter is exposed. - FIX:
HttpsCallableResult'sdataproperty can now return a Map, List or a primitive value. Previously the Web implementation incorrectly assumed that a Map was always returned by the HTTPS callable function.
- BREAKING:
HttpsCallableOptions:- NEW: This new class has been created to support setting options for
httpsCallableinstances.
- NEW: This new class has been created to support setting options for
Messaging#
This plugin is now federated to allow integration with other platforms, along with upgrading underlying SDK versions.
We've also added lots of features which can be seen in the changelog below, however notably the biggest changes are:
Removed all manual native code changes that were originally required for integration - this plugin works out of the box once configured with Firebase & APNs.
Support for macOS.
iOS background handler support.
Android background handler debugging and logging support.
Android V2 embedding support.
Reworked API for message handling (Streams + explicit handlers).
Fully typed Message & Notification classes (vs raw Maps).
New Apple notification permissions & support.
Detailed documentation.
FirebaseMessaging:- BREAKING:
configure()has been removed in favor of calling specific static methods which return Streams.- Why?: The previous implementation of
configure()caused unintended side effects if called multiple times (either to register a different handler, or remove handlers). This change allows developers to be more explicit about registering handlers and removing them without effecting others via Streams.
- Why?: The previous implementation of
- DEPRECATED: Calling
FirebaseMessaging()has been deprecated in favor ofFirebaseMessaging.instance&FirebaseMessaging.instanceFor(). - DEPRECATED:
requestNotificationPermissions()has been deprecated in favor ofrequestPermission(). - DEPRECATED:
deleteInstanceID()has been deprecated in favor ofdeleteToken(). - DEPRECATED:
autoInitEnabled()has been deprecated in favor ofisAutoInitEnabled. - NEW: Added support for
isAutoInitEnabledas a synchronous getter. - NEW: Added support for
getInitialMessage(). This API has been added to detect whether a messaging containing a notification has caused the application to be opened via users interaction. - NEW: Added support for
deleteToken(). - NEW: Added support for
getToken(). - NEW: [Apple] Added support for
getAPNSToken(). - NEW: [Apple] Added support for
getNotificationSettings(). SeeNotificationSettingsbelow. - NEW: [Apple] Added support for
requestPermission(). SeeNotificationSettingsbelow. New permissions such ascarPlay,crtiticalAlert,announcementare now supported. - NEW: [Android] Added support for
sendMessage(). ThesendMessage()API enables support for sending FCM payloads back to a custom server from the device. - NEW: [Android] When receiving background messages on the separate background Dart executor whilst in debug, you should now see flutter logs and be able to debug/add breakpoints your Dart background message handler.
- NEW: [Apple] Added support for
setForegroundNotificationPresentationOptions(). By default, iOS devices will not show notifications in the foreground. Use this API to override the defaults. See documentation for Android foreground notifications. - NEW - [Android] Firebase Cloud Messages that contain a notification are now always sent to Dart regardless of whether the app was in the foreground or background. Previously, if a message came through that contained a notification whilst your app was in the foreground then FCM would not notify the plugin messaging service of the message (and subsequently your handlers in Dart) until the user interacted with it.
- BREAKING:
Event handling:
- Event handling has been reworked to provide a more intuitive API for developers. Foreground based events can now
be accessed via Streams:
- NEW:
FirebaseMessaging.onMessageReturns a Stream that is called when an incoming FCM payload is received whilst the Flutter instance is in the foreground, containing a [RemoteMessage]. - NEW:
FirebaseMessaging.onMessageOpenedAppReturns a [Stream] that is called when a user presses a notification displayed via FCM. This replaces the previousonLaunchandonResumehandlers. - NEW:
FirebaseMessaging.onBackgroundMessage()Sets a background message handler to trigger when the app is in the background or terminated.
- NEW:
- Event handling has been reworked to provide a more intuitive API for developers. Foreground based events can now
be accessed via Streams:
IosNotificationSettings:- DEPRECATED: Usage of the
IosNotificationSettingsclass is now deprecated (currently used with the now deprecatedrequestNotificationPermissions()method).- Instead of this class, use named arguments when calling
requestPermission()and read the permissions back via the returnedNotificationSettingsinstance.
- Instead of this class, use named arguments when calling
- DEPRECATED: Usage of the
NotificationSettings:- NEW: A
NotificationSettingsclass is returned from calls torequestPermission()andgetNotificationSettings(). It contains information such as the authorization status, along with the platform specific settings.
- NEW: A
RemoteMessage:- NEW: Incoming FCM payloads are now represented as a
RemoteMessagerather than a rawMap.
- NEW: Incoming FCM payloads are now represented as a
RemoteNotification:- NEW:When a message includes a notification payload, the
RemoteMessageincludes aRemoteNotificationrather than a rawMap.
- NEW:When a message includes a notification payload, the
Other:
- Additional types are available throughout messaging to aid with the latest changes:
BackgroundMessageHandler,AppleNotificationSetting,AppleShowPreviewSetting,AuthorizationStatus,AndroidNotificationPriority,AndroidNotificationVisibility
- Additional types are available throughout messaging to aid with the latest changes:
Remote Config#
The plugin has been updated and reworked to better mirror the features currently offered by the native (iOS and Android) clients.
RemoteConfig:
- CHORE: migrate to platform interface.
- FEAT: support multiple firebase apps.
RemoteConfig.instanceFor()can be used to retrieve an instance of RemoteConfig for a particular Firebase App. - BREAKING:
fetch()now takes no arguments.RemoteConfigSettingsshould be used to specify the freshness of the cached config via theminimumFetchIntervalproperty. - BREAKING:
activateFetched()is nowactivate(). - FEAT: Added
fetchAndActivate()support. - FEAT: Added
ensureInitialized()support.
RemoteConfigSettings
- BREAKING:
fetchTimeoutMillisis nowfetchTimeout. - BREAKING:
minimumFetchIntervalMillisis nowminimumFetchInterval - BREAKING:
fetchTimeoutandminimumFetchIntervalare refactored frominttoDuration.
FetchThrottledException
- BREAKING: removed
FetchThrottledException. The general FirebaseException is used to handle all RemoteConfig specific exceptions.
Storage#
Overall, Firebase Storage has been heavily reworked to bring it inline with the federated plugin setup along with adding new features, documentation and many more unit and end-to-end tests (tested on Android, iOS & macOS).
FirebaseStorage:- DEPRECATED: Constructing an instance is now deprecated, use
FirebaseStorage.instanceFororFirebaseStorage.instanceinstead. - DEPRECATED:
getReferenceFromUrl()is deprecated in favor of callingref()with a path. - DEPRECATED:
getMaxOperationRetryTimeMillis()is deprecated in favor of the gettermaxOperationRetryTime. - DEPRECATED:
getMaxUploadRetryTimeMillis()is deprecated in favor of the gettermaxUploadRetryTime. - DEPRECATED:
getMaxDownloadRetryTimeMillis()is deprecated in favor of the gettermaxDownloadRetryTime. - DEPRECATED:
setMaxOperationRetryTimeMillis()is deprecated in favor ofsetMaxUploadRetryTime(). - DEPRECATED:
setMaxUploadRetryTimeMillis()is deprecated in favor ofsetMaxUploadRetryTime(). - DEPRECATED:
setMaxDownloadRetryTimeMillis()is deprecated in favor ofsetMaxDownloadRetryTime(). - NEW: To match the Web SDK, calling
ref()creates a newReferenceat the bucket root, whereas an optional path (ref('/foo/bar.png')) can be used to create aReferencepointing at a specific location. - NEW: Added support for
refFromURL, which accepts a Google Storage (gs://) or HTTP URL and returns aReferencesynchronously.
- DEPRECATED: Constructing an instance is now deprecated, use
Reference:- BREAKING:
StorageReferencehas been renamed toReference. - DEPRECATED:
getParent()is deprecated in favor of.parent. - DEPRECATED:
getRoot()is deprecated in favor of.root. - DEPRECATED:
getStorage()is deprecated in favor of.storage. - DEPRECATED:
getBucket()is deprecated in favor of.bucket. - DEPRECATED:
getPath()is deprecated in favor of.fullPath. - DEPRECATED:
getName()is deprecated in favor of.name. - NEW: Added support for
list(options).- Includes
ListOptionsAPI (see below).
- Includes
- NEW: Added support for
listAll(). - NEW:
putString()has been added to accept a string value, of type Base64, Base64Url, a Data URL or raw strings.- Data URLs automatically set the
Content-Typemetadata if not already set.
- Data URLs automatically set the
- NEW:
getData()does not require amaxSize, it can now be called with a default of 10mb.
- BREAKING:
NEW
ListOptions:- The
list()method accepts aListOptionsinstance with the following arguments:maxResults- limits the number of results returned from a call. Defaults to 1000.pageToken- a page token returned from aListResult- used if there are more items to query.
- The
NEW
ListResult:- A
ListResultclass has been added, which is returned from a call tolist()orlistAll(). It exposes the following properties:items(List<Reference>): Returns the list of reference objects at the current reference location.prefixes(List<Reference>): Returns the list of reference sub-folders at the current reference location.nextPageToken(String): Returns a string (or null) if a next page during alist()call exists.
- A
Tasks:
- Tasks have been overhauled to be closer to the expected Firebase Web SDK Storage API, allowing users to access and
control ongoing tasks easier. There are a number of breaking changes & features with this overhaul:
- BREAKING:
StorageUploadTaskhas been renamed toUploadTask(extendsTask). - BREAKING:
StorageDownloadTaskhas been renamed toDownloadTask(extendsTask). - BREAKING:
StorageTaskEventhas been removed (see below). - BREAKING:
StorageTaskSnapshothas been renamed toTaskSnapshot. - BREAKING:
pause(),cancel()andresume()are now Futures which return a boolean value to represent whether the status update was successful.- Previously, these were
voidmethods but still carried out an asynchronous tasks, potentially leading to uncaught exceptions.
- Previously, these were
- BREAKING:
isCanceled,isComplete,isInProgress,isPausedandisSuccessfulhave now been removed. Instead, you should subscribe to the stream (for paused/progress/complete/error events) or the taskFuturefor task completion/errors. - Additionally, the latest
TaskSnapshotnow provides the latestTaskStateviatask.snapshot.state. - BREAKING: The
eventsstream (nowsnapshotEvents) previously returned aStorageTaskEvent, containing aStorageTaskEventTypeandStorageTaskSnapshotInstead, the stream now returns aTaskSnapshotwhich includes thestate. - BREAKING: A task failure and cancellation now throw a
FirebaseExceptioninstead of a new event. - DEPRECATED:
eventsstream is deprecated in favor ofsnapshotEvents. - DEPRECATED:
lastSnapshotis deprecated in favor ofsnapshot.
- BREAKING:
- Tasks have been overhauled to be closer to the expected Firebase Web SDK Storage API, allowing users to access and
control ongoing tasks easier. There are a number of breaking changes & features with this overhaul:
Example#
The new Tasks API matches the Web SDK API, for example:
Subscribing to Stream updates and/or the tasks delegating Future is optional - if you require progress updates on your task use the Stream, otherwise the Future will resolve once it's complete. Using both together is also supported.
Common Upgrade Issues#
CocoaPods could not find compatible versions for pod#
This issue can happen when you upgrade your FlutterFire packages and attempt to build for iOS or macOS, this is usually down to one of the following:
- Your
Podfile.lockversion inside your iOS or macOS directory is out of date and locked to older versions of the Firebase iOS SDKs whereas the newly upgraded FlutterFire packages might be using newer versions of these SDKs.- Solution: Delete the
Podfile.lockfile and try your build again. This file will get regenerated after the nextpod install.
- Solution: Delete the
- Your pod specs repo is out of date, meaning CocoaPods locally isn't aware of any potential newer versions of the
Firebase iOS SDKs that have been recently published.
- Solution: Run
pod repo updatein your terminal and try your build again.
- Solution: Run