Easy Push: Push message evertwhere easily
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2024 11:41 PM
Hi all
The background of this article is that my project needs to push some message to the self-developed OA system within the enterprise, so I created a POC application EASY PUSH to achieve that purpose. The overall architecture is as follows:
The advantages are:
- Push messages are as easy to configure as emails,
- Push messages will be logged,
- Each push can have a unique watermark,
- There are push switches and forwarding settings in the global settings.
The premise for the application to push messages normally is:
The user registers the push device token of the corresponding app.
My Example:
As the internal OA system use the email address prefix as the recipient's unique identifier,i add business rule for sys_user to register device token when the email field changes;
(function executeRule(current, previous) {
var pushAppName = 'my_rest_push';
new EasyPushUtils(pushAppName)
.registryDeviceUser(
current.sys_id + '',
current.email + ''
);
})(current, previous);
The basic principle is:
- Step 1. Push system call the internal scripted REST API through REST message with the generate push content when push notification be triggered.
- Step 2: After receiving the payload, the scripted REST API will call the pushService method to complete the push.
- Step 3: The pushService method call others function like integration hub, sub flow, sub action or other external REST API etc, event gs.info payload as logs.
I designed transform functions before the push content is generated and before the push service is called.
var EasyPushUtils = Class.create();
EasyPushUtils.prototype = Object.extendsObject(x_838241_easy_push.EasyPushSNC, {
transformFunc_parsePushPayload: function(rawContent) {
// function impletements
this.log.info('>>> run transformFunc_parsePushPayload')
return rawContent;
},
transformFunc_pushContentBuilder: function(json, current, message, attributes) {
// function impletements
this.log.info('>>> run transformFunc_pushContentBuilder')
return json;
},
transformFunc_appendWaterMark: function(rpushReqID, requestID) {
// function impletements
this.log.info('>>> run transformFunc_appendWaterMark')
return pushReqID + ' -- ' + requestID;
},
type: 'EasyPushUtils'
});
Problems I encountered:
- I imitated the unboxing example ServiceNowMobileApp Push to create the following REST message:
- endpoint: https://${pushHost}/API/now/v1/push/${applicationName}/enqueue
- I expected ${pushHost} should be the instance name, but the actual value is not; so i have to manually hard code for the endpoint for other dev uat sit instances;
- The internal call of servicenow seems to use only the post resource endpoint, and does not use the configured authentication, which causes me to manually handle authentication and data verification in the called Scripted REST API;
- When Pushing notification, I cannot efficiently get the push message id. It happens that I have many similar push messages, which makes it difficult for me to modify it by reversing the result to locate the template;
- Feedback: how to mark push as failed, what's the structure of REST message response body {feedback:[]}?
Result:
I built a real APP extend this APP for production instance, there are some screenshots
- push message:
- push notification log:
I will to publish this application after completing If you are interested in it.
The above is my sharing, thank you.
0 REPLIES 0