Push Notifications for Android
- Generate your private key file
- Upload your private key file to Sailthru
Generate your private key file
- Login to your Firebase account
- Select your project
- Select the cog icon next to 'Project Overview' then select 'Project settings'
- Ensure 'Firebase Cloud Messaging API" is enabled
- Go to the 'Cloud Messaging' tab
- If 'Firebase Cloud Messaging API (V1)' does not display "Enabled" next to it, you will need to enable it
- Select the three dots icon on the right hand side
- Select 'Manage API in Google Cloud Console' (it will open in another tab)
- Click the 'Enable' button
- Select the three dots icon on the right hand side
- Go to the Service Accounts tab
- Click Generate New Private Key (.json file), then confirm by clicking Generate Key
- Securely store the JSON file containing the key
Upload your private key file to Sailthru
- Login to your Sailthru account
- Go to Settings > Developer > Google Android
- Upload the .json file to the Service Account (.json) upload field
- If this was done successfully you will see
- "This certificate is valid", and
- "Service Account: Uploaded and saved successfully" (top right corner of screen)
- If this was not done successfully you will see
- This upload field remains blank, and
- Related error messages (top right corner of screen)
Having trouble uploading your Service Account (.json) file?
If you are unable to upload your private key file to Sailthru, check your permissions
- Click Manage service account permissions
- Click View Access
- Click Analyze > Run query
- See which role(s) your app is assigned:
To be able to send messages, the role must have these specific permissions:- cloudmessaging.messages.create
- firebasenotifications.messages.create
- firebasenotifications.messages.delete
- firebasenotifications.messages.get
- firebasenotifications.messages.list
- Firebasenotifications.messages.update
If you are using Firebase's default roles, these roles contain the correct permissions:
- Firebase Admin
- Firebase Grow Admin
- Firebase Admin SDK Administrator Service Agent
Otherwise, you will need to create a new role or update an existing one, and grant it to a service account.
To create a new custom role:
- Go to the Google Cloud Console
- IAM & Admin > Roles
- "+ Create Role"
- Fill in the fields
- Add the above permissions
Note, there are two filters. - Filter by property name or value and search for the above permissions
- Create
To create a new service account and a new private key:
- Go to Service Accounts from the left side nav
- "+ Create Service Account"
- Fill in the fields
- "Create and continue" to Step 2
- Select a role > Custom > The role you just created
- Done
- Select the new service account you just created
- "Keys"
- "Add key" > "Create new key"
- You should now have your new service_account.json key