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.

19201920

Scope of Notification Service

  • Allow mobile applications to register for receiving notifications.
  • Allow mobile applications to configure notification message format and delivery options while registering.
  • 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 user to push data/event to 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 in Notification Service

Before registering 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 create 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 to vault created in the above step.

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

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

use /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: [];
        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

{
    "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/"
    }
}
{
    "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.

{
    "name": "test_lsql_filter",
    "source": ["test-lsql-topic"],
    "draft": true,
    "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

{
  "topic": "test_topic_1",
  "source": {
    "name": "order-service",
    "type": "notification",
    "user": {}
  },
  "key": "partition_key_1",
  "event": {
    "key1": "value1"
  }
}

Did this page help you?