Implementing Push Notification
Here, we explain how to implement push notifications through the Firebase connector connected to the Interactor Engine.
You can get information about input variables in built-in-connectors page.
info
We support the Firebase connector for push notifications. Firebase
Steps
- Prepare Firebase Admin SDK
- Create Firebase Project
- Initialize the SDK in non-Google environments
- Create the Platform Connector Variable with given Firebase admin SDK info
- Query Parameters:
- userId:
connectorAccount
- The connectorAccount is an account that contains the connector's own information.
- userId:
- Body Parameters:
- name:
connector_account
- value: content of Firebase Admin SDK
- name:
- Example CURL:
- Replace value with the content of the your admin sdk json file
curl --location 'http://localhost:1290/v1/platform/connector/firebase/variable?userId=connectorAccount' \
--header 'Content-Type: application/json' \
--header 'api_key: default' \
--data-raw '{
"name": "connector_account",
"value": {
"type": "connector_account",
"project_id": "your_project_id",
"private_key_id": "your_private_key_id",
"private_key": "-----BEGIN PRIVATE KEY-----\nyour_private_key\n-----END PRIVATE KEY-----\n",
"client_email": "your_client_email",
"client_id": "your_client_id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-ye1yh%40interactor-418406.iam.gconnectoraccount.com",
"universe_domain": "googleapis.com"
}
}'
- Query Parameters:
- Get a server access token
- You need to get a server access token with user
connectorAccount
. - It only needs to be created once during the initial setup.
- Example Curl:
curl --location 'http://localhost:1290/v1/connector/firebase/oauth?userId=connectorAccount' \
--header 'api_key: default'
- You need to get a server access token with user
- Get a device Id from the client and send it to the Interactor Engine
- You should implement below in your client:
- initialize app
- initialize getMessaging
- get a permission from the user
- send a device token to the Interactor Engine
- Example Curl:
curl --location 'http://localhost:1290/v1/subscription?userId=your_user_id' \
--header 'Content-Type: application/json' \
--header 'api_key: default' \
--data '{
"platform": "interactor",
"connector": "firebase",
"trigger": "push.registered",
"variables": {
"token": "your_device_token"
}
}'
- You should implement below in your client:
- Send a push notification
- Once you're ready, you can send a push notification to the user using execute api
- Example Curl:
curl --location 'http://localhost:1290/v1/connector/firebase/action/push.send/execute?userId=your_user_id' \
--header 'Content-Type: application/json' \
--header 'api_key: default' \
--data '{
"notification": {
"title": "push test",
"body": "11231231"
}
}'
Helpful?