Firebase - Assign/Unassign to Topic
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens,Lists,Firebase project
Subscribes devices to a Firebase Cloud Messaging topic, or unsubscribes them. A topic is a named group of devices. Once devices are subscribed, Firebase - Send push notification can notify all of them with one send.
You don't create topics in advance. Firebase creates a topic the first time a device is subscribed to it.
This action is part of the Push Notifications add-on (DnnSharp.PushNotifications). The add-on is installed separately and needs the PUSHN feature in your license. If it isn't licensed, the action fails with a "not licensed" error. If you don't see the Push Notifications actions, the add-on isn't installed.
Typical Use Cases
- Subscribe a user's devices to the topics they pick on a preferences form
- Unsubscribe devices when the user turns off a type of notification
- Subscribe new devices to a general topic, such as
all-users, when the app registers them
Don't use it to
- Send a notification. Use Firebase - Send push notification.
- List the topics a device is subscribed to. Firebase doesn't return this through this action. Keep your own record if you need it.
Related Actions
| Action Name | Description |
|---|---|
| Firebase - Send push notification | Sends a notification to the devices subscribed to a topic. |
| Execute Actions For Each List Entry | Runs actions for each failed device in the error list, for example to delete old tokens. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Credential Key | The name of an appSettings key in web.config whose value is the full path of your Firebase service account key file, for example FirebaseCredentials. See Push Notifications. | Yes | empty string | Yes |
| Unassign Devices | When checked, the devices are unsubscribed from the topic. When unchecked, they're subscribed. | No | Unchecked | No |
| Topic Name | The topic, for example news or team-[TeamId]. | Yes | empty string | Yes |
| Device Ids | Device registration tokens separated by commas. Don't put spaces after the commas. | Yes | empty string | Yes |
| Output List Name | The name of the list that receives the devices Firebase rejected, for example TopicErrorsList. Brackets are optional. | No | empty string | No |
Output Parameters Reference
These are only set when Output List Name has a value.
| Parameter | Description |
|---|---|
[<Output List Name>:HasErrors] | True if Firebase rejected one or more devices, otherwise False. |
<Output List Name> | A list with one item per rejected device. It's only created when there are errors. Each item has Index (the position of the token in Device Ids, starting at 0), DeviceToken and Reason (the error text from Firebase). |
Considerations
- Rejected devices don't fail the action. If Firebase rejects some tokens, the others are still processed and the action succeeds. Set Output List Name and check
[<Output List Name>:HasErrors]. Without Output List Name, rejected devices are ignored. - Other errors fail the action. A missing or wrong key file, a network error or an invalid topic name stops execution. The credential errors are the same as for Firebase - Send push notification.
- Reusing the list name. In 1.28, if a list with the Output List Name already exists and devices are rejected again, the action fails. Use a different list name each time you run it in the same flow.
- Commas aren't trimmed.
token1, token2sends" token2", which Firebase rejects. - Batch size. Firebase accepts up to 1,000 tokens in one request.
- Topic names. Firebase only allows letters, numbers and the characters
-_.~%in topic names.
Examples
To understand how to use the below examples, please see Running Examples.
1. Subscribe a device and log rejected tokens
The first action subscribes the device in [DeviceToken] to the news topic and saves rejected devices in TopicErrorsList. The second action runs only when there were errors. It loops through the list and writes each rejected token and its reason to the log.
[
{
"Title": "Firebase - Assign/Unassign to Topic",
"ActionType": "Firebase.AssignToFirebaseTopic",
"Description": "Subscribe the device to news",
"Parameters": {
"CredentialKey": "FirebaseCredentials",
"UnassignDevices": false,
"TopicName": "news",
"DeviceIds": "[DeviceToken]",
"OutputEntityName": "TopicErrorsList"
}
},
{
"Title": "Execute Actions for each List Entry",
"ActionType": "ExecuteActionsOnEntityList",
"Description": "Log each rejected device",
"Condition": "[TopicErrorsList:HasErrors] == \"True\"",
"Parameters": {
"EntityName": "TopicErrorsList",
"ActionList": [
{
"Title": "Log Error",
"ActionType": "LogError",
"Description": "Log the rejected device",
"Parameters": {
"Message": "Could not subscribe [TopicErrorsList:DeviceToken] to news: [TopicErrorsList:Reason]"
}
}
]
}
}
]
2. Unsubscribe a user's devices
This action unsubscribes every device in [UserDeviceTokens], a comma-separated list, from the promotions topic.
{
"Title": "Firebase - Assign/Unassign to Topic",
"ActionType": "Firebase.AssignToFirebaseTopic",
"Description": "Turn off promotions",
"Parameters": {
"CredentialKey": "FirebaseCredentials",
"UnassignDevices": true,
"TopicName": "promotions",
"DeviceIds": "[UserDeviceTokens]",
"OutputEntityName": ""
}
}
Revised 10/03/2026