Actions4
- FCM Token Actions
- Notifications Actions
Overview
This node interacts with Google Firebase Notifications, specifically focusing on managing Firebase Cloud Messaging (FCM) tokens stored in Firestore collections. The "Get" operation for the "FCM Token" resource retrieves user token data from a specified Firestore collection.
Common scenarios include:
- Retrieving FCM tokens associated with a specific user ID to send targeted push notifications.
- Accessing device-specific tokens stored under a user document to manage or audit notification endpoints.
Practical example:
- You have a mobile app where each user’s devices register their FCM tokens in Firestore. Using this node, you can fetch all tokens for a given user ID to send personalized notifications or verify which devices are registered.
Properties
Name | Meaning |
---|---|
Collection | The name of the Firestore collection where the FCM tokens are stored (e.g., "tokens"). |
UID | The user ID that corresponds to the Firestore document ID within the collection. |
Output
The output is a JSON array containing either:
- An object representing the user document data if no device sub-collection exists.
- Or an object mapping device IDs to their respective token details, including creation timestamps and token strings, if a "device_ids" sub-collection exists under the user document.
Example output when device tokens exist:
[
{
"deviceId1": {
"created_at": 1680000000000,
"token": "fcm_token_string_1"
},
"deviceId2": {
"created_at": 1680000100000,
"token": "fcm_token_string_2"
}
}
]
If no device tokens are found, the output contains the user document data as a single-element array.
No binary data output is produced by this operation.
Dependencies
- Requires valid Google Firebase credentials with access to Firestore.
- The node expects these credentials to be configured in n8n as an API key credential for Google Firebase Notifications.
- The Firebase Admin SDK is used internally to interact with Firestore and messaging services.
Troubleshooting
Error: "No credentials got returned!"
This indicates missing or misconfigured Firebase credentials in n8n. Ensure the API key credential is properly set up and linked to the node.Error: "User collection not found"
The specified user document (by UID) does not exist in the given collection. Verify the collection name and UID are correct.Error: "No data found for the user"
The user document exists but contains no data. Check if the document has been populated correctly in Firestore.General Firestore permission errors
Make sure the Firebase service account used has sufficient permissions to read documents and sub-collections in Firestore.