From 08f1dcc0c965aeb2207ba6a0abc16c27010fd7f8 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 13 Aug 2024 23:27:18 +0530 Subject: [PATCH] WebEngage SDK Security Added, New Plugin for Capacitor Inbox Added --- .../plugins/we-cap-inbox/index.ts | 162 ++++++++++++++++++ .../plugins/webengage/index.ts | 36 +++- 2 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 src/@awesome-cordova-plugins/plugins/we-cap-inbox/index.ts diff --git a/src/@awesome-cordova-plugins/plugins/we-cap-inbox/index.ts b/src/@awesome-cordova-plugins/plugins/we-cap-inbox/index.ts new file mode 100644 index 000000000..71a404e9b --- /dev/null +++ b/src/@awesome-cordova-plugins/plugins/we-cap-inbox/index.ts @@ -0,0 +1,162 @@ +import { Injectable } from '@angular/core'; +import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; + +/** + * @name WE Cap Inbox + * @description + * This plugin provides functionalities to manage notifications in your app. + * + * @usage + * ```typescript + * import { WECapInbox } from '@awesome-cordova-plugins/we-cap-inbox'; + * + * constructor(private wECapInbox: WECapInbox) { } + * + * ... + * + * this.wECapInbox.getNotificationCount() + * .then((count: number) => console.log(count)) + * .catch((error: string) => console.error(error)); + * ``` + */ + + +@Plugin({ + pluginName: 'WECapInbox', + plugin: 'we-notificationinbox-cordova', // npm package name, example: cordova-plugin-camera + pluginRef: 'WENotificationInboxPlugin', // the variable reference to call the plugin, + repo: 'https://github.com/WebEngage/we-ionic-notification-inbox', + platforms: ['Android', 'iOS'] // Array of platforms supported, example: ['Android', 'iOS'] +}) +@Injectable() +export class WECapInbox extends AwesomeCordovaNativePlugin { + + /** + * Resets the notification count. + * @returns {Promise} + */ + @Cordova() + resetNotificationCount(): Promise { + return; + } + + /** + * Retrieves the count of notifications. + * @param {function} successCallback + * @param {function} errorCallback + * @returns {Promise} - The count of notifications. + */ + @Cordova() + getNotificationCount( + successCallback: (count: number) => void, // TODO verify if it is string number + errorCallback: (error: string) => void + ): Promise { + return; + } + + /**- + * Sets WebEngage SDK configuration + * @param {JsonObject | null} offset - Optional offset for notifications + * @param {function} successCallback + * @param {function} errorCallback + * @returns {Promise} + */ + @Cordova() + getNotificationList( + offset: JsonObject | null, + successCallback: (notifications: JsonArray[]) => void, + errorCallback: (error: string) => void + ): Promise { + return; + } + + + /** + * Marks a specific notification as read. + * @param {JsonObject} notificationObject - The notification to mark as read. + * @returns {Promise} + */ + @Cordova() + markRead(notificationObject: JsonObject): Promise { + return; + } + + /** + * Marks a specific notification as unread. + * @param {JsonObject} notificationObject - The notification to mark as unread. + * @returns {Promise} + */ + @Cordova() + markUnread(notificationObject: JsonObject): Promise { + return; + } + + /** + * Tracks a click event on a notification. + * @param {JsonObject} notificationObject - The notification that was clicked. + * @returns {Promise} + */ + @Cordova() + trackClick(notificationObject: JsonObject): Promise { + return; + } + + /** + * Tracks the view event of a notification. + * @param {JsonObject} notificationObject - The notification that was viewed. + * @returns {Promise} + */ + @Cordova() + trackView(notificationObject: JsonObject): Promise { + return; + } + + /** + * Marks a specific notification as deleted. + * @param {JsonObject} notificationObject - The notification to delete. + * @returns {Promise} + */ + @Cordova() + markDelete(notificationObject: JsonObject): Promise { + return; + } + + /** + * Marks all notifications as read. + * @param {JsonArray} notificationList - An array of notification identifiers to mark as read. + * @returns {Promise} + */ + @Cordova() + readAll(notificationList: JsonArray): Promise { + return; + } + + /** + * Marks all notifications as unread. + * @param {JsonArray} notificationList - An array of notification identifiers to mark as unread. + * @returns {Promise} + */ + @Cordova() + unReadAll(notificationList: JsonArray): Promise { + return; + } + + /** + * Deletes all notifications. + * @param {JsonArray} notificationList - An array of notification identifiers to delete. + * @returns {Promise} + */ + @Cordova() + deleteAll(notificationList: JsonArray): Promise { + return; + } + +} + +export type JsonValue = string | number | boolean | null | JsonObject | JsonArray; + +export type JsonObject = { + [key: string]: JsonValue; +}; + +export type JsonArray = JsonValue[]; \ No newline at end of file diff --git a/src/@awesome-cordova-plugins/plugins/webengage/index.ts b/src/@awesome-cordova-plugins/plugins/webengage/index.ts index 5f0139103..b92569f1c 100644 --- a/src/@awesome-cordova-plugins/plugins/webengage/index.ts +++ b/src/@awesome-cordova-plugins/plugins/webengage/index.ts @@ -7,7 +7,7 @@ import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-pl * Awesome Cordova Plugins wrapper that wraps Webengage Cordova plugin for Android and iOS * @usage * ```typescript - * import { Webengage, WebengageUser, WebengagePush, WebengageNotification } from '@awesome-cordova-plugins/webengage/ngx'; + * import { Webengage, WebengageUser, WebengagePush, WebengageNotification, WebengageJwtManager } from '@awesome-cordova-plugins/webengage/ngx'; * * * constructor(private webengage: Webengage, private webengageUser: WebengageUser, private webengagePush: WebengagePush, private webengageNotification: WebengageNotification ) { } @@ -96,7 +96,17 @@ export class WebengageUser extends AwesomeCordovaNativePlugin { * @returns {Promise} */ @Cordova() - login(userId: string): Promise { + login(userId: string, jwtToken?: string): Promise { + return; + } + + /** + * Logs user in + * @param {string} userId + * @returns {Promise} + */ + @Cordova() + setSecureToken(userId: string, jwtToken: string): Promise { return; } @@ -142,6 +152,28 @@ export class WebengageUser extends AwesomeCordovaNativePlugin { } } +/** + * @hidden + */ +@Plugin({ + pluginName: 'Webengage', + plugin: 'cordova-plugin-webengage', + pluginRef: 'webengage.jwtManager', +}) + +@Injectable() +export class WebengageJwtManager extends AwesomeCordovaNativePlugin { + /** + * Callback function is invoked when a Jwt token is clicked + * @param {any} callback + * @returns {Promise} + */ + @Cordova() + tokenInvalidatedCallback(callback: any): Promise { + return; + } +} + /** * @hidden */