FCM Integration API

Tài liệu này hướng dẫn tích hợp FCM (Firebase Cloud Messaging) vào PangoCDP để gửi notification từ Pango đến Mobile App. Bạn có thể tạo Kịch bản tự động từ DMA để gửi theo sự kiện hoặc segment.

Token Subscription API

API này cho phép client push Firebase App Token vào PangoCDP.

Information

Method

POST

Header

  • content-type: application/json

  • reqId=fcm************* (Pango provides)

  • cdpKey= (Pangpo provides)

Path Parameter

{cdpAppId}: CDP Application ID (Pango provides)

Payload

[
 {
 "clientAppId": "loyalty-app-android",
"token": "firebase-app-token"
 }
]

Payload

Field
Required
Description
Example

clientAppId

Yes

Client App Id / Name.

Loyalty Android

Loyalty for MS

token

Yes

Firebase App Token

loginUId

Yes

Login User ID

loginUIdField

Yes

Field type of Login User ID. Valid values:

  • CustomerId

  • Email

  • Phone

  • UserId

  • Cid

Email

userId

If loginUIdField=UserId, then require userId.

dee88

customerId

If loginUIdField=CustomerId, then require customerId.

C09999991

phone

If loginUIdField=Phone, then require PHONE.

0909999999

email

If loginUIdField=Email, then require EMAIL.

cid

If loginUIdField=UserId, then require CID.

2125546.967878

uniqueId

Related to Device. For example, In iOs: identifier for vendor

deviceInfo

A List of values with prefix

[ “os: iOs”, “osv: 12.0”]

extParams

A List of values with prefix if more information needs to be tracked

[ “value1”, “...”]

Sample Request

loginUIdField=Phone

{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token",
  "loginUId": "0909999999",
  "loginUIdField": "Phone",
  "userId": null,
  "customerId": null,
  "phone": "0909999999",
  "email": null,
  "cid": null,
  "uniqueId": null
  "deviceInfo": [
    "manf: VALUE",
    "brand: VALUE",
    "model: VALUE",
    "os: VALUE",
    "osv: VALUE"
  ],
  "extParams": [
    "key1: VALUE1"
  ]
}

loginUIdField=CustomerId

{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token",
  "loginUId": "C09999999",
  "loginUIdField": "CustomerId",
  "userId": null,
  "customerId": "C09999999",
  "phone": null,
  "email": null,
  "cid": null,
  "uniqueId": null
  "deviceInfo": [
    "manf: VALUE",
    "brand: VALUE",
    "model: VALUE",
    "os: VALUE",
    "osv: VALUE"
  ],
  "extParams": [
    "key1: VALUE1"
  ]
}

Response

Code
Value

400

{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
  "success": false,
  "message": "Some required fields are missing: clientAppId",
  "errorCode": "MISSING_INFO"
}

401

{
  "success": false,
  "message": "Unauthorized!",
  "errorCode": "REQ_ID_NOT_MATCHED"
}

200

{
  "success": true,
  "took": 98
}

FCM Token Unsubscribed

API này cho phép client delete Firebase App Token trong PangoCDP

Information

Method

POST

Header

  • content-type: application/json

  • reqId=fcm************* (Pango provides)

  • cdpKey= (Pango provides)

Path Parameter

{cdpAppId}: CDP Application ID (Pango provides)

Payload

{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token"
}

Payload

Field
Required
Description
Example

clientAppId

Yes

Client App Id / Name.

Loyalty Android

Loyalty for MS

token

Yes

Firebase App Token

Sample Request

{
  "clientAppId": "loyalty-app-android",
  "token": "firebase-app-token"
}

Response

Code
Value

400

{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
  "success": false,
  "message": "Some required fields are missing: clientAppId",
  "errorCode": "MISSING_INFO"
}

401

{
  "success": false,
  "message": "Unauthorized!",
  "errorCode": "REQ_ID_NOT_MATCHED"
}

200

{
  "success": true,
  "took": 98
}

FCM Message Structure

To push messages to Devices / Topic based on Firebase, PangoCDP provides a tool to build templates, then JSON messages to push to clients.

Structure

{
  "message": {
    "notification": {
      "title": "Notification MMV - Xpander 2022 - New ",
      "body": "Notification Text"
    },
    "data": {
      "cdpAck": "fcm**********",
      "title": "Notification MMV - Xpander 2022 - New",
      "body": "Notification Text",
      "imageUrl": "https://",
      "key01": "/promotion"
    },
    "android": {
      "ttl": "86400s",
      "priority": "normal",
      "notification": {
        "click_action": ""
      }
    },
    "apns": {
      "headers": {
        "ttl": 86400,
        "apns-priority": "10"
      },
      "payload": {
        "aps": {
          "category": ""
        }
      }
    }
  }
}
Sample message
Key
Description

cdpAck

This value is used for acknowledgement.

Clients that received the messages will push back PangoCDP this value to notify that the messages are delivered successfully.

android

apns

Acknowledge Event API

This API allows clients to push “Acknowledge Messages” back to PangoCDP. With each message delivered by Firebase, PangoCDP needs to know its status like: received, clicked.

Information

Method

POST

Header

  • content-type: application/json

  • reqId=fcm************* (Pango provides)

  • cdpKey= (Pango provides)

Path Parameter

{cdpAppId}: CDP Application ID (Pango provides)

Payload

{
  "clientAppId": "loyalty-app-android",
  "eventName": "received",
  "cdpMsgId": "fcmxxxxxxxxxxxxxxx",
  "extParams": [
  ]
}

Payload

Field
Required
Description
Example

clientAppId

Yes

Client App Id / Name.

Loyalty Android

Loyalty for MS

eventName

Yes

Event name from Client sent back:

  • received: The message is received by a device

  • clicked: User clicked on the message on Phones

received

cdpMsgId

Yes

When pangCDP pushes a message to a device, a key: “” will be appended to the data message.

The client sends the value of “” back to PangoCDP along with “eventName” to inform CDP that the message has been delivered successfully.

fcm...

extParams

A List of values with prefix if more information needs to be tracked

[ “value1”, “...”]

Sample Request

{
  "clientAppId": "loyalty-app-android",
  "eventName": "received",
  "cdpMsgId": "fcmxxxxxxxxxxxxxxx",
  "extParams": [
     "key1: VALUE1"
  ]
}

Response

Code
Value

400

{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
  "success": false,
  "message": "Some required fields are missing: clientAppId",
  "errorCode": "MISSING_INFO"
}

401

{
  "success": false,
  "message": "Unauthorized!",
  "errorCode": "REQ_ID_NOT_MATCHED"
}

200

{
  "success": true,
  "took": 98
}

Push Original Message / In-house Message API

This API allows clients to push “Original Messages” or “In-house Messages” to PangoCDP.

Information

Method

POST

Header

  • content-type: application/json

  • reqId=fcm************* (Pango provides)

  • cdpKey= (Pango provides)

Path Parameter

{cdpAppId}: CDP Application ID (Pango provides)

Payload

[{
  "clientAppId": "loyalty-app-android",
  "templateId": "template id",
  "fcmToken": "firebase token",
  "msgId": "message id in your system",
  "fmsgId": "message id from firebase",
  "eventAt": 1665041443000,
  "userId": "user id",
  "customerId": "customer id",
  "phone": "phone number",
  "email": "email",
  "note": "received",
  "tags": ["TAG VALUE"],
  "deviceInfo": [
    "brand: APPLE",
    "model :iPhone",
    "os: IOS",
    "osv: 15.6.1"
  ],
  "extParams": [
  ]
}, 
{},
{}]

Payload

The payload contains a List of Events. Allowed size: [1 - 50]

Field
Required
Description
Example

clientAppId

Yes

Client App Id / Name.

Loyalty Android

Loyalty for MS

templateId

Yes

The template Id in your system

fcmToken

Yes

Firebase token

msgId

Yes

The message is created by your system

Any text

fmsgId

Firebase Message-Id. The id is returned by Firebase after the message sent

eventAt

Yes

Event Time - Timestamp with millisecond

1665041443000

userId

User Id in your system

customerId

Customer Id

phone

Phone number

email

Email Address

note

Some notes

tags

List of Tags

[“Promotion”, “New Year”]

deviceInfo

Device information, following the keys:

  • brand

  • model

  • os

  • osv

"deviceInfo": [
    "brand: APPLE",
    "model :iPhone",
    "os: IOS",
    "osv: 15.6.1"
  ]

extParams

More information if you want to push.

"extParams": [
    "code: 000011",
    "campaign: ABC "
  ]

Sample Request

[{
  "clientAppId": "loyalty-app-android",
  "templateId": "template id",
  "fcmToken": "firebase token",
  "msgId": "message id in your system",
  "fmsgId": "message id from firebase",
  "userId": "user id",
  "customerId": "customer id",
  "phone": "phone number",
  "email": "email",
  "note": "received",
  "tags": ["TAG VALUE"],
  "deviceInfo": [
    "brand: APPLE",
    "model :iPhone",
    "os: IOS",
    "osv: 15.6.1"
  ],
  "extParams": [
     
  ]
}]

Response

Code
Value

400

{
  "success": false,
  "message": "REQ Id is incorrect.",
  "errorCode": "NOT_FOUND"
}

// Missing fields
{
  "success": false,
  "errors": ["clientAppId"],
  "errorCode": "MISSING_INFO"
}

401

{
  "success": false,
  "message": "Unauthorized!",
  "errorCode": "REQ_ID_NOT_MATCHED"
}

200

{
  "success": true,
  "took": 98
}

Last updated

Was this helpful?