Custom Native Push

Integrating a custom Native Push Notification provider as part of your Operator API

Fast Tracks supports Firebase as Native Push Notification provider, if your business need a provider which is not a part of the list of supported providers then you can build this API.

Fast Track Native Push Notification Service

The Fast Track Native Push Notification service can be configured to send Native Push Notification requests to the Operator API endpoints listed below, which allows the Operator to manage the Native Push Notification provider. It supports sending messages and to get fetch delivery status. Sending is available for both single or batched Native Push Notification requests.

The following endpoints can be built as a part for your Operator API:

⬆️ POST /channels/push/single

⬆️ POST /channels/push/batch

The Operator can then forward these requests to the Native Push Notification provider for processing and answer back with the respective responses.

API format and responses need to be formatted as outlined below

It is important that the "meta" data outlined below is sent back to Fast Track in either Webhook or Polling so that conversion data can be stored correctly. Please refer to the shown examples and the tables underneath for further clarification.

Pre-Requisites

  • Advice Fast Track if any rate limiting should be taken into consideration. (If you plan to implement rate limiting please contact Fast Track before, so we can guide you on supported implementation)

  • Advice Fast Track if any batch maximums should be taken into consideration.

  • Provide Fast Track with any credentials specific for the integrated providers (if required)

Send Native Push Notification (Single)

A single Native Push Notification send request will contain the data of each individual Native Push Notification in separate requests to the API.

Endpoint Implementation

Implement the endpoint in the format below to support single-send Native Push Notification through API.

⬆️ POST <operator-api-endpoint-url>/channels/push/single

Request Header

The header of the sent request contains an "X-Api-Key" which is a token required to authenticate the API calls at the endpoint. This token needs to be passed on to Fast Track in order to make these requests.

Request Body Schema

Refer to the following example of a single Native Push Notification request sent by Fast Track. The description of each field is listed in the table below it.

{
  "activity": {
    "id": "BE0F442F-6A2F-471E-8421-C103232AC4F8",
    "brand_id": 1,
    "user_id": "111",
    "internal_user_id": 111,
    "activity_id": 1,
    "origin": "origin-a",
    "action_group_id": 2,
    "trigger_hash": "8eb3474509644cfdf07d9a61e90ddc7e",
    "action_id": 3
  },
  "body": "",
  "title": "Test Title",
  "image_url": "https://www.example.com/image.jpg",
  "android": {
    "priority": "",
    "ttl": "",
    "collapse_key": "",
    "restricted_package_name": "",
    "icon": "",
    "color": "",
    "sound": "",
    "tag": "",
    "click_action": "",
    "body_loc_key": "",
    "body_loc_args": [
      ""
    ],
    "title_loc_key": "",
    "title_loc_args": [
      ""
    ],
    "channel_id": ""
  },
  "ios": {
    "badge": "",
    "category": "",
    "thread_id": "",
    "sub_title": "",
    "loc_key": "",
    "loc_args": [
      ""
    ],
    "title_loc_key": "",
    "title_loc_args": [
      ""
    ],
    "subtitle_loc_key": "",
    "subtitle_loc_args": [
      ""
    ],
    "action_loc_key": "",
    "launch_image": ""
  },
  "web": {
    "icon": "",
    "badge": "",
    "direction": "",
    "data": {},
    "lang": "",
    "renotify": "",
    "require_interaction": "",
    "silent": "",
    "tag": "",
    "timestamp": "",
    "vibrate": [
      1,
      2,
      3
    ],
    "link": ""
  },
  "meta": {
    // These are custom fields that can be added from within Fast Track CRM
    "custom_field_one": "value",
    "custom_field_two": "value"
  }
}
Key
Type
Desctiption

activity.id

integer

A unique identifier of the Native Push Notification

activity.brand_id

integer

The unique identifier of the brand on Fast Track

activity.user_id

string

The unique identifier of the player

activity.activity_id

integer

The unique identifier of the activity setup in Fast Track

activity.action_group_id

integer

The unique identifier of the action group which the Native Push Notification originates from Fast Track

activity.trigger_hash

string

Trigger hash

activity.action_id

integer

The unique identifier of the individual action from Fast Track

Expected Responses

The Operator API should return the responses for each individual Native Push Notification message respectively to avoid unrelated storage of Native Push Notification data.

Successful HTTP 200-299 JSON Response

The push_id will be a unique identifier generated by the Operator API which allows Fast Track to identify that particular Native Push Notification message in order to update its delivery status after it is sent.

{
  "push_id": "123123"
}

ERROR Non-200 response JSON Response

Erroneous responses are typically associated with HTTP status codes 400s or 500s. The response should contain an "error" field with a description to show what went wrong and assist with troubleshooting.

{
    "error": "a description of the error"
}

The responses from the Operator API will be handled differently depending on the class of the HTTP status code. The table below gives a summary of how the HTTP status are handled separately.

HTTP Status Codes
Description

200-299

Successfully Delivered. Fast Track will acknowledge the message and start processing the next message in the queue.

400-499

Non Successful. When receiving this error, Fast Track will skip the Native Push Notification message. Additionally, it will send its data to Failed Actions, if the service is enabled.

500 or any other status code which is not listed above

Non Successful. The service fatals and Fast Track will keep retrying until a 200 response is received.

Batch Native Push Notifications

Batch Native Push Notification helps to process a collection of Native Push Notification in one request to the API. The number of messages within the batch request is limited by a set integer amount in the configuration and sent within a configured time span, even when the batch is not yet full.

Endpoint Implementation

Implement the endpoint in the format below to support batch-send Native Push Notification through API.

⬆️ POST <operator-api-endpoint-url>/channels/push/batch

Request Header

The header of the sent request contains an "X-Api-Key" which is a token required to authenticate the API calls at the endpoint. This token needs to be passed on to Fast Track in order to make these requests.

Request Body Schema

Here is an example of expected format when batching the requests. It is similar to the Single Native Push Notification request but the requests are stored in an array, one after the other.

[
  {
    "activity": {
      "id": "BE0F442F-6A2F-471E-8421-C103232AC4F8",
      "brand_id": 1,
      "user_id": "111",
      "internal_user_id": 111,
      "activity_id": 1,
      "origin": "origin-a",
      "action_group_id": 2,
      "trigger_hash": "8eb3474509644cfdf07d9a61e90ddc7e",
      "action_id": 3
    },
    "body": "",
    "title": "Test Title",
    "image_url": "https://www.example.com/image.jpg",
    "android": {
      // ... Android specific fields (as shown in above model)
    },
    "ios": {
      // ... iOS specific fields (as shown in above model)
    },
    "web": {
      // ... Web specific fields (as shown in above model)
    },
    "meta": {
      // These are custom fields that can be added from within Fast Track CRM
      "custom_field_one": "value",
      "custom_field_two": "value"
    }
  },
  {
    "activity": {
      "id": "BE0F442F-6A2F-471E-8421-C103232AC4F8",
      "brand_id": 1,
      "user_id": "111",
      "internal_user_id": 111,
      "activity_id": 1,
      "origin": "origin-a",
      "action_group_id": 2,
      "trigger_hash": "8eb3474509644cfdf07d9a61e90ddc7e",
      "action_id": 3
    },
    "body": "",
    "title": "Test Title",
    "image_url": "https://www.example.com/image.jpg",
    "android": {
      // ... Android specific fields (as shown in above model)
    },
    "ios": {
      // ... iOS specific fields (as shown in above model)
    },
    "web": {
      // ... Web specific fields (as shown in above model)
    },
    "meta": {
      // These are custom fields that can be added from within Fast Track CRM
      "custom_field_one": "value",
      "custom_field_two": "value"
    }
  }
]
Key
Type
Description

activity.id

integer

A unique identifier of the Native Push Notification

activity.brand_id

integer

The unique identifier of the brand on Fast Track

activity.user_id

string

The unique identifier of the player

activity.activity_id

integer

The unique identifier of the activity setup in Fast Track

activity.action_group_id

integer

The unique identifier of the action group which the Native Push Notification originates from Fast Track

activity.trigger_hash

string

Trigger hash

activity.action_id

integer

The unique identifier of the individual action from Fast Track

Expected Responses

The below responses should be returned by the Operator API.

Successful HTTP 200 JSON Response

The "activity.id" initially sent in the request will be returned back in the response as "id". This is required to help Fast Track identify the individual Native Push Notification message in the initial batch request. The push_id will be a unique identifier generated by the Operator API, which Fast Track will use to identify the related Native Push Notification message when updating its status. If any of the listed categories ("successful", "failed" or "fatal") do not have an associated Native Push Notification, they should be returned as an empty array.

{
    "successful": [
        {
            "id": "{activity.id(from request)}",
            "push_id": "123123"
        },
        {
            "id": "{activity.id(from request)}",
            "push_id": "123123"
        }
    ],
    "failed": [
        {
            "id": "{activity.id(from request)}",
            "push_id": "unique-id-of-the-push (if applicable)",
            "error": "why it failed"
        }
    ],
    "fatal": [
        {
            "id": "{activity.id(from request)}",
            "push_id": "unique-id-of-the-push (if applicable)",
            "error": "why it failed"
        }
    ]
}

The logic flow on how the response will be handled is very similar to how the HTTP status codes are handled in the Single Native Push Notification. The sole difference is that the response with a status code 200 will be handled instead, according to the message's category in the response.

Response Category
Description

successful

Successfully Delivered. Fast Track will acknowledge the message and start processing the next batch in the queue.

failed

Non Successful. When receiving this error, Fast Track will skip the Native Push Notification message. Additionally, it will send its data to Failed Actions, if the service is enabled.

fatal

Messages will be retried

Any other messages that are not listed within the response will be retried.

ERROR (non 500 response) JSON Response

Fast Track will only support HTTP Status Code 200 in batching. The whole batch request will be retried if any other status code is received with the following response.

{
    "error": "the error"
}

Last updated

Was this helpful?