Message Format

Web Socket Messages

Web Socket messages are formatted as JSON with the following schema:

  • campaign_name: The name of the campaign that was responsible for this generated message
  • data: (Optional) Data defined from the web console campaign creation
  • namespace: The namespace from where the campaign is defined
  • event_name: The name of the event that triggered the message send
  • topic: The topic attributes. If a user is subscribed to multiple topics, this information can be used to determine which topic the message came from.
  • message_id: The ID of the message that was sent.
  • ciid_hash: The generated CIID hash that is generated from the topic attributes. This is effectively a unique identifier for the target topic.
  • forwarded_event: (Optional) if the Send Triggering Event checkbox has been selected in the web console for this specific campaign then the all of the event details in the event that triggered the message send will be forwarded.
    • namespace: The namespace of the triggering event. Will always be the same as above.
    • event_name: The event name tied to the triggering event. Will always be the same as above.
    • attributes: The attributes that were sent in the triggering event
    • timestamp: When this event was processed. ISO 8601 format.
  • campaign_id: The ID of the campaign that was responsible for this generated message.
  • url: (Optional) User defined URL. This can be defined at campaign creation.
  • notification_msg: (Optional) User defined message. This can be defined at campaign creation. 

Example Message

{
    "campaign_name": "Campaign",
    "data": "{\"boolean\":true}",
    "namespace": "Namespace",
    "event_name": "Event",
    "topic": {"uuid": "86f178c5-66d7-4da6-b8bb-4489f34dcd0a"},
    "message_id": "70de4608-2297-11e6-84f8-59bc5a678bce",
    "ciid_hash": "RLpVTheXezFBPVMeCqTgLoeno4EV0747M8lfhfrCpPc=",
    "forwarded_event": {
        "namespace": "Namespace",
        "event_name": "Event",
        "attributes": {
            "IntegerAttr": 52,
            "BooleanAttr": true,
            "uuid": "86f178c5-66d7-4da6-b8bb-4489f34dcd0a"
        },
        "timestamp": "2016-05-25T16:38+0000"
    },
    "campaign_id": 279,
	"url": "https://cogswell.io",
    "notification_msg": "You have been notified"
}

 

Notification Message format

We use the approach of separating the message payload from the actual push notification message - to allow us to get around size restrictions that Apple or Google have enforced in Push Notification Messages. For both Android and iOS the message ID is forwarded in the data. This message ID must be used to fetch the message payload which is identical in its format to the Web Socket Messages. 

iOS

 

{
  "aps": {
      content-available : 1,
      alert : "Notification Message",
      sound : "sound.wav",
      badge : 1,
      category : "string"
  },
  "aviata_gambit_message_id" : "string"
}

aps (required) - this field contains the notification content

  • aps.content-available: Cogs currently always sets this to one since we generate a separate message which must be fetched by the Client app from Cogs. Therefore there is always content available. GCM documentation states that when this property is set to 1, then application:didReceiveRemoteNotification:fetchCompletionHandler: is called. 
  • aps.alert: If this property is included, the system displays a standard alert. You may specify a string as the value of alert. If you specify a string, it becomes the message text of an alert with two buttons: Close and View. If the user taps View, the app is launched.
  • aps.sound: The name of a sound file in the app bundle or in the Library/Sounds folder of the app’s data container. The sound in this file is played as an alert. If the sound file doesn’t exist or default is specified as the value, the default alert sound is played. The audio must be in one of the audio data formats that are compatible with system sounds; see Preparing Custom Alert Sounds for details.
  • aps.badge: The number to display as the badge of the app icon. If this property is absent, the badge is not changed. To remove the badge, set the value of this property to 0.
  • aps.category: Provide this key with a string value that represents the identifier property of the UIMutableUserNotificationCategory object you created to define custom actions. To learn more about using custom actions, see Using Notification Actions in iOS.

aviata_gambit_message_id (required) - this is the UUID identifying the message to be fetched from Gambit via the GET /message/:message_id endpoint.

Android

Please refer to: https://developers.google.com/cloud-messaging/http-server-ref for standard attributes for GCM.

{
  "to": "string",
  "notification": {
    "title": "string",
    "body": "string",
    "icon": "string",
    "sound": "string",
    "tag": "string",
    "color": "string",
    "click_action": "string"
  },
  "data": {
    "aviata_gambit_message_id": "string"
  }
}

to (required) - this field identifies the device to which the notification should be sent. The value in this field is the ID which uniquely identifies a GCM client (Android device in the case of Gambit). This is the GCM registration token or notification key supplied by the device when it performs a push notification registration against Gambit via the POST /register_push endpoint.

notification (required) - this field contains the properties used to construct a notification

  • notification.title (required) - The notification title to display.
  • notification.body (optional) - The notification body text to display. Currently cannot be modified through web console.
  • notification.icon (required) - The icon to use in the notification.
  • notification.sound (optional) - The sound to play when the notification is received by the device. Sound file must reside in the /res/raw directory on Android devices.
  • notification.tag (optional) - Notifications with the same tag field supplied will be grouped together in Android's notification center. By default, all notifications result in a new entry.
  • notification.color (optional) - The color of the icon, expressed in #rrggbb format. Currently cannot be modified through the web console.
  • notification.click_action (optional) - The action to perform when a user clicks on the notification. Please read up on intent filters for Activities on Android in the documentation.

data (required) - this field contains custom data.

  • data.aviata_gambit_message_id (required) - this is the UUID identifying the message to be fetched from Gambit via the GET /message/:message_id endpoint.

priority (optional) - Valid values are "high" and  "normal" (the default). When set to high, the message is sent immediately, can wake a sleeping device, and can even open a connection if needed.

delay_while_idle (optional) - When present and set to true, the message delivery will be delayed until the device is actively in use.

time_to_live (optional) - This specifies how long (in seconds) a message should be stored by GCM while the device is offline. Max of 4 weeks; default of 4 weeks.

dry_run (optional) - When present and set to true, this allows a request to be sent to the services without triggering an actual send to a device.