Notification

Introduction to Notification Service

The Notification Service is responsible for managing a common message-streaming platform that can be used to send and consume messages across platform applications and mobile apps.

1920

Scope of Notification Service

  • Allow mobile applications to register and configure notification message format and delivery options for receiving notifications.
  • Send notifications to registered mobile applications in specified formats.
  • Allow tenants or apps to define filters on topics.
  • Filter data from Kafka topics and push to configured sink topics.
  • Allows the user to push data/event to a specified topic.

Mobile Notification

To use the Notification Service to push Notifications to Mobile Apps, you must first register it.

Steps to send Mobile Notifications

Register an App Notification Configuration in Notification Service

Before configuring an App in the notification service, first, add FCM App credentials including the project ID, the client email, and the private key in the Secure Data Storage (SDS) service vault. Then use this SDS ID when you configure the App.

To store notification data in SDS Vault:

  • Create an App in the SDS service.
  • Create a vault in the SDS service and provide decrypted read permission(010) to the App notification.
  • Store data in the vault created in the above step.

Register the Notification Configuration which acts as a default configuration if there is no other configuration defined in the Kafka event.

Send the notification events to topic: <tenant>_mobile_notification_P0_<env>.

  • for token based messaging provide device registration tokens in event.tokens field
  • for topic based messaging provide FCM topic name in event.notificationTopic field

Use the /event API for pushing events to the topic. Reference request payload for /event API call:

{
        topic: tenant1_mobile_notification_P0_dev,
    source: {
            name: string;
            type: string;
            user: { [key: string]: any };
    };
    event: {
        appId: string;
        tokens: []; // for token based messaging. notification event will be pushed to devices based on provided device tokens
        notificationTopic: string; // for topic based messaging. notification event will be pushed to this FCM topic
        body: {
            title?: string;
            body?: string;
            data?: { [key: string]: string };
        };
        config: {
            collapseKey?: string;
            priority?: "high" | "normal";
            restrictedPackageName?: string;
            ttl?: number;
            bodyLocArgs?: Array<string>;
            bodyLocKey?: string;
            channelId?: string;
            clickAction?: string;
            color?: string;
            defaultLightSettings?: boolean;
            defaultSound?: boolean;
            defaultVibrateTimings?: boolean;
            eventTimestamp?: Date;
            icon?: string;
            imageUrl?: string;
            localOnly?: boolean;
            notificationCount?: number;
            notificationPriority?: "min" | "low" | "default" | "high" | "max";
            sound?: string;
            sticky?: boolean;
            tag?: string;
            ticker?: string;
            titleLocArgs?: Array<string>;
            titleLocKey?: string;
            vibrateTimingsMillis?: number[];
            visibility?: "private" | "public" | "secret";
        };
        headers: {};
        auth: {};
    };
}

After the events are pushed to the Notification topics, the Notification service parses the event and sends the notification to the specified devices for which device tokens are specified in the payload

MemberDescriptionValidationData type
androidConfigConfiguration for Android notification message.
collapseKeyCollapse key for the message. Collapse key serves as an identifier for a group of messages that can be collapsed, so that only the last message
gets sent when delivery can be resumed.
string
priorityFCM concept that controls when the message is delivered.Enum: [high, normal]string
ttlTime-to-live duration of the message in milliseconds.number
restrictedPackageNamePackage name of the application where the registration tokens must match in order to receive the message.string
iconIcon resource for the Android notification.string
colorNotification icon color in #rrggbb format.pattern: ^#([a-fA-F0-9]{6})$string
soundFile name of the sound to be played when the device receives the notification.string
tagNotification tag. This is an identifier used to replace existing notifications in the notification drawer.
If not specified, each request creates a new notification.
string
clickActionAction associated with a user clicking on the notification.
If specified, an activity with a matching Intent Filter is launched when a user clicks on the notification.
string
channelIdThe Android notification channel ID (new in Android O). The app must create a channel with this channel ID before any notification with this channel ID
can be received. If you don't send this channel ID in the request, or if the channel ID provided has not yet been created by the app, FCM uses the channel ID
specified in the app manifest.
string
tickerSets the "ticker" text, which is sent to accessibility services. Prior to API level 21 (Lollipop), sets the text that is displayed in the status bar when
the notification first arrives.
string
stickyWhen set to false or unset, the notification is automatically dismissed when the user clicks it in the panel.
When set to true, the notification persists even when the user clicks it.
boolean
localOnlySets whether or not this notification is relevant only to the current device.
Some notifications can be bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend this
notification not be bridged.
boolean
notificationPrioritySets the relative priority for this notification. This priority is processed by the client after the message has been delivered.Enum: [ min, low, default, high, max ]string
defaultSoundIf set to true, use the Android framework's default sound for the notification.boolean
defaultVibrateTimingsIf set to true, use the Android framework's default vibrate pattern for the notification.boolean
defaultLightSettingsIf set to true, use the Android framework's default LED light settings for the notification.boolean
visibilitySets the visibility of the notification.Enum: [ private, public, secret ]string
imageUrlURL of an image to be displayed in the notification.string
{
    "name": "string",
    "appPlatform": "android",
    "appId": "string",
    "enableNotification": true,
    "accountConfig": {
      "android": {
        "projectId": "string",
        "clientEmail": "string",
        "privateKey": "string"
      }
    },
    "androidConfig": {
        "collapseKey": "collapseKey",
        "priority": "high",
        "ttl": 1000,
        "restrictedPackageName": "restrictedPackageName",
        "icon": "myicon"
        "color": "#aabbcc",
        "sound": "default"
        "tag": "tag1",
        "clickAction": "clickAction",
        "channelId": "channel_id_1",
        "ticker": ""tickerText,
        "sticky": false,
        "localOnly": true,
        "notificationPriority": "high",
        "defaultSound": true,
        "defaultVibrateTimings": true,
        "defaultLightSettings": true,
        "visibility": "public",
        "imageUrl": "http://example.fxtrt.io/"
    }
}
{
    "name": "string",
    "enableNotification": true,
    "accountConfig": {
      "android": {
        "projectId": "string",
        "clientEmail": "string",
        "privateKey": "string"
      }
    },
    "androidConfig": {
        "collapseKey": "collapseKey",
        "priority": "high",
        "ttl": 1000,
        "restrictedPackageName": "restrictedPackageName",
        "icon": "myicon"
        "color": "#aabbcc",
        "sound": "default"
        "tag": "tag1",
        "clickAction": "clickAction",
        "channelId": "channel_id_1",
        "ticker": ""tickerText,
        "sticky": false,
        "localOnly": true,
        "notificationPriority": "high",
        "defaultSound": true,
        "defaultVibrateTimings": true,
        "defaultLightSettings": true,
        "visibility": "public",
        "imageUrl": "http://example.fxtrt.io/"
    }
}

Message filtering

The Notification service allows you to create filters on topics and push data to new topics based on logic that you specify. After the filter is registered and activated in the Notification service, filtered data starts to flow from source topic to destination topics.

MemberDescriptionValidationData type
nameFilter name.string
sourceSource topic on which filter is required.minItems: 1 maxItems: 1string
sinkOutput topic for pushing filtered data.string
dataList of fields to be included in output topic, add * for pushing all fields as it is.string
filters>AND/OR>typeType of filterEnum: [ >, <, >=, <=, =, !=, in ]string
filters>AND/OR>keyField on which filter needs to be applied.string
filters>AND/OR>value Filter value.default: falseboolean
{
    "name": "test_lsql_filter",
    "source": ["test-lsql-topic"],
    "sink": ["test-lsql-topic-sink2"],
    "data": ["*"],
    "filters": {
        "AND": [
            {
                "type": ">=",
                "key": "key2",
                "value": "50"
            }
        ]
    }
}
{
    "source": ["test-lsql-topic"],
    "sink": ["test-lsql-topic-sink2"],
    "data": ["*"],
    "filters": {
        "AND": [
            {
                "type": ">=",
                "key": "key2",
                "value": "50"
            }
        ]
    },
    "draft": true,
    "enableFilter": false
}

//Can be updated only when filter is in draft mode (i.e., draft = true)

Push Event to Topic

The Notification Service allows you to push events to specified topics

MemberDescriptionValidationData type
topicName of the topic to which event will be pushed.pattern: ^[a-zA-Z0-9][a-zA-Z0-9_]{1,63}$string
source>nameName of the service/any to identify the source of event.pattern: ^[a-zA-Z0-9][a-zA-Z0-9:_-]{1,31}$string
source>typeType of event.pattern: ^[a-zA-Z0-9][a-zA-Z0-9:_-]{1,31}$string
source>userUser information.
keyKey for this event, based on which kafka partition will be identified.maxLength: 512string
eventActual event payload to be pushed in kafka topic.
{
  "topic": "test_topic_1",
  "source": {
    "name": "order-service",
    "type": "notification",
    "user": {}
  },
  "key": "partition_key_1",
  "event": {
    "key1": "value1"
  }
}