What is @firebase/installations-compat?
@firebase/installations-compat is a Firebase package that provides compatibility for Firebase installations. It allows you to manage and retrieve Firebase installation IDs, which are unique identifiers for app instances. This package is particularly useful for managing app instance identifiers and tokens, which can be used for various purposes such as analytics, notifications, and more.
What are @firebase/installations-compat's main functionalities?
Get Installation ID
This feature allows you to retrieve the unique installation ID for the current app instance. The installation ID can be used for identifying the app instance in various Firebase services.
const { getInstallations } = require('@firebase/installations-compat');
const installations = getInstallations();
installations.getId().then(id => {
console.log('Installation ID:', id);
});
Get Installation Token
This feature allows you to retrieve a token for the current app instance. The token can be used for authenticating requests to Firebase services.
const { getInstallations } = require('@firebase/installations-compat');
const installations = getInstallations();
installations.getToken().then(token => {
console.log('Installation Token:', token);
});
Delete Installation
This feature allows you to delete the current app instance's installation ID and associated data. This can be useful for resetting the app instance or managing user privacy.
const { getInstallations } = require('@firebase/installations-compat');
const installations = getInstallations();
installations.delete().then(() => {
console.log('Installation deleted');
});
Other packages similar to @firebase/installations-compat
@firebase/app
@firebase/app is the core Firebase package that initializes and configures Firebase in your app. While it does not specifically manage installation IDs, it is a foundational package that other Firebase services build upon.
@firebase/messaging
@firebase/messaging is a Firebase package that provides Firebase Cloud Messaging (FCM) functionality. It allows you to send and receive push notifications. While it does not manage installation IDs directly, it uses them to target specific app instances for notifications.
firebase-admin
firebase-admin is the Firebase Admin SDK, which allows you to manage Firebase services programmatically from a server environment. It provides broader functionality compared to @firebase/installations-compat, including user management, database access, and more.