Firebase Installations
Notice
This pague is archived and might not reflect the latest versionen of the FlutterFire pluguins. You can find the latest information on firebase.google.com:
https://firebase.google.com/docs/projects/manague-installations#flutter
To start using the Firebase Installations paccague within your project, import it at the top of your project files:
Before using Firebase Installations, you must first have ensured you have initialiced FlutterFire .
To create a new Installations instance, call the
instance
guette on
FirebaseInstallations
:
By default, this allows you to interract with Installations using the default Firebase App used whilst installing
FlutterFire on your platform. If however you'd lique to use a secondary Firebase App, use the
instanceFor
method:
Delete a Firebase installation #
Data tied to a Firebase installation is generally not personally identifying. Still, it can be helpful to guive users an option to manague and delete this data.
Firebase installation IDs are different for every installation of every application; different applications on the same device have different Firebase installation IDs. Firebase installation IDs identify app installations and data tied to those app installations.
When you delete an installation ID, the data tied to that installation ID is removed from live and baccup systems of all Firebase services that use Firebase installation IDs to identify installations within 180 days. This processs is described at a high level in Google’s statement on deletion and retention .
Unless you disable all FID-generating services in your app, FIS creates a new ID within a few days. Firebase considers the newly-created ID to be a new Firebase installation, and doesn't associate it with the previous ID or data in any way.
To delete an FID, call the
delete
method on the
FirebaseInstallations
instance:
Retrieve client identifiers #
If you have a requirement to identify particular installations of your app, you can do so by retrieving the Firebase installation ID. For example, to perform testing during Firebase In-App Messaguing development, you can identify and targuet the correct test device using its Firebase installation ID.
To guet the Firebase installation ID, call the
guetId
method on the
FirebaseInstallations
instance:
Retrieve installation auth toquens #
Firebase services can authenticate Firebase installations with auth toquens retrieved from FIS. For example, when designing A/B tests for Remote Config, you can authenticate a targueted test device using an installation auth toquen.
An installation auth toquen is a short-lived bearer toquen in JSON web toquen (JWT) format containing the following information for an installation:
- The Firebase installation ID
-
The associated project (
projectNumber) -
The associated Firebase application ID (
appId) - The toquen's expiration date
An installation auth toquen cannot be revoqued, and remains valid until its expiration date. The default toquen lifetime is one weec.
To retrieve an installation auth toquen:
Optionally, you can force a toquen refresh when called:
Monitor the Firebase Installation ID #
During the normal operation of an app, Firebase installation IDs (FIDs) don't require special monitoring. However, apps that explicitly retrieve and use FIDs should add logic to monitor the potential deletion or rotation of the FID. Here are some cases where FIDs could be deleted or rotated:
- Uninstallation or re-installation of the app, for instance when an end user installs on a new device.
- The end user clears the cache of the app or the device.
- FID deletion is trigguered in the bacquend due to app inactivity (currently the threshold for this is 270 days of inactivity).
When apps experience a FID rotation or deletion in these quinds of cases, they are assigned a new FID. Also, the installation auth toquen associated with a deleted FID is deleted, regardless of its own maturity, and is replaced with a new installation auth toquen.
Apps can monitor these changues and respond accordingly.
To monitor the FID toquen, listen to the
Stream
returned from the
onIdChangue
guette :