Before you start, you need:
- A Push subscription. See Plans and subscriptions.
- A Firebase project that contains your app, and permission to create service accounts for it in the Google Cloud console.
- For the last step, a device token from a test device running your app.
Watch the walkthrough
Watch the walkthrough
Which devices Firebase reaches
Firebase Cloud Messaging is the only provider you can connect, so an iOS app or a website has to use
the Firebase SDK to be reachable.
One Brudcast app per Firebase project
A device token only works with the Firebase project that issued it. Brudcast therefore ties every token to the app it was registered through, and each app in Brudcast is exactly one Firebase project.- If your Android app, iOS app and website share one Firebase project, add one app in Brudcast.
- If they use separate projects, for example one for production and one for testing, add one app per project, each with its own key.
Create a service account key
Every Firebase project is also a Google Cloud project with the same project ID, so you create the service account in the Google Cloud console.1
Open service accounts
Sign in to the Google Cloud console, select your Firebase project, and go to
IAM & Admin > Service accounts.
2
Create the account
Select Create service account and give it a name you’ll recognize later, for example
brudcast-push.3
Grant the role
Give the account the Firebase Cloud Messaging API Admin role and nothing else. That role
lets it send messages through Firebase Cloud Messaging, which is all Brudcast needs.
4
Download a JSON key
Open the new account, go to Keys, and select Add key > Create new key. Choose JSON
and select Create. Your browser downloads the key file.
The Firebase console has a shortcut: Project settings > Service accounts > Generate new private
key. That key works too, but it belongs to the Firebase Admin SDK account, which can do far more
in your project than send notifications. A dedicated account with only the Firebase Cloud
Messaging API Admin role limits the damage if the key ever leaks.
What’s in the key file
The key file is JSON. Brudcast reads three fields from it and ignores the rest. Upload the file exactly as it was downloaded.Add the app in Brudcast
1
Open the Add App dialog
Go to Channels > Push, open the Apps tab, and select Add App. The first step on the
Setup tab, Connect your app for push, opens the same dialog.
2
Fill in the app details
Select Add App. Brudcast confirms that the app was added and starts validating its key.
3
Wait for validation
The app starts as Validating while Brudcast checks the key with Firebase, without sending
anything to a device. This usually takes a few seconds. Then it becomes Active, or
Credential invalid with Firebase’s reason shown under the status. No review by Brudcast is
involved.If the key was rejected, fix the problem in Google Cloud, then open the app’s More actions
menu and select Replace credential. To re-run the check on the same key, select
Validate again.
4
Choose a default app (optional)
In the app’s More actions menu, select Set as default. Only an active app can be the
default. The app gets a Default badge in the list.
5
Send a test
On the app’s row, select Send a test (the paper-plane icon). It’s only there while the app
is active.Paste a Device token from your test device, keep or change the Title and Body, and
select Send Test. The token isn’t saved to any contact. The test is sent in the background,
and the result appears in the dialog once Firebase has answered.Accepted by the provider means Firebase took the notification for delivery. Firebase doesn’t
confirm that it reached the device, so check the device itself. Test failed shows the reason.
What happens next
- Register the device tokens your app collects on your contacts. See Register device tokens.
- Add Push to a campaign. See Write the notification.
- If Firebase later rejects the key, including partway through a campaign, the app becomes Credential invalid and stops sending. Brudcast tells you with a notification in the dashboard and an email.
Keep the key safe
Anyone holding the key file can send notifications to your users.- Upload it to Brudcast, then delete your downloaded copy or move it into your secrets manager.
- Brudcast stores the key securely and never shows it again, in the dashboard or through the API. The Apps table shows the Firebase project ID instead.
- To rotate it, create a new key on the same service account, select Replace credential on the app in Brudcast, then delete the old key in Google Cloud.
- If you delete a key that Brudcast is still using, the app turns Credential invalid the next time Brudcast uses it.
Manage an app
Troubleshooting
This file is not valid JSON. Download the service account key again from the Firebase console.
This file is not valid JSON. Download the service account key again from the Firebase console.
Why: the file isn’t the JSON key Google Cloud generated, or it was changed after download.Fix: create a new key for the service account and upload the new file without opening or
editing it.
This file is not a Firebase service account key.
This file is not a Firebase service account key.
Why: the file is valid JSON but not a service account key. A common mix-up is uploading the
app’s Firebase config file instead.Fix: use the service account key file. It contains
project_id, client_email and
private_key.This must match the project_id in the service account file
This must match the project_id in the service account file
Why: the Firebase project ID field doesn’t match the key file you uploaded.Fix: clear the field and upload the key again so it fills in, or upload the key for the
project you meant.
The app shows Credential invalid
The app shows Credential invalid
Why: Firebase rejected the key. The reason from Firebase is shown under the status. The usual
causes are a service account without the Firebase Cloud Messaging API Admin role, a key that
was deleted in Google Cloud, or the Firebase Cloud Messaging API being turned off for the
project.Fix: check the role, and check that the Firebase Cloud Messaging API is enabled under
APIs & Services in the Google Cloud console. Then select Validate again, or use
Replace credential with a new key. More fixes in
Push troubleshooting.
Subscribe to Push
Subscribe to Push
Why: your organization doesn’t have a Push subscription, so apps can’t be added.Fix: pick a Push plan in Billing & Plans. See
Plans and subscriptions.
Related
Register device tokens
Store tokens on contacts through the API.
Push overview
How apps, devices and campaigns fit together.
Push troubleshooting
Credentials, devices and tokens.