From a6fc9360aa9a7fbb3e76fe0716283f3597051aef Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Thu, 2 Mar 2023 15:32:53 +0800 Subject: [PATCH] update docs (14558) Signed-off-by: ester.zhou --- .../apis/js-apis-notificationManager.md | 410 +++++++++++++----- .../apis/js-apis-notificationSubscribe.md | 104 +++-- .../errorcodes/errorcode-notification.md | 219 ++++++++++ 3 files changed, 575 insertions(+), 158 deletions(-) create mode 100644 en/application-dev/reference/errorcodes/errorcode-notification.md diff --git a/en/application-dev/reference/apis/js-apis-notificationManager.md b/en/application-dev/reference/apis/js-apis-notificationManager.md index 2d8f497bed..71987d3594 100644 --- a/en/application-dev/reference/apis/js-apis-notificationManager.md +++ b/en/application-dev/reference/apis/js-apis-notificationManager.md @@ -1,4 +1,4 @@ -# @ohos.notificationManager +# @ohos.notificationManager (NotificationManager) The **notificationManager** module provides notification management capabilities, covering notifications, notification slots, notification enabled status, and notification badge status. @@ -29,6 +29,8 @@ Publishes a notification. This API uses an asynchronous callback to return the r **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------------- | | 1600001 | Internal error. | @@ -50,7 +52,7 @@ function publishCallback(err) { } } // NotificationRequest object -var notificationRequest = { +let notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -60,8 +62,8 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} -Notification.publish(notificationRequest, publishCallback) +}; +Notification.publish(notificationRequest, publishCallback); ``` @@ -82,6 +84,8 @@ Publishes a notification. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------------- | | 1600001 | Internal error. | @@ -95,7 +99,7 @@ Publishes a notification. This API uses a promise to return the result. ```js // NotificationRequest object -var notificationRequest = { +let notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -105,7 +109,7 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; Notification.publish(notificationRequest).then(() => { console.info("publish success"); }); @@ -134,6 +138,8 @@ Publishes a notification to a specified user. This API uses an asynchronous call **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------------- | | 1600001 | Internal error. | @@ -156,9 +162,9 @@ function publishCallback(err) { } } // User ID -var userId = 1 +let userId = 1; // NotificationRequest object -var notificationRequest = { +let notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -168,7 +174,7 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; Notification.publish(notificationRequest, userId, publishCallback); ``` @@ -193,6 +199,8 @@ Publishes a notification to a specified user. This API uses a promise to return **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------------- | | 1600001 | Internal error. | @@ -206,7 +214,7 @@ Publishes a notification to a specified user. This API uses a promise to return **Example** ```js -var notificationRequest = { +let notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -216,9 +224,9 @@ var notificationRequest = { additionalText: "test_additionalText" } } -} +}; -var userId = 1 +let userId = 1; Notification.publish(notificationRequest, userId).then(() => { console.info("publish success"); @@ -244,6 +252,8 @@ Cancels a notification with the specified ID and label. This API uses an asynchr **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -262,7 +272,7 @@ function cancelCallback(err) { console.info("cancel success"); } } -Notification.cancel(0, "label", cancelCallback) +Notification.cancel(0, "label", cancelCallback); ``` @@ -284,6 +294,8 @@ Cancels a notification with the specified ID and optional label. This API uses a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -318,6 +330,8 @@ Cancels a notification with the specified ID. This API uses an asynchronous call **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -336,7 +350,7 @@ function cancelCallback(err) { console.info("cancel success"); } } -Notification.cancel(0, cancelCallback) +Notification.cancel(0, cancelCallback); ``` @@ -351,6 +365,8 @@ Cancels all notifications. This API uses an asynchronous callback to return the **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -374,7 +390,7 @@ function cancelAllCallback(err) { console.info("cancelAll success"); } } -Notification.cancelAll(cancelAllCallback) +Notification.cancelAll(cancelAllCallback); ``` @@ -389,6 +405,8 @@ Cancels all notifications. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -426,6 +444,8 @@ Adds a notification slot. This API uses an asynchronous callback to return the r **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -444,10 +464,10 @@ function addSlotCallBack(err) { } } // NotificationSlot object -var notificationSlot = { +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} -Notification.addSlot(notificationSlot, addSlotCallBack) +}; +Notification.addSlot(notificationSlot, addSlotCallBack); ``` @@ -472,6 +492,8 @@ Adds a notification slot. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -482,9 +504,9 @@ Adds a notification slot. This API uses a promise to return the result. ```js // NotificationSlot object -var notificationSlot = { +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.addSlot(notificationSlot).then(() => { console.info("addSlot success"); }); @@ -509,6 +531,8 @@ Adds a notification slot of a specified type. This API uses an asynchronous call **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -526,7 +550,7 @@ function addSlotCallBack(err) { console.info("addSlot success"); } } -Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) +Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack); ``` @@ -547,6 +571,8 @@ Adds a notification slot of a specified type. This API uses a promise to return **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -584,6 +610,8 @@ Adds an array of notification slots. This API uses an asynchronous callback to r **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -602,14 +630,14 @@ function addSlotsCallBack(err) { } } // NotificationSlot object -var notificationSlot = { +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; // NotificationSlotArray object -var notificationSlotArray = new Array(); +let notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; -Notification.addSlots(notificationSlotArray, addSlotsCallBack) +Notification.addSlots(notificationSlotArray, addSlotsCallBack); ``` @@ -634,6 +662,8 @@ Adds an array of notification slots. This API uses a promise to return the resul **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -644,11 +674,11 @@ Adds an array of notification slots. This API uses a promise to return the resul ```js // NotificationSlot object -var notificationSlot = { +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; // NotificationSlotArray object -var notificationSlotArray = new Array(); +let notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; Notification.addSlots(notificationSlotArray).then(() => { @@ -675,6 +705,8 @@ Obtains a notification slot of a specified type. This API uses an asynchronous c **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -692,8 +724,8 @@ function getSlotCallback(err,data) { console.info("getSlot success"); } } -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; -Notification.getSlot(slotType, getSlotCallback) +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +Notification.getSlot(slotType, getSlotCallback); ``` @@ -720,6 +752,8 @@ Obtains a notification slot of a specified type. This API uses a promise to retu **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -729,7 +763,7 @@ Obtains a notification slot of a specified type. This API uses a promise to retu **Example** ```js -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.getSlot(slotType).then((data) => { console.info("getSlot success, data: " + JSON.stringify(data)); }); @@ -753,6 +787,8 @@ Obtains all notification slots of this application. This API uses an asynchronou **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -770,7 +806,7 @@ function getSlotsCallback(err,data) { console.info("getSlots success"); } } -Notification.getSlots(getSlotsCallback) +Notification.getSlots(getSlotsCallback); ``` @@ -791,6 +827,8 @@ Obtains all notification slots of this application. This API uses a promise to r **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -824,6 +862,8 @@ Removes a notification slot of a specified type. This API uses an asynchronous c **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -841,8 +881,8 @@ function removeSlotCallback(err) { console.info("removeSlot success"); } } -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; -Notification.removeSlot(slotType,removeSlotCallback) +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +Notification.removeSlot(slotType,removeSlotCallback); ``` @@ -863,6 +903,8 @@ Removes a notification slot of a specified type. This API uses a promise to retu **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -872,7 +914,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu **Example** ```js -var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; +let slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType).then(() => { console.info("removeSlot success"); }); @@ -896,6 +938,8 @@ Removes all notification slots. This API uses an asynchronous callback to return **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -912,7 +956,7 @@ function removeAllCallBack(err) { console.info("removeAllSlots success"); } } -Notification.removeAllSlots(removeAllCallBack) +Notification.removeAllSlots(removeAllCallBack); ``` @@ -927,6 +971,8 @@ Removes all notification slots. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -965,6 +1011,8 @@ Sets whether to enable notification for a specified application. This API uses a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -982,9 +1030,9 @@ function setNotificationEnablenCallback(err) { console.info("setNotificationEnablenCallback success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback); ``` @@ -1011,6 +1059,8 @@ Sets whether to enable notification for a specified application. This API uses a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1021,9 +1071,9 @@ Sets whether to enable notification for a specified application. This API uses a **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.setNotificationEnable(bundle, false).then(() => { console.info("setNotificationEnable success"); }); @@ -1052,6 +1102,8 @@ Checks whether notification is enabled for a specified application. This API use **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1069,9 +1121,9 @@ function isNotificationEnabledCallback(err, data) { console.info("isNotificationEnabled success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ``` @@ -1103,6 +1155,8 @@ Checks whether notification is enabled for a specified application. This API use **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1113,9 +1167,9 @@ Checks whether notification is enabled for a specified application. This API use **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isNotificationEnabled(bundle).then((data) => { console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); }); @@ -1143,6 +1197,8 @@ Checks whether notification is enabled for this application. This API uses an as **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1191,6 +1247,8 @@ Checks whether notification is enabled for the current application. This API use **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1230,6 +1288,8 @@ Sets whether to enable the notification badge for a specified application. This **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1247,9 +1307,9 @@ function displayBadgeCallback(err) { console.info("displayBadge success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.displayBadge(bundle, false, displayBadgeCallback); ``` @@ -1276,6 +1336,8 @@ Sets whether to enable the notification badge for a specified application. This **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1286,9 +1348,9 @@ Sets whether to enable the notification badge for a specified application. This **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.displayBadge(bundle, false).then(() => { console.info("displayBadge success"); }); @@ -1317,6 +1379,8 @@ Checks whether the notification badge is enabled for a specified application. Th **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1334,9 +1398,9 @@ function isBadgeDisplayedCallback(err, data) { console.info("isBadgeDisplayed success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ``` @@ -1368,6 +1432,8 @@ Checks whether the notification badge is enabled for a specified application. Th **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1378,9 +1444,9 @@ Checks whether the notification badge is enabled for a specified application. Th **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isBadgeDisplayed(bundle).then((data) => { console.info("isBadgeDisplayed success, data: " + JSON.stringify(data)); }); @@ -1410,6 +1476,8 @@ Sets the notification slot for a specified application. This API uses an asynchr **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1429,12 +1497,12 @@ function setSlotByBundleCallback(err) { console.info("setSlotByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationSlot = { +}; +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ``` @@ -1461,6 +1529,8 @@ Sets the notification slot for a specified application. This API uses a promise **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1471,12 +1541,12 @@ Sets the notification slot for a specified application. This API uses a promise **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationSlot = { +}; +let notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION -} +}; Notification.setSlotByBundle(bundle, notificationSlot).then(() => { console.info("setSlotByBundle success"); }); @@ -1505,6 +1575,8 @@ Obtains the notification slots of a specified application. This API uses an asyn **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1522,9 +1594,9 @@ function getSlotsByBundleCallback(err, data) { console.info("getSlotsByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ``` @@ -1556,6 +1628,8 @@ Obtains the notification slots of a specified application. This API uses a promi **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1566,9 +1640,9 @@ Obtains the notification slots of a specified application. This API uses a promi **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotsByBundle(bundle).then((data) => { console.info("getSlotsByBundle success, data: " + JSON.stringify(data)); }); @@ -1597,6 +1671,8 @@ Obtains the number of notification slots of a specified application. This API us **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1614,9 +1690,9 @@ function getSlotNumByBundleCallback(err, data) { console.info("getSlotNumByBundle success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ``` @@ -1648,6 +1724,8 @@ Obtains the number of notification slots of a specified application. This API us **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -1658,9 +1736,9 @@ Obtains the number of notification slots of a specified application. This API us **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.getSlotNumByBundle(bundle).then((data) => { console.info("getSlotNumByBundle success, data: " + JSON.stringify(data)); }); @@ -1689,6 +1767,8 @@ Obtains all active notifications. This API uses an asynchronous callback to retu **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1731,6 +1811,8 @@ Obtains all active notifications. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1763,6 +1845,8 @@ Obtains the number of active notifications of this application. This API uses an **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1801,6 +1885,8 @@ Obtains the number of active notifications of this application. This API uses a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1833,6 +1919,8 @@ Obtains active notifications of this application. This API uses an asynchronous **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1871,6 +1959,8 @@ Obtains active notifications of this application. This API uses a promise to ret **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1904,6 +1994,8 @@ Cancels notifications under a notification group of this application. This API u **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1944,6 +2036,8 @@ Cancels notifications under a notification group of this application. This API u **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -1953,7 +2047,7 @@ Cancels notifications under a notification group of this application. This API u **Example** ```js -var groupName = "GroupName"; +let groupName = "GroupName"; Notification.cancelGroup(groupName).then(() => { console.info("cancelGroup success"); }); @@ -1983,6 +2077,8 @@ Removes notifications under a notification group of a specified application. Thi **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -2001,8 +2097,8 @@ function removeGroupByBundleCallback(err) { } } -var bundleOption = {bundle: "Bundle"}; -var groupName = "GroupName"; +let bundleOption = {bundle: "Bundle"}; +let groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); ``` @@ -2030,6 +2126,8 @@ Removes notifications under a notification group of a specified application. Thi **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -2040,8 +2138,8 @@ Removes notifications under a notification group of a specified application. Thi **Example** ```js -var bundleOption = {bundle: "Bundle"}; -var groupName = "GroupName"; +let bundleOption = {bundle: "Bundle"}; +let groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName).then(() => { console.info("removeGroupByBundle success"); }); @@ -2070,6 +2168,8 @@ Sets the DND time. This API uses an asynchronous callback to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2087,11 +2187,11 @@ function setDoNotDisturbDateCallback(err) { } } -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ``` @@ -2118,6 +2218,8 @@ Sets the DND time. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2127,11 +2229,11 @@ Sets the DND time. This API uses a promise to return the result. **Example** ```js -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { console.info("setDoNotDisturbDate success"); }); @@ -2160,6 +2262,8 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2178,13 +2282,13 @@ function setDoNotDisturbDateCallback(err) { } } -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; -var userId = 1 +let userId = 1; Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); ``` @@ -2212,6 +2316,8 @@ Sets the DND time for a specified user. This API uses a promise to return the re **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2222,13 +2328,13 @@ Sets the DND time for a specified user. This API uses a promise to return the re **Example** ```js -var doNotDisturbDate = { +let doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) -} +}; -var userId = 1 +let userId = 1; Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { console.info("setDoNotDisturbDate success"); @@ -2256,6 +2362,8 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2298,6 +2406,8 @@ Obtains the DND time. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2334,6 +2444,8 @@ Obtains the DND time of a specified user. This API uses an asynchronous callback **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2352,7 +2464,7 @@ function getDoNotDisturbDateCallback(err,data) { } } -var userId = 1 +let userId = 1; Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); ``` @@ -2385,6 +2497,8 @@ Obtains the DND time of a specified user. This API uses a promise to return the **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2395,7 +2509,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the **Example** ```js -var userId = 1 +let userId = 1; Notification.getDoNotDisturbDate(userId).then((data) => { console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); @@ -2403,9 +2517,9 @@ Notification.getDoNotDisturbDate(userId).then((data) => { ``` -## Notification.supportDoNotDisturbMode +## Notification.isSupportDoNotDisturbMode -supportDoNotDisturbMode(callback: AsyncCallback\): void +isSupportDoNotDisturbMode(callback: AsyncCallback\): void Checks whether DND mode is supported. This API uses an asynchronous callback to return the result. @@ -2423,6 +2537,8 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2432,22 +2548,22 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to **Example** ```js -function supportDoNotDisturbModeCallback(err,data) { +function isSupportDoNotDisturbModeCallback(err,data) { if (err) { - console.info("supportDoNotDisturbMode failed " + JSON.stringify(err)); + console.info("isSupportDoNotDisturbMode failed " + JSON.stringify(err)); } else { - console.info("supportDoNotDisturbMode success"); + console.info("isSupportDoNotDisturbMode success"); } } -Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); +Notification.isSupportDoNotDisturbMode(supportDoNotDisturbModeCallback); ``` -## Notification.supportDoNotDisturbMode +## Notification.isSupportDoNotDisturbMode -supportDoNotDisturbMode(): Promise\ +isSupportDoNotDisturbMode(): Promise\ Checks whether DND mode is supported. This API uses a promise to return the result. @@ -2465,6 +2581,8 @@ Checks whether DND mode is supported. This API uses a promise to return the resu **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2474,8 +2592,8 @@ Checks whether DND mode is supported. This API uses a promise to return the resu **Example** ```js -Notification.supportDoNotDisturbMode().then((data) => { - console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data)); +Notification.isSupportDoNotDisturbMode().then((data) => { + console.info("isSupportDoNotDisturbMode success, data: " + JSON.stringify(data)); }); ``` @@ -2498,6 +2616,8 @@ Checks whether a specified template is supported. This API uses an asynchronous **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2508,7 +2628,7 @@ Checks whether a specified template is supported. This API uses an asynchronous **Example** ```javascript -var templateName = 'process'; +let templateName = 'process'; function isSupportTemplateCallback(err, data) { if (err) { console.info("isSupportTemplate failed " + JSON.stringify(err)); @@ -2544,6 +2664,8 @@ Checks whether a specified template is supported. This API uses a promise to ret **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2554,7 +2676,7 @@ Checks whether a specified template is supported. This API uses a promise to ret **Example** ```javascript -var templateName = 'process'; +let templateName = 'process'; Notification.isSupportTemplate(templateName).then((data) => { console.info("isSupportTemplate success, data: " + JSON.stringify(data)); @@ -2579,6 +2701,8 @@ Requests notification to be enabled for this application. This API uses an async **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2611,6 +2735,8 @@ Requests notification to be enabled for this application. This API uses a promis **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2648,6 +2774,8 @@ Sets whether this device supports distributed notifications. This API uses an as **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2666,7 +2794,7 @@ function setDistributedEnableCallback() { } }; -var enable = true +let enable = true; Notification.setDistributedEnable(enable, setDistributedEnableCallback); ``` @@ -2693,6 +2821,8 @@ Sets whether this device supports distributed notifications. This API uses a pro **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2703,7 +2833,7 @@ Sets whether this device supports distributed notifications. This API uses a pro **Example** ```javascript -var enable = true +let enable = true; Notification.setDistributedEnable(enable).then(() => { console.info("setDistributedEnable success"); @@ -2727,6 +2857,8 @@ Checks whether this device supports distributed notifications. This API uses an **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2766,6 +2898,8 @@ Checks whether this device supports distributed notifications. This API uses a p **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -2805,6 +2939,8 @@ Sets whether a specified application supports distributed notifications. This AP **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -2824,11 +2960,11 @@ function setDistributedEnableByBundleCallback(err) { } }; -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; -var enable = true +let enable = true Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback); ``` @@ -2856,6 +2992,8 @@ Sets whether a specified application supports distributed notifications. This AP **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -2867,11 +3005,11 @@ Sets whether a specified application supports distributed notifications. This AP **Example** ```javascript -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; -var enable = true +let enable = true Notification.setDistributedEnableByBundle(bundle, enable).then(() => { console.info("setDistributedEnableByBundle success"); @@ -2899,6 +3037,8 @@ Checks whether a specified application supports distributed notifications. This **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -2918,9 +3058,9 @@ function isDistributedEnabledByBundleCallback(data) { } }; -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); ``` @@ -2953,6 +3093,8 @@ Checks whether a specified application supports distributed notifications. This **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -2964,9 +3106,9 @@ Checks whether a specified application supports distributed notifications. This **Example** ```javascript -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; Notification.isDistributedEnabledByBundle(bundle).then((data) => { console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); @@ -2994,6 +3136,8 @@ Obtains the notification reminder type. This API uses an asynchronous callback t **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3036,6 +3180,8 @@ Obtains the notification reminder type. This API uses a promise to return the re **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3074,6 +3220,8 @@ Publishes a notification through the reminder agent. This API uses an asynchrono **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------------- | | 1600001 | Internal error. | @@ -3096,9 +3244,9 @@ function callback(err) { } } // Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo" +let representativeBundle = "com.example.demo"; // User ID -let userId = 100 +let userId = 100; // NotificationRequest object let request = { id: 1, @@ -3110,7 +3258,7 @@ let request = { additionalText: "test_additionalText" } } -} +}; Notification.publishAsBundle(request, representativeBundle, userId, callback); ``` @@ -3138,6 +3286,8 @@ Publishes a notification through the reminder agent. This API uses a promise to **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------------- | | 1600001 | Internal error. | @@ -3152,11 +3302,11 @@ Publishes a notification through the reminder agent. This API uses a promise to ```js // Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo" +let representativeBundle = "com.example.demo"; // User ID -let userId = 100 +let userId = 100; // NotificationRequest object -var request = { +let request = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, @@ -3166,7 +3316,7 @@ var request = { additionalText: "test_additionalText" } } -} +}; Notification.publishAsBundle(request, representativeBundle, userId).then(() => { console.info("publishAsBundle success"); @@ -3198,6 +3348,8 @@ Cancels a notification published by the reminder agent. This API uses an asynchr **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3218,9 +3370,9 @@ function cancelAsBundleCallback(err) { } } // Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo" +let representativeBundle = "com.example.demo"; // User ID -let userId = 100 +let userId = 100; Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); ``` @@ -3249,6 +3401,8 @@ Cancels a notification published by the reminder agent. This API uses a promise **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3261,9 +3415,9 @@ Cancels a notification published by the reminder agent. This API uses a promise ```js // Bundle name of the application whose notification function is taken over by the reminder agent -let representativeBundle = "com.example.demo" +let representativeBundle = "com.example.demo"; // User ID -let userId = 100 +let userId = 100; Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { console.info("cancelAsBundle success"); @@ -3293,6 +3447,8 @@ Sets whether to enable a specified notification slot type for a specified applic **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -3341,6 +3497,8 @@ Sets whether to enable a specified notification slot type for a specified applic **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -3382,6 +3540,8 @@ Checks whether a specified notification slot type is enabled for a specified app **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -3434,6 +3594,8 @@ Checks whether a specified notification slot type is enabled for a specified app **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -3474,6 +3636,8 @@ Sets whether to enable the notification sync feature for devices where the appli **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3526,6 +3690,8 @@ Sets whether to enable the notification sync feature for devices where the appli **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3568,6 +3734,8 @@ Obtains whether the notification sync feature is enabled for devices where the a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -3618,6 +3786,8 @@ Obtains whether the notification sync feature is enabled for devices where the a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | diff --git a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md index ed0ad9400e..edef7122d0 100644 --- a/en/application-dev/reference/apis/js-apis-notificationSubscribe.md +++ b/en/application-dev/reference/apis/js-apis-notificationSubscribe.md @@ -1,4 +1,4 @@ -# @ohos.notificationSubscribe +# @ohos.notificationSubscribe (NotificationSubscribe) The **NotificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs. @@ -36,6 +36,8 @@ Subscribes to a notification with the subscription information specified. This A **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -56,12 +58,12 @@ function subscribeCallback(err) { function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback -} -var info = { +}; +let info = { bundleNames: ["bundleName1","bundleName2"] -} +}; NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); ``` @@ -88,6 +90,8 @@ Subscribes to notifications of all applications under this user. This API uses a **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -107,9 +111,9 @@ function subscribeCallback(err) { function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback -} +}; NotificationSubscribe.subscribe(subscriber, subscribeCallback); ``` @@ -136,6 +140,8 @@ Subscribes to a notification with the subscription information specified. This A **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -148,7 +154,7 @@ Subscribes to a notification with the subscription information specified. This A function onConsumeCallback(data) { console.info("Consume callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onConsume: onConsumeCallback }; NotificationSubscribe.subscribe(subscriber).then(() => { @@ -179,6 +185,8 @@ Unsubscribes from a notification. This API uses an asynchronous callback to retu **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -198,9 +206,9 @@ function unsubscribeCallback(err) { function onDisconnectCallback(data) { console.info("Cancel callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onDisconnect: onDisconnectCallback -} +}; NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); ``` @@ -226,6 +234,8 @@ Unsubscribes from a notification. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -238,7 +248,7 @@ Unsubscribes from a notification. This API uses a promise to return the result. function onDisconnectCallback(data) { console.info("Cancel callback: " + JSON.stringify(data)); } -var subscriber = { +let subscriber = { onDisconnect: onDisconnectCallback }; NotificationSubscribe.unsubscribe(subscriber).then(() => { @@ -271,6 +281,8 @@ Removes a notification for a specified application. This API uses an asynchronou **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -289,14 +301,14 @@ function removeCallback(err) { console.info("remove success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationKey = { +}; +let notificationKey = { id: 0, label: "label", -} -var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +}; +let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); ``` @@ -324,6 +336,8 @@ Removes a notification for a specified application. This API uses a promise to r **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -335,14 +349,14 @@ Removes a notification for a specified application. This API uses a promise to r **Example** ```js -var bundle = { +let bundle = { bundle: "bundleName1", -} -var notificationKey = { +}; +let notificationKey = { id: 0, label: "label", -} -var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +}; +let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => { console.info("remove success"); }); @@ -372,6 +386,8 @@ Removes a specified notification. This API uses an asynchronous callback to retu **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -382,7 +398,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu **Example** ```js -var hashCode = 'hashCode' +let hashCode = 'hashCode'; function removeCallback(err) { if (err) { @@ -391,7 +407,7 @@ function removeCallback(err) { console.info("remove success"); } } -var reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; +let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; NotificationSubscribe.remove(hashCode, reason, removeCallback); ``` @@ -418,6 +434,8 @@ Removes a specified notification. This API uses a promise to return the result. **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -428,8 +446,8 @@ Removes a specified notification. This API uses a promise to return the result. **Example** ```js -var hashCode = 'hashCode' -var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; +let hashCode = 'hashCode'; +let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; NotificationSubscribe.remove(hashCode, reason).then(() => { console.info("remove success"); }); @@ -458,6 +476,8 @@ Removes all notifications for a specified application. This API uses an asynchro **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -475,9 +495,9 @@ function removeAllCallback(err) { console.info("removeAll success"); } } -var bundle = { +let bundle = { bundle: "bundleName1", -} +}; NotificationSubscribe.removeAll(bundle, removeAllCallback); ``` @@ -503,6 +523,8 @@ Removes all notifications. This API uses an asynchronous callback to return the **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -545,6 +567,8 @@ Removes all notifications for a specified application. This API uses a promise t **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ---------------------------------------- | | 1600001 | Internal error. | @@ -582,6 +606,8 @@ Removes all notifications for a specified user. This API uses an asynchronous ca **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -600,7 +626,7 @@ function removeAllCallback(err) { } } -var userId = 1 +let userId = 1; NotificationSubscribe.removeAll(userId, removeAllCallback); ``` @@ -625,6 +651,8 @@ Removes all notifications for a specified user. This API uses a promise to retur **Error codes** +For details about the error codes, see [Notification Error Codes](../errorcodes/errorcode-notification.md). + | ID| Error Message | | -------- | ----------------------------------- | | 1600001 | Internal error. | @@ -643,7 +671,7 @@ function removeAllCallback(err) { } } -var userId = 1 +let userId = 1; NotificationSubscribe.removeAll(userId, removeAllCallback); ``` @@ -689,7 +717,7 @@ function onConsumeCallback(data) { console.info('===> onConsume callback req.id:' + req.id); }; -var subscriber = { +let subscriber = { onConsume: onConsumeCallback }; @@ -729,7 +757,7 @@ function onCancelCallback(data) { console.info('===> onCancel callback req.id:' + req.id); } -var subscriber = { +let subscriber = { onCancel: onCancelCallback }; @@ -767,7 +795,7 @@ function onUpdateCallback(map) { console.info('===> onUpdateCallback map:' + JSON.stringify(map)); } -var subscriber = { +let subscriber = { onUpdate: onUpdateCallback }; @@ -799,7 +827,7 @@ function onConnectCallback() { console.info('===> onConnect in test'); } -var subscriber = { +let subscriber = { onConnect: onConnectCallback }; @@ -841,7 +869,7 @@ function onDisconnectCallback() { console.info('===> onDisconnect in test'); } -var subscriber = { +let subscriber = { onConnect: onConnectCallback, onDisconnect: onDisconnectCallback }; @@ -877,7 +905,7 @@ function onDestroyCallback() { console.info('===> onDestroy in test'); } -var subscriber = { +let subscriber = { onDestroy: onDestroyCallback }; @@ -915,7 +943,7 @@ function onDoNotDisturbDateChangeCallback(mode) { console.info('===> onDoNotDisturbDateChange:' + mode); } -var subscriber = { +let subscriber = { onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback }; @@ -956,7 +984,7 @@ function onEnabledNotificationChangedCallback(callbackData) { console.info("enable: ", callbackData.enable); }; -var subscriber = { +let subscriber = { onEnabledNotificationChanged: onEnabledNotificationChangedCallback }; @@ -1011,7 +1039,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ## NotificationSorting -Provides sorting information of activity notifications. +Provides sorting information of active notifications. **System capability**: SystemCapability.Notification.Notification diff --git a/en/application-dev/reference/errorcodes/errorcode-notification.md b/en/application-dev/reference/errorcodes/errorcode-notification.md new file mode 100644 index 0000000000..9f1d521902 --- /dev/null +++ b/en/application-dev/reference/errorcodes/errorcode-notification.md @@ -0,0 +1,219 @@ +# Notification Error Codes + +## 1600001 Internal Error + +**Error Message** + +Internal error. + +**Description** + +This error code is reported when an error occurs during internal processing, such as multi-thread processing or internal pointer checks. + +**Cause** + +Common kernel errors such as multi-thread processing and internal processing errors occur. + +**Solution** + +Make sure the system resources are sufficient. + +## 1600002 Marshalling or Unmarshalling Error + +**Error Message** + +marshalling or unmarshalling error. + +**Description** + +This error code is reported when a marshalling or unmarshalling error occurs before data transmission. + +**Cause** + +A parameter mismatch is detected between the application and the notification service. + +**Solution** + +Make sure the application SDK version matches the system version. + +## 1600003 Failed to Connect to the Notification Service + +**Error Message** + +Failed to connect service. + +**Description** + +This error code is reported when the application fails to connect to the notification service. + +**Cause** + +The notification service is busy or abnormal. + +**Solution** + +Restart the system. + +## 1600004 Notification Disabled + +**Error Message** + +Notification is not enabled. + +**Description** + +This error code is reported when notification is disabled. + +**Cause** + +The notification feature is not enabled for the application. + +**Solution** + +Enable notification for the application in the notification settings. + +## 1600005 Notification Slot Disabled + +**Error Message** + +Notification slot is not enabled. + +**Description** + +This error code is reported when the notification slot is not available. + +**Cause** + +The notification slot is disabled or has not been added. + +**Solution** + +1. Access the notification settings and check whether the application has the notification slot. If no, add it. + +2. Make sure the notification slot is enabled. + +## 1600006 Notification Deletion Failed + +**Error Message** + +Notification is not allowed to remove. + +**Description** + +This error code is reported when notification deletion is disabled. + +**Cause** + +The notification attribute **isUnremovable** is set to true. + +**Solution** + +Set **isUnremovable** as needed. For details, see [NotificationRequest](../apis/js-apis-notificationManager.md#notificationrequest). + +## 1600007 Notification Not Found + +**Error Message** + +The notification is not exist. + +**Description** + +This error code is reported when the notification service could not find the notification. + +**Cause** + +The notification has been canceled or deleted. + +**Solution** + +N/A + +## 1600008 User Not Found + +**Error Message** + +The user is not exist. + +**Description** + +This error code is reported when the specified user is not found in the information system. + +**Cause** + +The user information passed is incorrect. + +**Solution** + +Verify the user information. + +## 1600009 Notification Sending Limit Reached + +**Error Message** + +Over max number notifications per second. + +**Description** + +This error code is reported when the notification sending frequency reaches the upper limit. + +**Cause** + +More than 10 notifications are sent per second. + +**Solution** + +Reduce the notification sending frequency to no more than 10 per second. + +## 16000010 Distributed Operation Failed + +**Error Message** + +Distributed operation failed. + +**Description** + +This error code is reported when an error occurs with the distributed database operation or distributed API invoking. + +**Cause** + +The distributed database could not be operated or the distributed API could not be invoked. + +**Solution** + +Verify the distributed connection. + +## 16000011 Failed to Read the Template Configuration + +**Error Message** + +Read template config failed. + +**Description** + +This error code is reported when the attempt to read the template configuration file fails. + +**Cause** + +The template configuration file is lost in the system. + +**Solution** + +Check for the template configuration file: /system/etc/notification_template/external.json. + +## 16000012 Insufficient Memory Space + +**Error Message** + +No memory space. + +**Description** + +This error code is reported when a memory allocation error occurs. + +**Cause** + +A memory allocation error occurs. + +**Solution** + +Ensure sufficient system memory. -- GitLab