Skip to main content
Version: 7.0.0

Implementing Push Notification

Here, we explain how to implement push notifications through the Firebase service connected to the Interactor Engine.

You can get information about input variables in built-in-services page.

info

We support the Firebase service for push notifications. Firebase

Steps

  1. Prepare Firebase Admin SDK
  2. Create the Platform Service Variable with given Firebase admin SDK info
    • Query Parameters:
      • userId: serviceAccount
        • The serviceAccount is an account that contains the service's own information.
    • Body Parameters:
      • name: service_account
      • value: content of Firebase Admin SDK
    • Example CURL:
      • Replace value with the content of the your admin sdk json file
      curl --location 'http://localhost:1290/v1/platform/service/firebase/variable?userId=serviceAccount' \
      --header 'Content-Type: application/json' \
      --header 'api_key: default' \
      --data-raw '{
      "name": "service_account",
      "value": {
      "type": "service_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.gserviceaccount.com",
      "universe_domain": "googleapis.com"
      }
      }'
  3. Get a server access token
    • You need to get a server access token with user serviceAccount.
    • It only needs to be created once during the initial setup.
    • Example Curl:
      curl --location 'http://localhost:1290/v1/service/firebase/oauth?userId=serviceAccount' \
      --header 'api_key: default'
  4. Get a device Id from the client and send it to the Interactor Engine
    • You should implement below in your client:
      1. initialize app
      2. initialize getMessaging
      3. get a permission from the user
      4. 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",
        "service": "firebase",
        "trigger": "push.registered",
        "variables": {
        "token": "your_device_token"
        }
        }'
  5. 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/service/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"
      }
      }'