Actions4
- FCM Token Actions
- Notifications Actions
FCM Token → Update
AI-generatedOverview
This node integrates with Google Firebase to manage Firebase Cloud Messaging (FCM) tokens and send notifications. Specifically, the FCM Token - Update operation updates or creates a document in a specified Firestore collection representing a user's FCM token(s). It supports storing tokens either directly under the user document or nested under device IDs.
Common scenarios include:
- Keeping users' device tokens up-to-date for push notifications.
- Managing multiple devices per user by associating tokens with device IDs.
- Ensuring that your backend has the latest registration tokens to target devices accurately.
Example use case: When a mobile app registers or refreshes its FCM token, this node can update the Firestore database with the new token linked to the user ID and optionally the device ID.
Properties
| Name | Meaning |
|---|---|
| Collection | The Firestore collection name where user token documents are stored (e.g., "tokens"). |
| UID | The user ID used as the Firestore document ID to identify the user record. |
| Device ID | (Optional) The device identifier; if provided, the token is stored under this device's doc. |
| FCM Token | The Firebase Cloud Messaging registration token to store/update for the user/device. |
Output
The output JSON contains the result of the Firestore write operation:
- If a
deviceIdis provided, the node sets the token and timestamp under the subcollectiondevice_ids/{deviceId}of the user document. - If no
deviceIdis provided, it sets the token and timestamp directly on the user document. - The output reflects the Firestore write response, which typically does not contain detailed data but confirms success.
No binary data is output by this operation.
Dependencies
- Requires a valid Google Firebase service account credential with access to Firestore.
- The node uses the Firebase Admin SDK initialized with the project ID, client email, and private key from credentials.
- Firestore must be enabled in the Firebase project.
- Proper permissions to read/write documents in the specified collection are necessary.
Troubleshooting
- Missing Credentials Error: If no credentials are provided or invalid, the node throws an error indicating missing credentials. Ensure you configure the API authentication token correctly.
- Firestore Permission Denied: Insufficient Firestore permissions will cause errors when reading or writing documents. Verify IAM roles and Firestore rules.
- Document Not Found: If updating a device ID under a user document that does not exist, the node creates the user document automatically.
- Invalid Parameters: Providing empty or incorrect collection names, UIDs, or tokens may cause failures. Validate inputs before execution.
- Private Key Formatting: The private key string replaces escaped newline characters (
\n) with actual newlines. Incorrect formatting may cause initialization errors.