Skip to content

Commit c58ee9c

Browse files
authored
feat: Support for Web push destinations (Chrome and Firefox) BREAKING CHANGE: SendNotifications accepts json string for the CeIbmenpushto, CeIbmenfcmbody, CeIbmenapnsbody, CeIbmenapnsheaders fields.
1 parent 40d8cd7 commit c58ee9c

File tree

8 files changed

+478
-21468
lines changed

8 files changed

+478
-21468
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ node_js:
88
- 12
99
- 14
1010

11+
before_install:
12+
- npm i -g npm@8
13+
- npm --version
14+
1115
script:
1216
- npm run build
1317
- npm run test-unit-travis || travis_terminate 1

README.md

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -682,26 +682,22 @@ eventNotificationsService
682682

683683
const params = {
684684
instanceId: instanceId,
685-
subject: notificationSubject,
686-
ibmenseverity: notificationSeverity,
687-
id: notificationID,
688-
source: notificationsSouce,
689-
ibmensourceid: sourceId,
690-
type: typeValue,
691-
time: '<notification-time>',
692-
data: {},
693-
ibmenpushto: notificationDevicesModel,
694-
ibmenfcmbody: notificationFcmBodyModel,
695-
ibmenapnsbody: notificationApnsBodyModel,
696-
ibmenapnsheaders: apnsHeaders,
697-
datacontenttype: 'application/json',
698-
specversion: '1.0',
685+
ceIbmenseverity: notificationSeverity,
686+
ceId: notificationID,
687+
ceSource: notificationsSouce,
688+
ceIbmensourceid: sourceId,
689+
ceType: typeValue,
690+
ceTime: '<notification-time>',
691+
ceIbmenpushto: JSON.stringify(notificationDevicesModel),
692+
ceIbmenfcmbody: JSON.stringify(notificationFcmBodyModel),
693+
ceIbmenapnsbody: JSON.stringify(notificationApnsBodyModel),
694+
ceIbmenapnsheaders: JSON.stringify(apnsHeaders),
695+
ceSpecversion: '1.0',
699696
};
700697

701698
let res;
702699
try {
703-
const sendNotifications = SendNotifications.newInstance(initParameters) // same `initParameters` used in the SDK initialization step.
704-
res = await sendNotifications.sendNotifications(params);
700+
res = await eventNotificationsService.sendNotifications(params);
705701
console.log(JSON.stringify(res.result, null, 2));
706702
} catch (err) {
707703
console.warn(err);
@@ -711,32 +707,35 @@ eventNotificationsService
711707
<summary>Send Notifications Variables</summary>
712708
<br>
713709

714-
- **FCM Target NotificationFcmDevices** - Set up the the push notifications tragets.
710+
- **ceIbmenpushto** - Set up the the push notifications tragets.
715711
- *user_ids* (Array of **String**) - Send notification to the specified userIds.
716-
- *fcm_devices* (Array of **String**) - Send notification to the list of specified fcm devices.
717-
- *apns_devices* (Array of **String**) - Send notification to the list of specified iOS devices.
718-
- *tags* (Array of **String**) - Send notification to the devices that have subscribed to any of
719-
these tags.
720-
- *platforms* (Array of **String**) - Send notification to the devices of the specified platforms. Pass 'G' for google (Android) devices. Pass 'A' for iOS devices.
721-
- **FCM messageFcmBody** - Set payload specific to Android platform [Refer this FCM official [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support)]. We support `notification` and `data` keys in FCM.
722-
- **iOS messageApnsBody** - Set payload specific to iOS platform [Refer this APNs official doc [link](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html)].
723-
- **APNs messageApnsHeaders** - Set headers required for the APNs message [Refer this APNs official [link](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns)(Table 1 Header fields for a POST request)].
724-
- **Event Notificaitons SendNotificationsOptions** - Event Notificaitons Send notificaitons method.
725-
- *instanceId* (**String**) - Event Notificaitons instance AppGUID.
726-
- *subject* (**String**) - Subject for the notifications.
727-
- *ibmenseverity* (**String**) - Severity for the notifications.
728-
- *id* (**ID**) - ID for the notifications.
729-
- *source* (**String**) - Source of the notifications.
730-
- *ibmensourceid* (**String**) - Event Notificaitons instance Source ID.
731-
- *type* (**String**) - Type for the notifications.
732-
- *time* (**String**) - Time of the notifications.
733-
- *data* (**JSON**) - Data for the notifications. Supported only for `Webhook` destination.
734-
- *ibmenpushto* (**NotificationFcmDevices**) - Targets for the FCM notifications.
735-
- *ibmenfcmbody* (**notificationFcmBodyModel**) - Message body for the FCM notifications.
736-
- *ibmenapnsbody* (**notificationApnsBodyModel**) - Message body for the APNs notifications.
737-
- *ibmenapnsheaders* (**JSON**) - Headers for the APNs notifications.
738-
- *datacontenttype* (**String**) - Data content type of the notifications.
739-
- *specversion* (**String**) - Spec version of the Event Notificaitons. Default value is `1.0`.
712+
- *fcm_devices* (Array of **String**) - Send notification to the list of specified Android devices.
713+
- *fcm_devices* (Array of **String**) - Send notification to the list of specified iOS devices.
714+
- *_devices* (Array of **String**) - Send notification to the list of specified Chrome devices.
715+
- *firefox_devices* (Array of **String**) - Send notification to the list of specified Firefox devices.
716+
- *tags* (Array of **String**) - Send notification to the devices that have subscribed to any of these tags.
717+
- *platforms* (Array of **String**) - Send notification to the devices of the specified platforms.
718+
- Pass 'G' for google (Android) devices.
719+
- Pass 'A' for iOS devices.
720+
- Pass 'WEB_FIREFOX' for Firefox browser.
721+
- Pass 'WEB_CHROME' for Chrome browser.
722+
- **Event Notifications SendNotificationsOptions** - Event Notifications Send Notifications method.
723+
- *InstanceID* (**String**) - Event Notifications instance AppGUID.
724+
- *CeIbmenseverity* (**String**) - Severity for the notifications.
725+
- *CeID* (**String**) - ID for the notifications.
726+
- *CeSource* (**String**) - Source of the notifications.
727+
- *CeIbmensourceid* (**String**) - Event Notifications instance Source ID.
728+
- *CeType* (**String**) - Type for the notifications.
729+
- *CeTime* (**String**) - Time of the notifications.
730+
- *CeIbmenpushto* (**string**) - Targets for the FCM notifications.
731+
- *CeIbmenfcmbody* (**string**) - Set payload string specific to Android platform [Refer this FCM official [link](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support)].
732+
- *CeIbmenapnsbody* (**string**) - Set payload string specific to iOS platform [Refer this APNs official doc [link](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html)].
733+
- *CeIbmenapnsheaders* (**string**) - Set headers required for the APNs message [Refer this APNs official [link](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns)(Table 1 Header fields for a POST request)]
734+
- *CeIbmenchromebody* (**string**) - Message body for the Chrome notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
735+
- *CeIbmenfirefoxbody* (**string**) - Message body for the Firefox notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
736+
- *CeIbmenchromeheaders* (**string**) - Headers for the Chrome notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
737+
- *CeIbmenfirefoxheaders* (**string**) - Headers for the Firefox notifications. Refer [this official documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/Notification) for more.
738+
- *CeSpecversion* (**String**) - Spec version of the Event Notifications. Default value is `1.0`.
740739

741740
</details>
742741

0 commit comments

Comments
 (0)