
Enable Auxia to Send Push Notifications
1. Service Account Setup
Auxia uses a GCP service account to authenticate push notification API calls.
Follow these steps:
-
Get started using Firebase with an existing Google Cloud project.
-
Create a service account in the linked GCP project.
-
Assign the following role to the service account:
Firebase Cloud Messaging API Admin
-
Generate a JSON Key for this service account.
Share this service account JSON key with the Auxia team.
2. FCM Token
The FCM token is a unique identifier for a device registered with Firebase Cloud Messaging (FCM). This token is required to send push notifications to a device.
Lifecycle:
- Use
getToken()
to generate the token. - Monitor for token refresh events.
Ensure your application updates the user_id to FCM token mapping on your backend. This ensures push notifications are delivered to the correct users.
For a sample implementation, see the Sample Flutter Set up section.
The user_id to FCM token mapping should be shared with the Auxia team through User Attributes ingestion. Use the property fcm_token
with the string_value
field set for the property value.
3. Delivery Details
Pre-requisites:
- FCM token is used to identify a particular user.
- Service account JSON Key is used for authentication.
- On the server, the JSON key is used to retrieve a short-lived OAuth 2.0 access token.
- The access token is used in the send-message API with the FCM token as the user identifier.
Auxia uses the Notification message type for standard fields:
title
body
image
Non-standard fields are sent via the Data message type.
Example payload:
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"notification":{
"title":"Portugal vs. Denmark",
"body":"great match!"
},
"data" : {
"Nick" : "Mario",
"Room" : "PortugalVSDenmark"
}
}
}