未验证 提交 4c108670 编写于 作者: O openharmony_ci 提交者: Gitee

!13857 翻译完成 13343

Merge pull request !13857 from ester.zhou/TR-13343
# @ohos.notification # @ohos.notification (Notification)
The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status. The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status.
...@@ -41,7 +41,7 @@ function publishCallback(err) { ...@@ -41,7 +41,7 @@ function publishCallback(err) {
} }
} }
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -51,8 +51,8 @@ var notificationRequest = { ...@@ -51,8 +51,8 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, publishCallback) Notification.publish(notificationRequest, publishCallback);
``` ```
...@@ -75,7 +75,7 @@ Publishes a notification. This API uses a promise to return the result. ...@@ -75,7 +75,7 @@ Publishes a notification. This API uses a promise to return the result.
```js ```js
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -85,7 +85,7 @@ var notificationRequest = { ...@@ -85,7 +85,7 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest).then(() => { Notification.publish(notificationRequest).then(() => {
console.info("publish success"); console.info("publish success");
}); });
...@@ -124,9 +124,9 @@ function publishCallback(err) { ...@@ -124,9 +124,9 @@ function publishCallback(err) {
} }
} }
// User ID // User ID
var userId = 1 let userId = 1;
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -136,7 +136,7 @@ var notificationRequest = { ...@@ -136,7 +136,7 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, userId, publishCallback); Notification.publish(notificationRequest, userId, publishCallback);
``` ```
...@@ -162,7 +162,7 @@ Publishes a notification to a specified user. This API uses a promise to return ...@@ -162,7 +162,7 @@ Publishes a notification to a specified user. This API uses a promise to return
**Example** **Example**
```js ```js
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -172,9 +172,9 @@ var notificationRequest = { ...@@ -172,9 +172,9 @@ var notificationRequest = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
var userId = 1 let userId = 1;
Notification.publish(notificationRequest, userId).then(() => { Notification.publish(notificationRequest, userId).then(() => {
console.info("publish success"); console.info("publish success");
...@@ -209,7 +209,7 @@ function cancelCallback(err) { ...@@ -209,7 +209,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, "label", cancelCallback) Notification.cancel(0, "label", cancelCallback);
``` ```
...@@ -265,7 +265,7 @@ function cancelCallback(err) { ...@@ -265,7 +265,7 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, cancelCallback) Notification.cancel(0, cancelCallback);
``` ```
...@@ -295,7 +295,7 @@ function cancelAllCallback(err) { ...@@ -295,7 +295,7 @@ function cancelAllCallback(err) {
console.info("cancelAll success"); console.info("cancelAll success");
} }
} }
Notification.cancelAll(cancelAllCallback) Notification.cancelAll(cancelAllCallback);
``` ```
...@@ -349,10 +349,10 @@ function addSlotCallBack(err) { ...@@ -349,10 +349,10 @@ function addSlotCallBack(err) {
} }
} }
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot, addSlotCallBack) Notification.addSlot(notificationSlot, addSlotCallBack);
``` ```
...@@ -379,9 +379,9 @@ Adds a notification slot. This API uses a promise to return the result. ...@@ -379,9 +379,9 @@ Adds a notification slot. This API uses a promise to return the result.
```js ```js
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot).then(() => { Notification.addSlot(notificationSlot).then(() => {
console.info("addSlot success"); console.info("addSlot success");
}); });
...@@ -415,7 +415,7 @@ function addSlotCallBack(err) { ...@@ -415,7 +415,7 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
``` ```
...@@ -475,14 +475,14 @@ function addSlotsCallBack(err) { ...@@ -475,14 +475,14 @@ function addSlotsCallBack(err) {
} }
} }
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
// NotificationSlotArray object // NotificationSlotArray object
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray, addSlotsCallBack) Notification.addSlots(notificationSlotArray, addSlotsCallBack);
``` ```
...@@ -509,11 +509,11 @@ Adds an array of notification slots. This API uses a promise to return the resul ...@@ -509,11 +509,11 @@ Adds an array of notification slots. This API uses a promise to return the resul
```js ```js
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
// NotificationSlotArray object // NotificationSlotArray object
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then(() => { Notification.addSlots(notificationSlotArray).then(() => {
...@@ -549,8 +549,8 @@ function getSlotCallback(err, data) { ...@@ -549,8 +549,8 @@ function getSlotCallback(err, data) {
console.info("getSlot success"); console.info("getSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback) Notification.getSlot(slotType, getSlotCallback);
``` ```
...@@ -578,7 +578,7 @@ Obtains a notification slot of a specified type. This API uses a promise to retu ...@@ -578,7 +578,7 @@ Obtains a notification slot of a specified type. This API uses a promise to retu
**Example** **Example**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => { Notification.getSlot(slotType).then((data) => {
console.info("getSlot success, data: " + JSON.stringify(data)); console.info("getSlot success, data: " + JSON.stringify(data));
}); });
...@@ -611,7 +611,7 @@ function getSlotsCallback(err, data) { ...@@ -611,7 +611,7 @@ function getSlotsCallback(err, data) {
console.info("getSlots success"); console.info("getSlots success");
} }
} }
Notification.getSlots(getSlotsCallback) Notification.getSlots(getSlotsCallback);
``` ```
...@@ -666,8 +666,8 @@ function removeSlotCallback(err) { ...@@ -666,8 +666,8 @@ function removeSlotCallback(err) {
console.info("removeSlot success"); console.info("removeSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback) Notification.removeSlot(slotType,removeSlotCallback);
``` ```
...@@ -689,7 +689,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu ...@@ -689,7 +689,7 @@ Removes a notification slot of a specified type. This API uses a promise to retu
**Example** **Example**
```js ```js
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = Notification.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() => { Notification.removeSlot(slotType).then(() => {
console.info("removeSlot success"); console.info("removeSlot success");
}); });
...@@ -721,7 +721,7 @@ function removeAllCallBack(err) { ...@@ -721,7 +721,7 @@ function removeAllCallBack(err) {
console.info("removeAllSlots success"); console.info("removeAllSlots success");
} }
} }
Notification.removeAllSlots(removeAllCallBack) Notification.removeAllSlots(removeAllCallBack);
``` ```
...@@ -778,12 +778,12 @@ function subscribeCallback(err) { ...@@ -778,12 +778,12 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
var info = { let info = {
bundleNames: ["bundleName1", "bundleName2"] bundleNames: ["bundleName1", "bundleName2"]
} };
Notification.subscribe(subscriber, info, subscribeCallback); Notification.subscribe(subscriber, info, subscribeCallback);
``` ```
...@@ -821,9 +821,9 @@ function subscribeCallback(err) { ...@@ -821,9 +821,9 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -854,7 +854,7 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -854,7 +854,7 @@ Subscribes to a notification with the subscription information specified. This A
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
Notification.subscribe(subscriber).then(() => { Notification.subscribe(subscriber).then(() => {
...@@ -896,9 +896,9 @@ function unsubscribeCallback(err) { ...@@ -896,9 +896,9 @@ function unsubscribeCallback(err) {
function onDisconnectCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
} };
Notification.unsubscribe(subscriber, unsubscribeCallback); Notification.unsubscribe(subscriber, unsubscribeCallback);
``` ```
...@@ -928,7 +928,7 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -928,7 +928,7 @@ Unsubscribes from a notification. This API uses a promise to return the result.
function onDisconnectCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
Notification.unsubscribe(subscriber).then(() => { Notification.unsubscribe(subscriber).then(() => {
...@@ -968,9 +968,9 @@ function enableNotificationCallback(err) { ...@@ -968,9 +968,9 @@ function enableNotificationCallback(err) {
console.info("enableNotification success"); console.info("enableNotification success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.enableNotification(bundle, false, enableNotificationCallback); Notification.enableNotification(bundle, false, enableNotificationCallback);
``` ```
...@@ -998,9 +998,9 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -998,9 +998,9 @@ Sets whether to enable notification for a specified application. This API uses a
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.enableNotification(bundle, false).then(() => { Notification.enableNotification(bundle, false).then(() => {
console.info("enableNotification success"); console.info("enableNotification success");
}); });
...@@ -1037,9 +1037,9 @@ function isNotificationEnabledCallback(err, data) { ...@@ -1037,9 +1037,9 @@ function isNotificationEnabledCallback(err, data) {
console.info("isNotificationEnabled success"); console.info("isNotificationEnabled success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback);
``` ```
...@@ -1072,9 +1072,9 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1072,9 +1072,9 @@ Checks whether notification is enabled for a specified application. This API use
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle).then((data) => { Notification.isNotificationEnabled(bundle).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
...@@ -1180,9 +1180,9 @@ function displayBadgeCallback(err) { ...@@ -1180,9 +1180,9 @@ function displayBadgeCallback(err) {
console.info("displayBadge success"); console.info("displayBadge success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false, displayBadgeCallback); Notification.displayBadge(bundle, false, displayBadgeCallback);
``` ```
...@@ -1210,9 +1210,9 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1210,9 +1210,9 @@ Sets whether to enable the notification badge for a specified application. This
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false).then(() => { Notification.displayBadge(bundle, false).then(() => {
console.info("displayBadge success"); console.info("displayBadge success");
}); });
...@@ -1249,9 +1249,9 @@ function isBadgeDisplayedCallback(err, data) { ...@@ -1249,9 +1249,9 @@ function isBadgeDisplayedCallback(err, data) {
console.info("isBadgeDisplayed success"); console.info("isBadgeDisplayed success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
``` ```
...@@ -1284,9 +1284,9 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1284,9 +1284,9 @@ Checks whether the notification badge is enabled for a specified application. Th
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle).then((data) => { Notification.isBadgeDisplayed(bundle).then((data) => {
console.info("isBadgeDisplayed success, data: " + JSON.stringify(data)); console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
}); });
...@@ -1324,12 +1324,12 @@ function setSlotByBundleCallback(err) { ...@@ -1324,12 +1324,12 @@ function setSlotByBundleCallback(err) {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
``` ```
...@@ -1357,12 +1357,12 @@ Sets the notification slot for a specified application. This API uses a promise ...@@ -1357,12 +1357,12 @@ Sets the notification slot for a specified application. This API uses a promise
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: Notification.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot).then(() => { Notification.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
}); });
...@@ -1399,9 +1399,9 @@ function getSlotsByBundleCallback(err, data) { ...@@ -1399,9 +1399,9 @@ function getSlotsByBundleCallback(err, data) {
console.info("getSlotsByBundle success"); console.info("getSlotsByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback);
``` ```
...@@ -1434,9 +1434,9 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1434,9 +1434,9 @@ Obtains the notification slots of a specified application. This API uses a promi
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle).then((data) => { Notification.getSlotsByBundle(bundle).then((data) => {
console.info("getSlotsByBundle success, data: " + JSON.stringify(data)); console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
}); });
...@@ -1473,9 +1473,9 @@ function getSlotNumByBundleCallback(err, data) { ...@@ -1473,9 +1473,9 @@ function getSlotNumByBundleCallback(err, data) {
console.info("getSlotNumByBundle success"); console.info("getSlotNumByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
``` ```
...@@ -1508,9 +1508,9 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1508,9 +1508,9 @@ Obtains the number of notification slots of a specified application. This API us
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle).then((data) => { Notification.getSlotNumByBundle(bundle).then((data) => {
console.info("getSlotNumByBundle success, data: " + JSON.stringify(data)); console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
}); });
...@@ -1549,14 +1549,14 @@ function removeCallback(err) { ...@@ -1549,14 +1549,14 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason, removeCallback); Notification.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -1585,14 +1585,14 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1585,14 +1585,14 @@ Removes a notification for a specified bundle. This API uses a promise to return
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(bundle, notificationKey, reason).then(() => { Notification.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -1623,7 +1623,7 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal ...@@ -1623,7 +1623,7 @@ Removes a notification for a specified bundle. This API uses an asynchronous cal
**Example** **Example**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err.code) { if (err.code) {
...@@ -1632,7 +1632,7 @@ function removeCallback(err) { ...@@ -1632,7 +1632,7 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var reason = Notification.RemoveReason.CANCEL_REASON_REMOVE; let reason = Notification.RemoveReason.CANCEL_REASON_REMOVE;
Notification.remove(hashCode, reason, removeCallback); Notification.remove(hashCode, reason, removeCallback);
``` ```
...@@ -1660,8 +1660,8 @@ Removes a notification for a specified bundle. This API uses a promise to return ...@@ -1660,8 +1660,8 @@ Removes a notification for a specified bundle. This API uses a promise to return
**Example** **Example**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
var reason = Notification.RemoveReason.CLICK_REASON_REMOVE; let reason = Notification.RemoveReason.CLICK_REASON_REMOVE;
Notification.remove(hashCode, reason).then(() => { Notification.remove(hashCode, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
...@@ -1698,9 +1698,9 @@ function removeAllCallback(err) { ...@@ -1698,9 +1698,9 @@ function removeAllCallback(err) {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.removeAll(bundle, removeAllCallback); Notification.removeAll(bundle, removeAllCallback);
``` ```
...@@ -1797,7 +1797,7 @@ function removeAllCallback(err) { ...@@ -1797,7 +1797,7 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
Notification.removeAll(userId, removeAllCallback); Notification.removeAll(userId, removeAllCallback);
``` ```
...@@ -1822,7 +1822,7 @@ Removes all notifications for a specified user. This API uses a promise to retur ...@@ -1822,7 +1822,7 @@ Removes all notifications for a specified user. This API uses a promise to retur
**Example** **Example**
```js ```js
var userId = 1 let userId = 1;
Notification.removeAll(userId).then(() => { Notification.removeAll(userId).then(() => {
console.info("removeAll success"); console.info("removeAll success");
}); });
...@@ -2025,7 +2025,7 @@ function cancelGroupCallback(err) { ...@@ -2025,7 +2025,7 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); Notification.cancelGroup(groupName, cancelGroupCallback);
``` ```
...@@ -2049,7 +2049,7 @@ Cancels notifications under a notification group of this application. This API u ...@@ -2049,7 +2049,7 @@ Cancels notifications under a notification group of this application. This API u
**Example** **Example**
```js ```js
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => { Notification.cancelGroup(groupName).then(() => {
console.info("cancelGroup success"); console.info("cancelGroup success");
}); });
...@@ -2088,8 +2088,8 @@ function removeGroupByBundleCallback(err) { ...@@ -2088,8 +2088,8 @@ function removeGroupByBundleCallback(err) {
} }
} }
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
``` ```
...@@ -2118,8 +2118,8 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -2118,8 +2118,8 @@ Removes notifications under a notification group of a specified application. Thi
**Example** **Example**
```js ```js
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => { Notification.removeGroupByBundle(bundleOption, groupName).then(() => {
console.info("removeGroupByBundle success"); console.info("removeGroupByBundle success");
}); });
...@@ -2157,11 +2157,11 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2157,11 +2157,11 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
``` ```
...@@ -2189,11 +2189,11 @@ Sets the DND time. This API uses a promise to return the result. ...@@ -2189,11 +2189,11 @@ Sets the DND time. This API uses a promise to return the result.
**Example** **Example**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate success"); console.info("setDoNotDisturbDate success");
}); });
...@@ -2231,13 +2231,13 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2231,13 +2231,13 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1
Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
``` ```
...@@ -2265,13 +2265,13 @@ Sets the DND time for a specified user. This API uses a promise to return the re ...@@ -2265,13 +2265,13 @@ Sets the DND time for a specified user. This API uses a promise to return the re
**Example** **Example**
```js ```js
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
console.info("setDoNotDisturbDate success"); console.info("setDoNotDisturbDate success");
...@@ -2370,7 +2370,7 @@ function getDoNotDisturbDateCallback(err,data) { ...@@ -2370,7 +2370,7 @@ function getDoNotDisturbDateCallback(err,data) {
} }
} }
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
``` ```
...@@ -2404,7 +2404,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the ...@@ -2404,7 +2404,7 @@ Obtains the DND time of a specified user. This API uses a promise to return the
**Example** **Example**
```js ```js
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId).then((data) => { Notification.getDoNotDisturbDate(userId).then((data) => {
console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
...@@ -2492,7 +2492,7 @@ Checks whether a specified template exists. This API uses an asynchronous callba ...@@ -2492,7 +2492,7 @@ Checks whether a specified template exists. This API uses an asynchronous callba
**Example** **Example**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
function isSupportTemplateCallback(err, data) { function isSupportTemplateCallback(err, data) {
if (err.code) { if (err.code) {
console.info("isSupportTemplate failed " + JSON.stringify(err)); console.info("isSupportTemplate failed " + JSON.stringify(err));
...@@ -2529,7 +2529,7 @@ Checks whether a specified template exists. This API uses a promise to return th ...@@ -2529,7 +2529,7 @@ Checks whether a specified template exists. This API uses a promise to return th
**Example** **Example**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
Notification.isSupportTemplate(templateName).then((data) => { Notification.isSupportTemplate(templateName).then((data) => {
console.info("isSupportTemplate success, data: " + JSON.stringify(data)); console.info("isSupportTemplate success, data: " + JSON.stringify(data));
...@@ -2615,7 +2615,7 @@ function enabledNotificationCallback(err) { ...@@ -2615,7 +2615,7 @@ function enabledNotificationCallback(err) {
} }
}; };
var enable = true let enable = true;
Notification.enableDistributed(enable, enabledNotificationCallback); Notification.enableDistributed(enable, enabledNotificationCallback);
``` ```
...@@ -2643,7 +2643,7 @@ Sets whether this device supports distributed notifications. This API uses a pro ...@@ -2643,7 +2643,7 @@ Sets whether this device supports distributed notifications. This API uses a pro
**Example** **Example**
```javascript ```javascript
var enable = true let enable = true;
Notification.enableDistributed(enable).then(() => { Notification.enableDistributed(enable).then(() => {
console.info("enableDistributed success"); console.info("enableDistributed success");
}); });
...@@ -2734,11 +2734,11 @@ function enableDistributedByBundleCallback(err) { ...@@ -2734,11 +2734,11 @@ function enableDistributedByBundleCallback(err) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true;
Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback); Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback);
``` ```
...@@ -2767,11 +2767,11 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2767,11 +2767,11 @@ Sets whether a specified application supports distributed notifications. This AP
**Example** **Example**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true;
Notification.enableDistributedByBundle(bundle, enable).then(() => { Notification.enableDistributedByBundle(bundle, enable).then(() => {
console.info("enableDistributedByBundle success"); console.info("enableDistributedByBundle success");
}); });
...@@ -2807,9 +2807,9 @@ function isDistributedEnabledByBundleCallback(err, data) { ...@@ -2807,9 +2807,9 @@ function isDistributedEnabledByBundleCallback(err, data) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
``` ```
...@@ -2843,9 +2843,9 @@ Checks whether a specified application supports distributed notifications. This ...@@ -2843,9 +2843,9 @@ Checks whether a specified application supports distributed notifications. This
**Example** **Example**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle).then((data) => { Notification.isDistributedEnabledByBundle(bundle).then((data) => {
console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
...@@ -2947,9 +2947,9 @@ function callback(err) { ...@@ -2947,9 +2947,9 @@ function callback(err) {
} }
} }
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
// NotificationRequest object // NotificationRequest object
let request = { let request = {
id: 1, id: 1,
...@@ -2961,7 +2961,7 @@ let request = { ...@@ -2961,7 +2961,7 @@ let request = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(request, representativeBundle, userId, callback); Notification.publishAsBundle(request, representativeBundle, userId, callback);
``` ```
...@@ -2991,11 +2991,11 @@ Publishes a notification through the reminder agent. This API uses a promise to ...@@ -2991,11 +2991,11 @@ Publishes a notification through the reminder agent. This API uses a promise to
```js ```js
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
// NotificationRequest object // NotificationRequest object
var request = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
...@@ -3005,7 +3005,7 @@ var request = { ...@@ -3005,7 +3005,7 @@ var request = {
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(request, representativeBundle, userId).then(() => { Notification.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle success"); console.info("publishAsBundle success");
...@@ -3047,9 +3047,9 @@ function cancelAsBundleCallback(err) { ...@@ -3047,9 +3047,9 @@ function cancelAsBundleCallback(err) {
} }
} }
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
``` ```
...@@ -3080,9 +3080,9 @@ Cancels a notification published by the reminder agent. This API uses a promise ...@@ -3080,9 +3080,9 @@ Cancels a notification published by the reminder agent. This API uses a promise
```js ```js
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { Notification.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success"); console.info("cancelAsBundle success");
...@@ -3421,7 +3421,7 @@ function onConsumeCallback(data) { ...@@ -3421,7 +3421,7 @@ function onConsumeCallback(data) {
console.info('===> onConsume callback req.id:' + req.id); console.info('===> onConsume callback req.id:' + req.id);
}; };
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
...@@ -3460,7 +3460,7 @@ function onCancelCallback(data) { ...@@ -3460,7 +3460,7 @@ function onCancelCallback(data) {
console.info('===> onCancel callback req.id:' + req.id); console.info('===> onCancel callback req.id:' + req.id);
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
...@@ -3498,7 +3498,7 @@ function onUpdateCallback(map) { ...@@ -3498,7 +3498,7 @@ function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map)); console.info('===> onUpdateCallback map:' + JSON.stringify(map));
} }
var subscriber = { let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
...@@ -3530,7 +3530,7 @@ function onConnectCallback() { ...@@ -3530,7 +3530,7 @@ function onConnectCallback() {
console.info('===> onConnect in test'); console.info('===> onConnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
...@@ -3572,7 +3572,7 @@ function onDisconnectCallback() { ...@@ -3572,7 +3572,7 @@ function onDisconnectCallback() {
console.info('===> onDisconnect in test'); console.info('===> onDisconnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
...@@ -3608,7 +3608,7 @@ function onDestroyCallback() { ...@@ -3608,7 +3608,7 @@ function onDestroyCallback() {
console.info('===> onDestroy in test'); console.info('===> onDestroy in test');
} }
var subscriber = { let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
...@@ -3645,12 +3645,12 @@ function onDoNotDisturbDateChangeCallback(mode) { ...@@ -3645,12 +3645,12 @@ function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode); console.info('===> onDoNotDisturbDateChange:' + mode);
} }
var subscriber = { let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: Notification.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
...@@ -3695,12 +3695,12 @@ function onEnabledNotificationChangedCallback(callbackData) { ...@@ -3695,12 +3695,12 @@ function onEnabledNotificationChangedCallback(callbackData) {
console.info("enable: " + callbackData.enable); console.info("enable: " + callbackData.enable);
}; };
var subscriber = { let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
Notification.subscribe(subscriber, subscribeCallback); Notification.subscribe(subscriber, subscribeCallback);
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} }
// Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes. // Set the onEnabledNotificationChanged callback that is triggered when the notification enabled status changes.
......
# @ohos.notificationManager # @ohos.notificationManager (NotificationManager)
The **notificationManager** module provides notification management capabilities, covering notifications, notification slots, notification enabled status, and notification badge status. The **notificationManager** module provides notification management capabilities, covering notifications, notification slots, notification enabled status, and notification badge status.
...@@ -8,11 +8,11 @@ The **notificationManager** module provides notification management capabilities ...@@ -8,11 +8,11 @@ The **notificationManager** module provides notification management capabilities
## Modules to Import ## Modules to Import
```js ```ts
import Notification from '@ohos.notificationManager'; import notificationManager from '@ohos.notificationManager';
``` ```
## Notification.publish ## notificationManager.publish
publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void publish(request: NotificationRequest, callback: AsyncCallback\<void\>): void
...@@ -40,7 +40,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r ...@@ -40,7 +40,7 @@ Publishes a notification. This API uses an asynchronous callback to return the r
**Example** **Example**
```js ```ts
// publish callback // publish callback
function publishCallback(err) { function publishCallback(err) {
if (err) { if (err) {
...@@ -50,23 +50,21 @@ function publishCallback(err) { ...@@ -50,23 +50,21 @@ function publishCallback(err) {
} }
} }
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, publishCallback) notificationManager.publish(notificationRequest, publishCallback);
``` ```
## notificationManager.publish
## Notification.publish
publish(request: NotificationRequest): Promise\<void\> publish(request: NotificationRequest): Promise\<void\>
...@@ -93,26 +91,26 @@ Publishes a notification. This API uses a promise to return the result. ...@@ -93,26 +91,26 @@ Publishes a notification. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest).then(() => { notificationManager.publish(notificationRequest).then(() => {
console.info("publish success"); console.info("publish success");
}); });
``` ```
## Notification.publish ## notificationManager.publish
publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void publish(request: NotificationRequest, userId: number, callback: AsyncCallback\<void\>): void
...@@ -146,7 +144,7 @@ Publishes a notification to a specified user. This API uses an asynchronous call ...@@ -146,7 +144,7 @@ Publishes a notification to a specified user. This API uses an asynchronous call
**Example** **Example**
```js ```ts
// publish callback // publish callback
function publishCallback(err) { function publishCallback(err) {
if (err) { if (err) {
...@@ -156,23 +154,23 @@ function publishCallback(err) { ...@@ -156,23 +154,23 @@ function publishCallback(err) {
} }
} }
// User ID // User ID
var userId = 1 let userId = 1;
// NotificationRequest object // NotificationRequest object
var notificationRequest = { let notificationRequest = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publish(notificationRequest, userId, publishCallback); notificationManager.publish(notificationRequest, userId, publishCallback);
``` ```
## Notification.publish ## notificationManager.publish
publish(request: NotificationRequest, userId: number): Promise\<void\> publish(request: NotificationRequest, userId: number): Promise\<void\>
...@@ -205,28 +203,28 @@ Publishes a notification to a specified user. This API uses a promise to return ...@@ -205,28 +203,28 @@ Publishes a notification to a specified user. This API uses a promise to return
**Example** **Example**
```js ```ts
var notificationRequest = { let notificationRequest = {
notificationId: 1, notificationId: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
var userId = 1 let userId = 1;
Notification.publish(notificationRequest, userId).then(() => { notificationManager.publish(notificationRequest, userId).then(() => {
console.info("publish success"); console.info("publish success");
}); });
``` ```
## Notification.cancel ## notificationManager.cancel
cancel(id: number, label: string, callback: AsyncCallback\<void\>): void cancel(id: number, label: string, callback: AsyncCallback\<void\>): void
...@@ -253,7 +251,7 @@ Cancels a notification with the specified ID and label. This API uses an asynchr ...@@ -253,7 +251,7 @@ Cancels a notification with the specified ID and label. This API uses an asynchr
**Example** **Example**
```js ```ts
// cancel callback // cancel callback
function cancelCallback(err) { function cancelCallback(err) {
if (err) { if (err) {
...@@ -262,12 +260,10 @@ function cancelCallback(err) { ...@@ -262,12 +260,10 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, "label", cancelCallback) notificationManager.cancel(0, "label", cancelCallback);
``` ```
## notificationManager.cancel
## Notification.cancel
cancel(id: number, label?: string): Promise\<void\> cancel(id: number, label?: string): Promise\<void\>
...@@ -293,15 +289,13 @@ Cancels a notification with the specified ID and optional label. This API uses a ...@@ -293,15 +289,13 @@ Cancels a notification with the specified ID and optional label. This API uses a
**Example** **Example**
```js ```ts
Notification.cancel(0).then(() => { notificationManager.cancel(0).then(() => {
console.info("cancel success"); console.info("cancel success");
}); });
``` ```
## notificationManager.cancel
## Notification.cancel
cancel(id: number, callback: AsyncCallback\<void\>): void cancel(id: number, callback: AsyncCallback\<void\>): void
...@@ -327,7 +321,7 @@ Cancels a notification with the specified ID. This API uses an asynchronous call ...@@ -327,7 +321,7 @@ Cancels a notification with the specified ID. This API uses an asynchronous call
**Example** **Example**
```js ```ts
// cancel callback // cancel callback
function cancelCallback(err) { function cancelCallback(err) {
if (err) { if (err) {
...@@ -336,12 +330,10 @@ function cancelCallback(err) { ...@@ -336,12 +330,10 @@ function cancelCallback(err) {
console.info("cancel success"); console.info("cancel success");
} }
} }
Notification.cancel(0, cancelCallback) notificationManager.cancel(0, cancelCallback);
``` ```
## notificationManager.cancelAll
## Notification.cancelAll
cancelAll(callback: AsyncCallback\<void\>): void cancelAll(callback: AsyncCallback\<void\>): void
...@@ -365,7 +357,7 @@ Cancels all notifications. This API uses an asynchronous callback to return the ...@@ -365,7 +357,7 @@ Cancels all notifications. This API uses an asynchronous callback to return the
**Example** **Example**
```js ```ts
// cancel callback // cancel callback
function cancelAllCallback(err) { function cancelAllCallback(err) {
if (err) { if (err) {
...@@ -374,12 +366,10 @@ function cancelAllCallback(err) { ...@@ -374,12 +366,10 @@ function cancelAllCallback(err) {
console.info("cancelAll success"); console.info("cancelAll success");
} }
} }
Notification.cancelAll(cancelAllCallback) notificationManager.cancelAll(cancelAllCallback);
``` ```
## notificationManager.cancelAll
## Notification.cancelAll
cancelAll(): Promise\<void\> cancelAll(): Promise\<void\>
...@@ -397,15 +387,13 @@ Cancels all notifications. This API uses a promise to return the result. ...@@ -397,15 +387,13 @@ Cancels all notifications. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
Notification.cancelAll().then(() => { notificationManager.cancelAll().then(() => {
console.info("cancelAll success"); console.info("cancelAll success");
}); });
``` ```
## notificationManager.addSlot
## Notification.addSlot
addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void addSlot(slot: NotificationSlot, callback: AsyncCallback\<void\>): void
...@@ -434,7 +422,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r ...@@ -434,7 +422,7 @@ Adds a notification slot. This API uses an asynchronous callback to return the r
**Example** **Example**
```js ```ts
// addSlot callback // addSlot callback
function addSlotCallBack(err) { function addSlotCallBack(err) {
if (err) { if (err) {
...@@ -444,15 +432,13 @@ function addSlotCallBack(err) { ...@@ -444,15 +432,13 @@ function addSlotCallBack(err) {
} }
} }
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: notificationManager.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot, addSlotCallBack) notificationManager.addSlot(notificationSlot, addSlotCallBack);
``` ```
## notificationManager.addSlot
## Notification.addSlot
addSlot(slot: NotificationSlot): Promise\<void\> addSlot(slot: NotificationSlot): Promise\<void\>
...@@ -480,19 +466,17 @@ Adds a notification slot. This API uses a promise to return the result. ...@@ -480,19 +466,17 @@ Adds a notification slot. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: notificationManager.SlotType.SOCIAL_COMMUNICATION
} };
Notification.addSlot(notificationSlot).then(() => { notificationManager.addSlot(notificationSlot).then(() => {
console.info("addSlot success"); console.info("addSlot success");
}); });
``` ```
## notificationManager.addSlot
## Notification.addSlot
addSlot(type: SlotType, callback: AsyncCallback\<void\>): void addSlot(type: SlotType, callback: AsyncCallback\<void\>): void
...@@ -517,7 +501,7 @@ Adds a notification slot of a specified type. This API uses an asynchronous call ...@@ -517,7 +501,7 @@ Adds a notification slot of a specified type. This API uses an asynchronous call
**Example** **Example**
```js ```ts
// addSlot callback // addSlot callback
function addSlotCallBack(err) { function addSlotCallBack(err) {
if (err) { if (err) {
...@@ -526,12 +510,10 @@ function addSlotCallBack(err) { ...@@ -526,12 +510,10 @@ function addSlotCallBack(err) {
console.info("addSlot success"); console.info("addSlot success");
} }
} }
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
``` ```
## notificationManager.addSlot
## Notification.addSlot
addSlot(type: SlotType): Promise\<void\> addSlot(type: SlotType): Promise\<void\>
...@@ -555,15 +537,13 @@ Adds a notification slot of a specified type. This API uses a promise to return ...@@ -555,15 +537,13 @@ Adds a notification slot of a specified type. This API uses a promise to return
**Example** **Example**
```js ```ts
Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
console.info("addSlot success"); console.info("addSlot success");
}); });
``` ```
## notificationManager.addSlots
## Notification.addSlots
addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void addSlots(slots: Array\<NotificationSlot\>, callback: AsyncCallback\<void\>): void
...@@ -592,7 +572,7 @@ Adds an array of notification slots. This API uses an asynchronous callback to r ...@@ -592,7 +572,7 @@ Adds an array of notification slots. This API uses an asynchronous callback to r
**Example** **Example**
```js ```ts
// addSlots callback // addSlots callback
function addSlotsCallBack(err) { function addSlotsCallBack(err) {
if (err) { if (err) {
...@@ -602,19 +582,17 @@ function addSlotsCallBack(err) { ...@@ -602,19 +582,17 @@ function addSlotsCallBack(err) {
} }
} }
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: notificationManager.SlotType.SOCIAL_COMMUNICATION
} };
// NotificationSlotArray object // NotificationSlotArray object
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray, addSlotsCallBack) notificationManager.addSlots(notificationSlotArray, addSlotsCallBack);
``` ```
## notificationManager.addSlots
## Notification.addSlots
addSlots(slots: Array\<NotificationSlot\>): Promise\<void\> addSlots(slots: Array\<NotificationSlot\>): Promise\<void\>
...@@ -642,23 +620,21 @@ Adds an array of notification slots. This API uses a promise to return the resul ...@@ -642,23 +620,21 @@ Adds an array of notification slots. This API uses a promise to return the resul
**Example** **Example**
```js ```ts
// NotificationSlot object // NotificationSlot object
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: notificationManager.SlotType.SOCIAL_COMMUNICATION
} };
// NotificationSlotArray object // NotificationSlotArray object
var notificationSlotArray = new Array(); let notificationSlotArray = new Array();
notificationSlotArray[0] = notificationSlot; notificationSlotArray[0] = notificationSlot;
Notification.addSlots(notificationSlotArray).then(() => { notificationManager.addSlots(notificationSlotArray).then(() => {
console.info("addSlots success"); console.info("addSlots success");
}); });
``` ```
## notificationManager.getSlot
## Notification.getSlot
getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void getSlot(slotType: SlotType, callback: AsyncCallback\<NotificationSlot\>): void
...@@ -683,7 +659,7 @@ Obtains a notification slot of a specified type. This API uses an asynchronous c ...@@ -683,7 +659,7 @@ Obtains a notification slot of a specified type. This API uses an asynchronous c
**Example** **Example**
```js ```ts
// getSlot callback // getSlot callback
function getSlotCallback(err,data) { function getSlotCallback(err,data) {
if (err) { if (err) {
...@@ -692,13 +668,11 @@ function getSlotCallback(err,data) { ...@@ -692,13 +668,11 @@ function getSlotCallback(err,data) {
console.info("getSlot success"); console.info("getSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType, getSlotCallback) notificationManager.getSlot(slotType, getSlotCallback);
``` ```
## notificationManager.getSlot
## Notification.getSlot
getSlot(slotType: SlotType): Promise\<NotificationSlot\> getSlot(slotType: SlotType): Promise\<NotificationSlot\>
...@@ -728,16 +702,14 @@ Obtains a notification slot of a specified type. This API uses a promise to retu ...@@ -728,16 +702,14 @@ Obtains a notification slot of a specified type. This API uses a promise to retu
**Example** **Example**
```js ```ts
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
Notification.getSlot(slotType).then((data) => { notificationManager.getSlot(slotType).then((data) => {
console.info("getSlot success, data: " + JSON.stringify(data)); console.info("getSlot success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.getSlots
## Notification.getSlots
getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlots(callback: AsyncCallback<Array\<NotificationSlot\>>): void
...@@ -761,7 +733,7 @@ Obtains all notification slots of this application. This API uses an asynchronou ...@@ -761,7 +733,7 @@ Obtains all notification slots of this application. This API uses an asynchronou
**Example** **Example**
```js ```ts
// getSlots callback // getSlots callback
function getSlotsCallback(err,data) { function getSlotsCallback(err,data) {
if (err) { if (err) {
...@@ -770,12 +742,10 @@ function getSlotsCallback(err,data) { ...@@ -770,12 +742,10 @@ function getSlotsCallback(err,data) {
console.info("getSlots success"); console.info("getSlots success");
} }
} }
Notification.getSlots(getSlotsCallback) notificationManager.getSlots(getSlotsCallback);
``` ```
## notificationManager.getSlots
## Notification.getSlots
getSlots(): Promise\<Array\<NotificationSlot\>> getSlots(): Promise\<Array\<NotificationSlot\>>
...@@ -799,15 +769,13 @@ Obtains all notification slots of this application. This API uses a promise to r ...@@ -799,15 +769,13 @@ Obtains all notification slots of this application. This API uses a promise to r
**Example** **Example**
```js ```ts
Notification.getSlots().then((data) => { notificationManager.getSlots().then((data) => {
console.info("getSlots success, data: " + JSON.stringify(data)); console.info("getSlots success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.removeSlot
## Notification.removeSlot
removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void removeSlot(slotType: SlotType, callback: AsyncCallback\<void\>): void
...@@ -832,7 +800,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c ...@@ -832,7 +800,7 @@ Removes a notification slot of a specified type. This API uses an asynchronous c
**Example** **Example**
```js ```ts
// removeSlot callback // removeSlot callback
function removeSlotCallback(err) { function removeSlotCallback(err) {
if (err) { if (err) {
...@@ -841,13 +809,11 @@ function removeSlotCallback(err) { ...@@ -841,13 +809,11 @@ function removeSlotCallback(err) {
console.info("removeSlot success"); console.info("removeSlot success");
} }
} }
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType,removeSlotCallback) notificationManager.removeSlot(slotType,removeSlotCallback);
``` ```
## notificationManager.removeSlot
## Notification.removeSlot
removeSlot(slotType: SlotType): Promise\<void\> removeSlot(slotType: SlotType): Promise\<void\>
...@@ -871,16 +837,14 @@ Removes a notification slot of a specified type. This API uses a promise to retu ...@@ -871,16 +837,14 @@ Removes a notification slot of a specified type. This API uses a promise to retu
**Example** **Example**
```js ```ts
var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; let slotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
Notification.removeSlot(slotType).then(() => { notificationManager.removeSlot(slotType).then(() => {
console.info("removeSlot success"); console.info("removeSlot success");
}); });
``` ```
## notificationManager.removeAllSlots
## Notification.removeAllSlots
removeAllSlots(callback: AsyncCallback\<void\>): void removeAllSlots(callback: AsyncCallback\<void\>): void
...@@ -904,7 +868,7 @@ Removes all notification slots. This API uses an asynchronous callback to return ...@@ -904,7 +868,7 @@ Removes all notification slots. This API uses an asynchronous callback to return
**Example** **Example**
```js ```ts
function removeAllCallBack(err) { function removeAllCallBack(err) {
if (err) { if (err) {
console.info("removeAllSlots failed " + JSON.stringify(err)); console.info("removeAllSlots failed " + JSON.stringify(err));
...@@ -912,12 +876,10 @@ function removeAllCallBack(err) { ...@@ -912,12 +876,10 @@ function removeAllCallBack(err) {
console.info("removeAllSlots success"); console.info("removeAllSlots success");
} }
} }
Notification.removeAllSlots(removeAllCallBack) notificationManager.removeAllSlots(removeAllCallBack);
``` ```
## notificationManager.removeAllSlots
## Notification.removeAllSlots
removeAllSlots(): Promise\<void\> removeAllSlots(): Promise\<void\>
...@@ -935,15 +897,13 @@ Removes all notification slots. This API uses a promise to return the result. ...@@ -935,15 +897,13 @@ Removes all notification slots. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
Notification.removeAllSlots().then(() => { notificationManager.removeAllSlots().then(() => {
console.info("removeAllSlots success"); console.info("removeAllSlots success");
}); });
``` ```
## notificationManager.setNotificationEnable
## Notification.setNotificationEnable
setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
...@@ -974,7 +934,7 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -974,7 +934,7 @@ Sets whether to enable notification for a specified application. This API uses a
**Example** **Example**
```js ```ts
function setNotificationEnablenCallback(err) { function setNotificationEnablenCallback(err) {
if (err) { if (err) {
console.info("setNotificationEnablenCallback failed " + JSON.stringify(err)); console.info("setNotificationEnablenCallback failed " + JSON.stringify(err));
...@@ -982,15 +942,13 @@ function setNotificationEnablenCallback(err) { ...@@ -982,15 +942,13 @@ function setNotificationEnablenCallback(err) {
console.info("setNotificationEnablenCallback success"); console.info("setNotificationEnablenCallback success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.setNotificationEnable(bundle, false, setNotificationEnablenCallback); notificationManager.setNotificationEnable(bundle, false, setNotificationEnablenCallback);
``` ```
## notificationManager.setNotificationEnable
## Notification.setNotificationEnable
setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\> setNotificationEnable(bundle: BundleOption, enable: boolean): Promise\<void\>
...@@ -1020,18 +978,16 @@ Sets whether to enable notification for a specified application. This API uses a ...@@ -1020,18 +978,16 @@ Sets whether to enable notification for a specified application. This API uses a
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.setNotificationEnable(bundle, false).then(() => { notificationManager.setNotificationEnable(bundle, false).then(() => {
console.info("setNotificationEnable success"); console.info("setNotificationEnable success");
}); });
``` ```
## notificationManager.isNotificationEnabled
## Notification.isNotificationEnabled
isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
...@@ -1061,7 +1017,7 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1061,7 +1017,7 @@ Checks whether notification is enabled for a specified application. This API use
**Example** **Example**
```js ```ts
function isNotificationEnabledCallback(err, data) { function isNotificationEnabledCallback(err, data) {
if (err) { if (err) {
console.info("isNotificationEnabled failed " + JSON.stringify(err)); console.info("isNotificationEnabled failed " + JSON.stringify(err));
...@@ -1069,15 +1025,13 @@ function isNotificationEnabledCallback(err, data) { ...@@ -1069,15 +1025,13 @@ function isNotificationEnabledCallback(err, data) {
console.info("isNotificationEnabled success"); console.info("isNotificationEnabled success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); notificationManager.isNotificationEnabled(bundle, isNotificationEnabledCallback);
``` ```
## notificationManager.isNotificationEnabled
## Notification.isNotificationEnabled
isNotificationEnabled(bundle: BundleOption): Promise\<boolean\> isNotificationEnabled(bundle: BundleOption): Promise\<boolean\>
...@@ -1112,18 +1066,16 @@ Checks whether notification is enabled for a specified application. This API use ...@@ -1112,18 +1066,16 @@ Checks whether notification is enabled for a specified application. This API use
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isNotificationEnabled(bundle).then((data) => { notificationManager.isNotificationEnabled(bundle).then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.isNotificationEnabled
## Notification.isNotificationEnabled
isNotificationEnabled(callback: AsyncCallback\<boolean\>): void isNotificationEnabled(callback: AsyncCallback\<boolean\>): void
...@@ -1151,7 +1103,7 @@ Checks whether notification is enabled for this application. This API uses an as ...@@ -1151,7 +1103,7 @@ Checks whether notification is enabled for this application. This API uses an as
**Example** **Example**
```js ```ts
function isNotificationEnabledCallback(err, data) { function isNotificationEnabledCallback(err, data) {
if (err) { if (err) {
console.info("isNotificationEnabled failed " + JSON.stringify(err)); console.info("isNotificationEnabled failed " + JSON.stringify(err));
...@@ -1160,12 +1112,10 @@ function isNotificationEnabledCallback(err, data) { ...@@ -1160,12 +1112,10 @@ function isNotificationEnabledCallback(err, data) {
} }
} }
Notification.isNotificationEnabled(isNotificationEnabledCallback); notificationManager.isNotificationEnabled(isNotificationEnabledCallback);
``` ```
## notificationManager.isNotificationEnabled
## Notification.isNotificationEnabled
isNotificationEnabled(): Promise\<boolean\> isNotificationEnabled(): Promise\<boolean\>
...@@ -1200,15 +1150,13 @@ Checks whether notification is enabled for the current application. This API use ...@@ -1200,15 +1150,13 @@ Checks whether notification is enabled for the current application. This API use
**Example** **Example**
```js ```ts
Notification.isNotificationEnabled().then((data) => { notificationManager.isNotificationEnabled().then((data) => {
console.info("isNotificationEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.displayBadge
## Notification.displayBadge
displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void\>): void
...@@ -1239,7 +1187,7 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1239,7 +1187,7 @@ Sets whether to enable the notification badge for a specified application. This
**Example** **Example**
```js ```ts
function displayBadgeCallback(err) { function displayBadgeCallback(err) {
if (err) { if (err) {
console.info("displayBadge failed " + JSON.stringify(err)); console.info("displayBadge failed " + JSON.stringify(err));
...@@ -1247,15 +1195,13 @@ function displayBadgeCallback(err) { ...@@ -1247,15 +1195,13 @@ function displayBadgeCallback(err) {
console.info("displayBadge success"); console.info("displayBadge success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false, displayBadgeCallback); notificationManager.displayBadge(bundle, false, displayBadgeCallback);
``` ```
## notificationManager.displayBadge
## Notification.displayBadge
displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\> displayBadge(bundle: BundleOption, enable: boolean): Promise\<void\>
...@@ -1285,18 +1231,16 @@ Sets whether to enable the notification badge for a specified application. This ...@@ -1285,18 +1231,16 @@ Sets whether to enable the notification badge for a specified application. This
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.displayBadge(bundle, false).then(() => { notificationManager.displayBadge(bundle, false).then(() => {
console.info("displayBadge success"); console.info("displayBadge success");
}); });
``` ```
## notificationManager.isBadgeDisplayed
## Notification.isBadgeDisplayed
isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\<boolean\>): void
...@@ -1326,7 +1270,7 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1326,7 +1270,7 @@ Checks whether the notification badge is enabled for a specified application. Th
**Example** **Example**
```js ```ts
function isBadgeDisplayedCallback(err, data) { function isBadgeDisplayedCallback(err, data) {
if (err) { if (err) {
console.info("isBadgeDisplayed failed " + JSON.stringify(err)); console.info("isBadgeDisplayed failed " + JSON.stringify(err));
...@@ -1334,15 +1278,13 @@ function isBadgeDisplayedCallback(err, data) { ...@@ -1334,15 +1278,13 @@ function isBadgeDisplayedCallback(err, data) {
console.info("isBadgeDisplayed success"); console.info("isBadgeDisplayed success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); notificationManager.isBadgeDisplayed(bundle, isBadgeDisplayedCallback);
``` ```
## notificationManager.isBadgeDisplayed
## Notification.isBadgeDisplayed
isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\> isBadgeDisplayed(bundle: BundleOption): Promise\<boolean\>
...@@ -1377,18 +1319,16 @@ Checks whether the notification badge is enabled for a specified application. Th ...@@ -1377,18 +1319,16 @@ Checks whether the notification badge is enabled for a specified application. Th
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isBadgeDisplayed(bundle).then((data) => { notificationManager.isBadgeDisplayed(bundle).then((data) => {
console.info("isBadgeDisplayed success, data: " + JSON.stringify(data)); console.info("isBadgeDisplayed success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.setSlotByBundle
## Notification.setSlotByBundle
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\<void\>): void
...@@ -1417,11 +1357,9 @@ Sets the notification slot for a specified application. This API uses an asynchr ...@@ -1417,11 +1357,9 @@ Sets the notification slot for a specified application. This API uses an asynchr
| 1600003 | Failed to connect service. | | 1600003 | Failed to connect service. |
| 17700001 | The specified bundle name was not found. | | 17700001 | The specified bundle name was not found. |
**Example** **Example**
```js ```ts
function setSlotByBundleCallback(err) { function setSlotByBundleCallback(err) {
if (err) { if (err) {
console.info("setSlotByBundle failed " + JSON.stringify(err)); console.info("setSlotByBundle failed " + JSON.stringify(err));
...@@ -1429,18 +1367,16 @@ function setSlotByBundleCallback(err) { ...@@ -1429,18 +1367,16 @@ function setSlotByBundleCallback(err) {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: notificationManager.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); notificationManager.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback);
``` ```
## notificationManager.setSlotByBundle
## Notification.setSlotByBundle
setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\> setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\<void\>
...@@ -1470,21 +1406,19 @@ Sets the notification slot for a specified application. This API uses a promise ...@@ -1470,21 +1406,19 @@ Sets the notification slot for a specified application. This API uses a promise
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationSlot = { let notificationSlot = {
type: Notification.SlotType.SOCIAL_COMMUNICATION type: notificationManager.SlotType.SOCIAL_COMMUNICATION
} };
Notification.setSlotByBundle(bundle, notificationSlot).then(() => { notificationManager.setSlotByBundle(bundle, notificationSlot).then(() => {
console.info("setSlotByBundle success"); console.info("setSlotByBundle success");
}); });
``` ```
## notificationManager.getSlotsByBundle
## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback<Array\<NotificationSlot\>>): void
...@@ -1514,7 +1448,7 @@ Obtains the notification slots of a specified application. This API uses an asyn ...@@ -1514,7 +1448,7 @@ Obtains the notification slots of a specified application. This API uses an asyn
**Example** **Example**
```js ```ts
function getSlotsByBundleCallback(err, data) { function getSlotsByBundleCallback(err, data) {
if (err) { if (err) {
console.info("getSlotsByBundle failed " + JSON.stringify(err)); console.info("getSlotsByBundle failed " + JSON.stringify(err));
...@@ -1522,15 +1456,13 @@ function getSlotsByBundleCallback(err, data) { ...@@ -1522,15 +1456,13 @@ function getSlotsByBundleCallback(err, data) {
console.info("getSlotsByBundle success"); console.info("getSlotsByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); notificationManager.getSlotsByBundle(bundle, getSlotsByBundleCallback);
``` ```
## notificationManager.getSlotsByBundle
## Notification.getSlotsByBundle
getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>> getSlotsByBundle(bundle: BundleOption): Promise<Array\<NotificationSlot\>>
...@@ -1565,18 +1497,16 @@ Obtains the notification slots of a specified application. This API uses a promi ...@@ -1565,18 +1497,16 @@ Obtains the notification slots of a specified application. This API uses a promi
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotsByBundle(bundle).then((data) => { notificationManager.getSlotsByBundle(bundle).then((data) => {
console.info("getSlotsByBundle success, data: " + JSON.stringify(data)); console.info("getSlotsByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.getSlotNumByBundle
## Notification.getSlotNumByBundle
getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\<number\>): void
...@@ -1606,7 +1536,7 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1606,7 +1536,7 @@ Obtains the number of notification slots of a specified application. This API us
**Example** **Example**
```js ```ts
function getSlotNumByBundleCallback(err, data) { function getSlotNumByBundleCallback(err, data) {
if (err) { if (err) {
console.info("getSlotNumByBundle failed " + JSON.stringify(err)); console.info("getSlotNumByBundle failed " + JSON.stringify(err));
...@@ -1614,15 +1544,13 @@ function getSlotNumByBundleCallback(err, data) { ...@@ -1614,15 +1544,13 @@ function getSlotNumByBundleCallback(err, data) {
console.info("getSlotNumByBundle success"); console.info("getSlotNumByBundle success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); notificationManager.getSlotNumByBundle(bundle, getSlotNumByBundleCallback);
``` ```
## notificationManager.getSlotNumByBundle
## Notification.getSlotNumByBundle
getSlotNumByBundle(bundle: BundleOption): Promise\<number\> getSlotNumByBundle(bundle: BundleOption): Promise\<number\>
...@@ -1657,19 +1585,17 @@ Obtains the number of notification slots of a specified application. This API us ...@@ -1657,19 +1585,17 @@ Obtains the number of notification slots of a specified application. This API us
**Example** **Example**
```js ```ts
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.getSlotNumByBundle(bundle).then((data) => { notificationManager.getSlotNumByBundle(bundle).then((data) => {
console.info("getSlotNumByBundle success, data: " + JSON.stringify(data)); console.info("getSlotNumByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.getAllActiveNotifications
## Notification.getAllActiveNotifications
getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getAllActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
...@@ -1697,7 +1623,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu ...@@ -1697,7 +1623,7 @@ Obtains all active notifications. This API uses an asynchronous callback to retu
**Example** **Example**
```js ```ts
function getAllActiveNotificationsCallback(err, data) { function getAllActiveNotificationsCallback(err, data) {
if (err) { if (err) {
console.info("getAllActiveNotifications failed " + JSON.stringify(err)); console.info("getAllActiveNotifications failed " + JSON.stringify(err));
...@@ -1706,12 +1632,10 @@ function getAllActiveNotificationsCallback(err, data) { ...@@ -1706,12 +1632,10 @@ function getAllActiveNotificationsCallback(err, data) {
} }
} }
Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); notificationManager.getAllActiveNotifications(getAllActiveNotificationsCallback);
``` ```
## notificationManager.getAllActiveNotifications
## Notification.getAllActiveNotifications
getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getAllActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
...@@ -1739,15 +1663,13 @@ Obtains all active notifications. This API uses a promise to return the result. ...@@ -1739,15 +1663,13 @@ Obtains all active notifications. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
Notification.getAllActiveNotifications().then((data) => { notificationManager.getAllActiveNotifications().then((data) => {
console.info("getAllActiveNotifications success, data: " + JSON.stringify(data)); console.info("getAllActiveNotifications success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.getActiveNotificationCount
## Notification.getActiveNotificationCount
getActiveNotificationCount(callback: AsyncCallback\<number\>): void getActiveNotificationCount(callback: AsyncCallback\<number\>): void
...@@ -1771,7 +1693,7 @@ Obtains the number of active notifications of this application. This API uses an ...@@ -1771,7 +1693,7 @@ Obtains the number of active notifications of this application. This API uses an
**Example** **Example**
```js ```ts
function getActiveNotificationCountCallback(err, data) { function getActiveNotificationCountCallback(err, data) {
if (err) { if (err) {
console.info("getActiveNotificationCount failed " + JSON.stringify(err)); console.info("getActiveNotificationCount failed " + JSON.stringify(err));
...@@ -1780,12 +1702,10 @@ function getActiveNotificationCountCallback(err, data) { ...@@ -1780,12 +1702,10 @@ function getActiveNotificationCountCallback(err, data) {
} }
} }
Notification.getActiveNotificationCount(getActiveNotificationCountCallback); notificationManager.getActiveNotificationCount(getActiveNotificationCountCallback);
``` ```
## notificationManager.getActiveNotificationCount
## Notification.getActiveNotificationCount
getActiveNotificationCount(): Promise\<number\> getActiveNotificationCount(): Promise\<number\>
...@@ -1809,15 +1729,13 @@ Obtains the number of active notifications of this application. This API uses a ...@@ -1809,15 +1729,13 @@ Obtains the number of active notifications of this application. This API uses a
**Example** **Example**
```js ```ts
Notification.getActiveNotificationCount().then((data) => { notificationManager.getActiveNotificationCount().then((data) => {
console.info("getActiveNotificationCount success, data: " + JSON.stringify(data)); console.info("getActiveNotificationCount success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.getActiveNotifications
## Notification.getActiveNotifications
getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void getActiveNotifications(callback: AsyncCallback<Array\<NotificationRequest\>>): void
...@@ -1841,7 +1759,7 @@ Obtains active notifications of this application. This API uses an asynchronous ...@@ -1841,7 +1759,7 @@ Obtains active notifications of this application. This API uses an asynchronous
**Example** **Example**
```js ```ts
function getActiveNotificationsCallback(err, data) { function getActiveNotificationsCallback(err, data) {
if (err) { if (err) {
console.info("getActiveNotifications failed " + JSON.stringify(err)); console.info("getActiveNotifications failed " + JSON.stringify(err));
...@@ -1850,12 +1768,10 @@ function getActiveNotificationsCallback(err, data) { ...@@ -1850,12 +1768,10 @@ function getActiveNotificationsCallback(err, data) {
} }
} }
Notification.getActiveNotifications(getActiveNotificationsCallback); notificationManager.getActiveNotifications(getActiveNotificationsCallback);
``` ```
## notificationManager.getActiveNotifications
## Notification.getActiveNotifications
getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\> getActiveNotifications(): Promise\<Array\<[NotificationRequest](#notificationrequest)\>\>
...@@ -1879,15 +1795,13 @@ Obtains active notifications of this application. This API uses a promise to ret ...@@ -1879,15 +1795,13 @@ Obtains active notifications of this application. This API uses a promise to ret
**Example** **Example**
```js ```ts
Notification.getActiveNotifications().then((data) => { notificationManager.getActiveNotifications().then((data) => {
console.info("removeGroupByBundle success, data: " + JSON.stringify(data)); console.info("removeGroupByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.cancelGroup
## Notification.cancelGroup
cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void cancelGroup(groupName: string, callback: AsyncCallback\<void\>): void
...@@ -1912,7 +1826,7 @@ Cancels notifications under a notification group of this application. This API u ...@@ -1912,7 +1826,7 @@ Cancels notifications under a notification group of this application. This API u
**Example** **Example**
```js ```ts
function cancelGroupCallback(err) { function cancelGroupCallback(err) {
if (err) { if (err) {
console.info("cancelGroup failed " + JSON.stringify(err)); console.info("cancelGroup failed " + JSON.stringify(err));
...@@ -1921,14 +1835,12 @@ function cancelGroupCallback(err) { ...@@ -1921,14 +1835,12 @@ function cancelGroupCallback(err) {
} }
} }
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName, cancelGroupCallback); notificationManager.cancelGroup(groupName, cancelGroupCallback);
``` ```
## notificationManager.cancelGroup
## Notification.cancelGroup
cancelGroup(groupName: string): Promise\<void\> cancelGroup(groupName: string): Promise\<void\>
...@@ -1952,16 +1864,14 @@ Cancels notifications under a notification group of this application. This API u ...@@ -1952,16 +1864,14 @@ Cancels notifications under a notification group of this application. This API u
**Example** **Example**
```js ```ts
var groupName = "GroupName"; let groupName = "GroupName";
Notification.cancelGroup(groupName).then(() => { notificationManager.cancelGroup(groupName).then(() => {
console.info("cancelGroup success"); console.info("cancelGroup success");
}); });
``` ```
## notificationManager.removeGroupByBundle
## Notification.removeGroupByBundle
removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\<void\>): void
...@@ -1992,7 +1902,7 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -1992,7 +1902,7 @@ Removes notifications under a notification group of a specified application. Thi
**Example** **Example**
```js ```ts
function removeGroupByBundleCallback(err) { function removeGroupByBundleCallback(err) {
if (err) { if (err) {
console.info("removeGroupByBundle failed " + JSON.stringify(err)); console.info("removeGroupByBundle failed " + JSON.stringify(err));
...@@ -2001,15 +1911,13 @@ function removeGroupByBundleCallback(err) { ...@@ -2001,15 +1911,13 @@ function removeGroupByBundleCallback(err) {
} }
} }
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); notificationManager.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback);
``` ```
## notificationManager.removeGroupByBundle
## Notification.removeGroupByBundle
removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\> removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\<void\>
...@@ -2039,17 +1947,15 @@ Removes notifications under a notification group of a specified application. Thi ...@@ -2039,17 +1947,15 @@ Removes notifications under a notification group of a specified application. Thi
**Example** **Example**
```js ```ts
var bundleOption = {bundle: "Bundle"}; let bundleOption = {bundle: "Bundle"};
var groupName = "GroupName"; let groupName = "GroupName";
Notification.removeGroupByBundle(bundleOption, groupName).then(() => { notificationManager.removeGroupByBundle(bundleOption, groupName).then(() => {
console.info("removeGroupByBundle success"); console.info("removeGroupByBundle success");
}); });
``` ```
## notificationManager.setDoNotDisturbDate
## Notification.setDoNotDisturbDate
setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\<void\>): void
...@@ -2078,7 +1984,7 @@ Sets the DND time. This API uses an asynchronous callback to return the result. ...@@ -2078,7 +1984,7 @@ Sets the DND time. This API uses an asynchronous callback to return the result.
**Example** **Example**
```js ```ts
function setDoNotDisturbDateCallback(err) { function setDoNotDisturbDateCallback(err) {
if (err) { if (err) {
console.info("setDoNotDisturbDate failed " + JSON.stringify(err)); console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
...@@ -2087,18 +1993,16 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2087,18 +1993,16 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: notificationManager.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); notificationManager.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback);
``` ```
## notificationManager.setDoNotDisturbDate
## Notification.setDoNotDisturbDate
setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\> setDoNotDisturbDate(date: DoNotDisturbDate): Promise\<void\>
...@@ -2126,19 +2030,19 @@ Sets the DND time. This API uses a promise to return the result. ...@@ -2126,19 +2030,19 @@ Sets the DND time. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: notificationManager.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { notificationManager.setDoNotDisturbDate(doNotDisturbDate).then(() => {
console.info("setDoNotDisturbDate success"); console.info("setDoNotDisturbDate success");
}); });
``` ```
## Notification.setDoNotDisturbDate ## notificationManager.setDoNotDisturbDate
setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\<void\>): void
...@@ -2169,7 +2073,7 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t ...@@ -2169,7 +2073,7 @@ Sets the DND time for a specified user. This API uses an asynchronous callback t
**Example** **Example**
```js ```ts
function setDoNotDisturbDateCallback(err) { function setDoNotDisturbDateCallback(err) {
if (err) { if (err) {
console.info("setDoNotDisturbDate failed " + JSON.stringify(err)); console.info("setDoNotDisturbDate failed " + JSON.stringify(err));
...@@ -2178,20 +2082,18 @@ function setDoNotDisturbDateCallback(err) { ...@@ -2178,20 +2082,18 @@ function setDoNotDisturbDateCallback(err) {
} }
} }
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: notificationManager.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback);
``` ```
## notificationManager.setDoNotDisturbDate
## Notification.setDoNotDisturbDate
setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\> setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\<void\>
...@@ -2221,22 +2123,22 @@ Sets the DND time for a specified user. This API uses a promise to return the re ...@@ -2221,22 +2123,22 @@ Sets the DND time for a specified user. This API uses a promise to return the re
**Example** **Example**
```js ```ts
var doNotDisturbDate = { let doNotDisturbDate = {
type: Notification.DoNotDisturbType.TYPE_ONCE, type: notificationManager.DoNotDisturbType.TYPE_ONCE,
begin: new Date(), begin: new Date(),
end: new Date(2021, 11, 15, 18, 0) end: new Date(2021, 11, 15, 18, 0)
} };
var userId = 1 let userId = 1;
Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { notificationManager.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => {
console.info("setDoNotDisturbDate success"); console.info("setDoNotDisturbDate success");
}); });
``` ```
## Notification.getDoNotDisturbDate ## notificationManager.getDoNotDisturbDate
getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void getDoNotDisturbDate(callback: AsyncCallback\<DoNotDisturbDate\>): void
...@@ -2264,7 +2166,7 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul ...@@ -2264,7 +2166,7 @@ Obtains the DND time. This API uses an asynchronous callback to return the resul
**Example** **Example**
```js ```ts
function getDoNotDisturbDateCallback(err,data) { function getDoNotDisturbDateCallback(err,data) {
if (err) { if (err) {
console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
...@@ -2273,12 +2175,10 @@ function getDoNotDisturbDateCallback(err,data) { ...@@ -2273,12 +2175,10 @@ function getDoNotDisturbDateCallback(err,data) {
} }
} }
Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); notificationManager.getDoNotDisturbDate(getDoNotDisturbDateCallback);
``` ```
## notificationManager.getDoNotDisturbDate
## Notification.getDoNotDisturbDate
getDoNotDisturbDate(): Promise\<DoNotDisturbDate\> getDoNotDisturbDate(): Promise\<DoNotDisturbDate\>
...@@ -2306,14 +2206,14 @@ Obtains the DND time. This API uses a promise to return the result. ...@@ -2306,14 +2206,14 @@ Obtains the DND time. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
Notification.getDoNotDisturbDate().then((data) => { notificationManager.getDoNotDisturbDate().then((data) => {
console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
}); });
``` ```
## Notification.getDoNotDisturbDate ## notificationManager.getDoNotDisturbDate
getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void getDoNotDisturbDate(userId: number, callback: AsyncCallback\<DoNotDisturbDate\>): void
...@@ -2343,7 +2243,7 @@ Obtains the DND time of a specified user. This API uses an asynchronous callback ...@@ -2343,7 +2243,7 @@ Obtains the DND time of a specified user. This API uses an asynchronous callback
**Example** **Example**
```js ```ts
function getDoNotDisturbDateCallback(err,data) { function getDoNotDisturbDateCallback(err,data) {
if (err) { if (err) {
console.info("getDoNotDisturbDate failed " + JSON.stringify(err)); console.info("getDoNotDisturbDate failed " + JSON.stringify(err));
...@@ -2352,14 +2252,12 @@ function getDoNotDisturbDateCallback(err,data) { ...@@ -2352,14 +2252,12 @@ function getDoNotDisturbDateCallback(err,data) {
} }
} }
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); notificationManager.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback);
``` ```
## notificationManager.getDoNotDisturbDate
## Notification.getDoNotDisturbDate
getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\> getDoNotDisturbDate(userId: number): Promise\<DoNotDisturbDate\>
...@@ -2394,16 +2292,16 @@ Obtains the DND time of a specified user. This API uses a promise to return the ...@@ -2394,16 +2292,16 @@ Obtains the DND time of a specified user. This API uses a promise to return the
**Example** **Example**
```js ```ts
var userId = 1 let userId = 1;
Notification.getDoNotDisturbDate(userId).then((data) => { notificationManager.getDoNotDisturbDate(userId).then((data) => {
console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data)); console.info("getDoNotDisturbDate success, data: " + JSON.stringify(data));
}); });
``` ```
## Notification.supportDoNotDisturbMode ## notificationManager.supportDoNotDisturbMode
supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void supportDoNotDisturbMode(callback: AsyncCallback\<boolean\>): void
...@@ -2431,7 +2329,7 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to ...@@ -2431,7 +2329,7 @@ Checks whether DND mode is supported. This API uses an asynchronous callback to
**Example** **Example**
```js ```ts
function supportDoNotDisturbModeCallback(err,data) { function supportDoNotDisturbModeCallback(err,data) {
if (err) { if (err) {
console.info("supportDoNotDisturbMode failed " + JSON.stringify(err)); console.info("supportDoNotDisturbMode failed " + JSON.stringify(err));
...@@ -2440,12 +2338,10 @@ function supportDoNotDisturbModeCallback(err,data) { ...@@ -2440,12 +2338,10 @@ function supportDoNotDisturbModeCallback(err,data) {
} }
} }
Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); notificationManager.supportDoNotDisturbMode(supportDoNotDisturbModeCallback);
``` ```
## notificationManager.supportDoNotDisturbMode
## Notification.supportDoNotDisturbMode
supportDoNotDisturbMode(): Promise\<boolean\> supportDoNotDisturbMode(): Promise\<boolean\>
...@@ -2473,15 +2369,13 @@ Checks whether DND mode is supported. This API uses a promise to return the resu ...@@ -2473,15 +2369,13 @@ Checks whether DND mode is supported. This API uses a promise to return the resu
**Example** **Example**
```js ```ts
Notification.supportDoNotDisturbMode().then((data) => { notificationManager.supportDoNotDisturbMode().then((data) => {
console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data)); console.info("supportDoNotDisturbMode success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.isSupportTemplate
## Notification.isSupportTemplate
isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void isSupportTemplate(templateName: string, callback: AsyncCallback\<boolean\>): void
...@@ -2508,7 +2402,7 @@ Checks whether a specified template is supported. This API uses an asynchronous ...@@ -2508,7 +2402,7 @@ Checks whether a specified template is supported. This API uses an asynchronous
**Example** **Example**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
function isSupportTemplateCallback(err, data) { function isSupportTemplateCallback(err, data) {
if (err) { if (err) {
console.info("isSupportTemplate failed " + JSON.stringify(err)); console.info("isSupportTemplate failed " + JSON.stringify(err));
...@@ -2517,12 +2411,10 @@ function isSupportTemplateCallback(err, data) { ...@@ -2517,12 +2411,10 @@ function isSupportTemplateCallback(err, data) {
} }
} }
Notification.isSupportTemplate(templateName, isSupportTemplateCallback); notificationManager.isSupportTemplate(templateName, isSupportTemplateCallback);
``` ```
## notificationManager.isSupportTemplate
## Notification.isSupportTemplate
isSupportTemplate(templateName: string): Promise\<boolean\> isSupportTemplate(templateName: string): Promise\<boolean\>
...@@ -2554,16 +2446,14 @@ Checks whether a specified template is supported. This API uses a promise to ret ...@@ -2554,16 +2446,14 @@ Checks whether a specified template is supported. This API uses a promise to ret
**Example** **Example**
```javascript ```javascript
var templateName = 'process'; let templateName = 'process';
Notification.isSupportTemplate(templateName).then((data) => { notificationManager.isSupportTemplate(templateName).then((data) => {
console.info("isSupportTemplate success, data: " + JSON.stringify(data)); console.info("isSupportTemplate success, data: " + JSON.stringify(data));
}); });
``` ```
## notificationManager.requestEnableNotification
## Notification.requestEnableNotification
requestEnableNotification(callback: AsyncCallback\<void\>): void requestEnableNotification(callback: AsyncCallback\<void\>): void
...@@ -2596,12 +2486,10 @@ function requestEnableNotificationCallback(err) { ...@@ -2596,12 +2486,10 @@ function requestEnableNotificationCallback(err) {
} }
}; };
Notification.requestEnableNotification(requestEnableNotificationCallback); notificationManager.requestEnableNotification(requestEnableNotificationCallback);
``` ```
## notificationManager.requestEnableNotification
## Notification.requestEnableNotification
requestEnableNotification(): Promise\<void\> requestEnableNotification(): Promise\<void\>
...@@ -2620,14 +2508,14 @@ Requests notification to be enabled for this application. This API uses a promis ...@@ -2620,14 +2508,14 @@ Requests notification to be enabled for this application. This API uses a promis
**Example** **Example**
```javascript ```javascript
Notification.requestEnableNotification().then(() => { notificationManager.requestEnableNotification().then(() => {
console.info("requestEnableNotification success"); console.info("requestEnableNotification success");
}); });
``` ```
## Notification.setDistributedEnable ## notificationManager.setDistributedEnable
setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void setDistributedEnable(enable: boolean, callback: AsyncCallback\<void\>): void
...@@ -2666,14 +2554,12 @@ function setDistributedEnableCallback() { ...@@ -2666,14 +2554,12 @@ function setDistributedEnableCallback() {
} }
}; };
var enable = true let enable = true;
Notification.setDistributedEnable(enable, setDistributedEnableCallback); notificationManager.setDistributedEnable(enable, setDistributedEnableCallback);
``` ```
## notificationManager.setDistributedEnable
## Notification.setDistributedEnable
setDistributedEnable(enable: boolean): Promise\<void> setDistributedEnable(enable: boolean): Promise\<void>
...@@ -2703,15 +2589,15 @@ Sets whether this device supports distributed notifications. This API uses a pro ...@@ -2703,15 +2589,15 @@ Sets whether this device supports distributed notifications. This API uses a pro
**Example** **Example**
```javascript ```javascript
var enable = true let enable = true;
Notification.setDistributedEnable(enable).then(() => { notificationManager.setDistributedEnable(enable).then(() => {
console.info("setDistributedEnable success"); console.info("setDistributedEnable success");
}); });
``` ```
## Notification.isDistributedEnabled ## notificationManager.isDistributedEnabled
isDistributedEnabled(callback: AsyncCallback\<boolean>): void isDistributedEnabled(callback: AsyncCallback\<boolean>): void
...@@ -2745,12 +2631,12 @@ function isDistributedEnabledCallback(err, data) { ...@@ -2745,12 +2631,12 @@ function isDistributedEnabledCallback(err, data) {
} }
}; };
Notification.isDistributedEnabled(isDistributedEnabledCallback); notificationManager.isDistributedEnabled(isDistributedEnabledCallback);
``` ```
## Notification.isDistributedEnabled ## notificationManager.isDistributedEnabled
isDistributedEnabled(): Promise\<boolean> isDistributedEnabled(): Promise\<boolean>
...@@ -2776,14 +2662,14 @@ Checks whether this device supports distributed notifications. This API uses a p ...@@ -2776,14 +2662,14 @@ Checks whether this device supports distributed notifications. This API uses a p
**Example** **Example**
```javascript ```javascript
Notification.isDistributedEnabled() notificationManager.isDistributedEnabled()
.then((data) => { .then((data) => {
console.info("isDistributedEnabled success, data: " + JSON.stringify(data)); console.info("isDistributedEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
## Notification.setDistributedEnableByBundle ## notificationManager.setDistributedEnableByBundle
setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\<void>): void
...@@ -2800,7 +2686,7 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2800,7 +2686,7 @@ Sets whether a specified application supports distributed notifications. This AP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| enable | boolean | Yes | Whether the application supports distributed notifications. | | enable | boolean | Yes | Whether the device supports distributed notifications. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -2824,18 +2710,18 @@ function setDistributedEnableByBundleCallback(err) { ...@@ -2824,18 +2710,18 @@ function setDistributedEnableByBundleCallback(err) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true
Notification.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback); notificationManager.setDistributedEnableByBundle(bundle, enable, setDistributedEnableByBundleCallback);
``` ```
## Notification.setDistributedEnableByBundle ## notificationManager.setDistributedEnableByBundle
setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void> setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise\<void>
...@@ -2852,7 +2738,7 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2852,7 +2738,7 @@ Sets whether a specified application supports distributed notifications. This AP
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------ | ---- | -------------------------- | | -------- | ------------------------ | ---- | -------------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| enable | boolean | Yes | Whether the application supports distributed notifications. | | enable | boolean | Yes | Whether the device supports distributed notifications. |
**Error codes** **Error codes**
...@@ -2867,18 +2753,18 @@ Sets whether a specified application supports distributed notifications. This AP ...@@ -2867,18 +2753,18 @@ Sets whether a specified application supports distributed notifications. This AP
**Example** **Example**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var enable = true let enable = true
Notification.setDistributedEnableByBundle(bundle, enable).then(() => { notificationManager.setDistributedEnableByBundle(bundle, enable).then(() => {
console.info("setDistributedEnableByBundle success"); console.info("setDistributedEnableByBundle success");
}); });
``` ```
## Notification.isDistributedEnabledByBundle ## notificationManager.isDistributedEnabledByBundle
isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\<boolean>): void
...@@ -2918,16 +2804,14 @@ function isDistributedEnabledByBundleCallback(data) { ...@@ -2918,16 +2804,14 @@ function isDistributedEnabledByBundleCallback(data) {
} }
}; };
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); notificationManager.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback);
``` ```
## notificationManager.isDistributedEnabledByBundle
## Notification.isDistributedEnabledByBundle
isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean> isDistributedEnabledByBundle(bundle: BundleOption): Promise\<boolean>
...@@ -2964,17 +2848,17 @@ Checks whether a specified application supports distributed notifications. This ...@@ -2964,17 +2848,17 @@ Checks whether a specified application supports distributed notifications. This
**Example** **Example**
```javascript ```javascript
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
Notification.isDistributedEnabledByBundle(bundle).then((data) => { notificationManager.isDistributedEnabledByBundle(bundle).then((data) => {
console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data)); console.info("isDistributedEnabledByBundle success, data: " + JSON.stringify(data));
}); });
``` ```
## Notification.getDeviceRemindType ## notificationManager.getDeviceRemindType
getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void getDeviceRemindType(callback: AsyncCallback\<DeviceRemindType\>): void
...@@ -3011,12 +2895,10 @@ function getDeviceRemindTypeCallback(err, data) { ...@@ -3011,12 +2895,10 @@ function getDeviceRemindTypeCallback(err, data) {
} }
}; };
Notification.getDeviceRemindType(getDeviceRemindTypeCallback); notificationManager.getDeviceRemindType(getDeviceRemindTypeCallback);
``` ```
## notificationManager.getDeviceRemindType
## Notification.getDeviceRemindType
getDeviceRemindType(): Promise\<DeviceRemindType\> getDeviceRemindType(): Promise\<DeviceRemindType\>
...@@ -3045,13 +2927,13 @@ Obtains the notification reminder type. This API uses a promise to return the re ...@@ -3045,13 +2927,13 @@ Obtains the notification reminder type. This API uses a promise to return the re
**Example** **Example**
```javascript ```javascript
Notification.getDeviceRemindType().then((data) => { notificationManager.getDeviceRemindType().then((data) => {
console.info("getDeviceRemindType success, data: " + JSON.stringify(data)); console.info("getDeviceRemindType success, data: " + JSON.stringify(data));
}); });
``` ```
## Notification.publishAsBundle ## notificationManager.publishAsBundle
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
...@@ -3086,7 +2968,7 @@ Publishes a notification through the reminder agent. This API uses an asynchrono ...@@ -3086,7 +2968,7 @@ Publishes a notification through the reminder agent. This API uses an asynchrono
**Example** **Example**
```js ```ts
// publishAsBundle callback // publishAsBundle callback
function callback(err) { function callback(err) {
if (err) { if (err) {
...@@ -3096,26 +2978,26 @@ function callback(err) { ...@@ -3096,26 +2978,26 @@ function callback(err) {
} }
} }
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
// NotificationRequest object // NotificationRequest object
let request = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(request, representativeBundle, userId, callback); notificationManager.publishAsBundle(request, representativeBundle, userId, callback);
``` ```
## Notification.publishAsBundle ## notificationManager.publishAsBundle
publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\> publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\<void\>
...@@ -3150,30 +3032,30 @@ Publishes a notification through the reminder agent. This API uses a promise to ...@@ -3150,30 +3032,30 @@ Publishes a notification through the reminder agent. This API uses a promise to
**Example** **Example**
```js ```ts
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
// NotificationRequest object // NotificationRequest object
var request = { let request = {
id: 1, id: 1,
content: { content: {
contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, contentType: notificationManager.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: { normal: {
title: "test_title", title: "test_title",
text: "test_text", text: "test_text",
additionalText: "test_additionalText" additionalText: "test_additionalText"
} }
} }
} };
Notification.publishAsBundle(request, representativeBundle, userId).then(() => { notificationManager.publishAsBundle(request, representativeBundle, userId).then(() => {
console.info("publishAsBundle success"); console.info("publishAsBundle success");
}); });
``` ```
## Notification.cancelAsBundle ## notificationManager.cancelAsBundle
cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\<void\>): void
...@@ -3208,7 +3090,7 @@ Cancels a notification published by the reminder agent. This API uses an asynchr ...@@ -3208,7 +3090,7 @@ Cancels a notification published by the reminder agent. This API uses an asynchr
**Example** **Example**
```js ```ts
// cancelAsBundle // cancelAsBundle
function cancelAsBundleCallback(err) { function cancelAsBundleCallback(err) {
if (err) { if (err) {
...@@ -3218,14 +3100,14 @@ function cancelAsBundleCallback(err) { ...@@ -3218,14 +3100,14 @@ function cancelAsBundleCallback(err) {
} }
} }
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); notificationManager.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback);
``` ```
## Notification.cancelAsBundle ## notificationManager.cancelAsBundle
cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\> cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\<void\>
...@@ -3259,18 +3141,18 @@ Cancels a notification published by the reminder agent. This API uses a promise ...@@ -3259,18 +3141,18 @@ Cancels a notification published by the reminder agent. This API uses a promise
**Example** **Example**
```js ```ts
// Bundle name of the application whose notification function is taken over by the reminder agent // 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 // User ID
let userId = 100 let userId = 100;
Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { notificationManager.cancelAsBundle(0, representativeBundle, userId).then(() => {
console.info("cancelAsBundle success"); console.info("cancelAsBundle success");
}); });
``` ```
## Notification.setNotificationEnableSlot ## notificationManager.setNotificationEnableSlot
setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\<void>): void
...@@ -3288,7 +3170,7 @@ Sets whether to enable a specified notification slot type for a specified applic ...@@ -3288,7 +3170,7 @@ Sets whether to enable a specified notification slot type for a specified applic
| -------- | ----------------------------- | ---- | ---------------------- | | -------- | ----------------------------- | ---- | ---------------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type. | | type | [SlotType](#slottype) | Yes | Notification slot type. |
| enable | boolean | Yes | Whether to enable the notification slot type. | | enable | boolean | Yes | Whether to enable notification. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Error codes** **Error codes**
...@@ -3302,7 +3184,7 @@ Sets whether to enable a specified notification slot type for a specified applic ...@@ -3302,7 +3184,7 @@ Sets whether to enable a specified notification slot type for a specified applic
**Example** **Example**
```js ```ts
// setNotificationEnableSlot // setNotificationEnableSlot
function setNotificationEnableSlotCallback(err) { function setNotificationEnableSlotCallback(err) {
if (err) { if (err) {
...@@ -3312,14 +3194,14 @@ function setNotificationEnableSlotCallback(err) { ...@@ -3312,14 +3194,14 @@ function setNotificationEnableSlotCallback(err) {
} }
}; };
Notification.setNotificationEnableSlot( notificationManager.setNotificationEnableSlot(
{ bundle: "ohos.samples.notification", }, { bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION, notificationManager.SlotType.SOCIAL_COMMUNICATION,
true, true,
setNotificationEnableSlotCallback); setNotificationEnableSlotCallback);
``` ```
## Notification.setNotificationEnableSlot ## notificationManager.setNotificationEnableSlot
setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void> setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\<void>
...@@ -3337,7 +3219,7 @@ Sets whether to enable a specified notification slot type for a specified applic ...@@ -3337,7 +3219,7 @@ Sets whether to enable a specified notification slot type for a specified applic
| ------ | ----------------------------- | ---- | -------------- | | ------ | ----------------------------- | ---- | -------------- |
| bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information of the application. |
| type | [SlotType](#slottype) | Yes | Notification slot type.| | type | [SlotType](#slottype) | Yes | Notification slot type.|
| enable | boolean | Yes | Whether to enable the notification slot type. | | enable | boolean | Yes | Whether to enable notification. |
**Error codes** **Error codes**
...@@ -3350,17 +3232,17 @@ Sets whether to enable a specified notification slot type for a specified applic ...@@ -3350,17 +3232,17 @@ Sets whether to enable a specified notification slot type for a specified applic
**Example** **Example**
```js ```ts
// setNotificationEnableSlot // setNotificationEnableSlot
Notification.setNotificationEnableSlot( notificationManager.setNotificationEnableSlot(
{ bundle: "ohos.samples.notification", }, { bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION, notificationManager.SlotType.SOCIAL_COMMUNICATION,
true).then(() => { true).then(() => {
console.info("setNotificationEnableSlot success"); console.info("setNotificationEnableSlot success");
}); });
``` ```
## Notification.isNotificationSlotEnabled ## notificationManager.isNotificationSlotEnabled
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\<boolean\>): void
...@@ -3391,7 +3273,7 @@ Checks whether a specified notification slot type is enabled for a specified app ...@@ -3391,7 +3273,7 @@ Checks whether a specified notification slot type is enabled for a specified app
**Example** **Example**
```js ```ts
// isNotificationSlotEnabled // isNotificationSlotEnabled
function getEnableSlotCallback(err, data) { function getEnableSlotCallback(err, data) {
if (err) { if (err) {
...@@ -3401,13 +3283,13 @@ function getEnableSlotCallback(err, data) { ...@@ -3401,13 +3283,13 @@ function getEnableSlotCallback(err, data) {
} }
}; };
Notification.isNotificationSlotEnabled( notificationManager.isNotificationSlotEnabled(
{ bundle: "ohos.samples.notification", }, { bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION, notificationManager.SlotType.SOCIAL_COMMUNICATION,
getEnableSlotCallback); getEnableSlotCallback);
``` ```
## Notification.isNotificationSlotEnabled ## notificationManager.isNotificationSlotEnabled
isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\> isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\<boolean\>
...@@ -3443,16 +3325,16 @@ Checks whether a specified notification slot type is enabled for a specified app ...@@ -3443,16 +3325,16 @@ Checks whether a specified notification slot type is enabled for a specified app
**Example** **Example**
```js ```ts
// isNotificationSlotEnabled // isNotificationSlotEnabled
Notification.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", }, notificationManager.isNotificationSlotEnabled({ bundle: "ohos.samples.notification", },
Notification.SlotType.SOCIAL_COMMUNICATION).then((data) => { notificationManager.SlotType.SOCIAL_COMMUNICATION).then((data) => {
console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data)); console.info("isNotificationSlotEnabled success, data: " + JSON.stringify(data));
}); });
``` ```
## Notification.setSyncNotificationEnabledWithoutApp ## notificationManager.setSyncNotificationEnabledWithoutApp
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\<void\>): void
...@@ -3483,7 +3365,7 @@ Sets whether to enable the notification sync feature for devices where the appli ...@@ -3483,7 +3365,7 @@ Sets whether to enable the notification sync feature for devices where the appli
**Example** **Example**
```js ```ts
let userId = 100; let userId = 100;
let enable = true; let enable = true;
...@@ -3495,11 +3377,11 @@ function callback(err) { ...@@ -3495,11 +3377,11 @@ function callback(err) {
} }
} }
Notification.setSyncNotificationEnabledWithoutApp(userId, enable, callback); notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable, callback);
``` ```
## Notification.setSyncNotificationEnabledWithoutApp ## notificationManager.setSyncNotificationEnabledWithoutApp
setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void> setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\<void>
...@@ -3535,11 +3417,11 @@ Sets whether to enable the notification sync feature for devices where the appli ...@@ -3535,11 +3417,11 @@ Sets whether to enable the notification sync feature for devices where the appli
**Example** **Example**
```js ```ts
let userId = 100; let userId = 100;
let enable = true; let enable = true;
Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => { notificationManager.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
console.info('setSyncNotificationEnabledWithoutApp success'); console.info('setSyncNotificationEnabledWithoutApp success');
}).catch((err) => { }).catch((err) => {
console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err)); console.info('setSyncNotificationEnabledWithoutApp, err:' + JSON.stringify(err));
...@@ -3547,7 +3429,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => { ...@@ -3547,7 +3429,7 @@ Notification.setSyncNotificationEnabledWithoutApp(userId, enable).then(() => {
``` ```
## Notification.getSyncNotificationEnabledWithoutApp ## notificationManager.getSyncNotificationEnabledWithoutApp
getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\<boolean>): void
...@@ -3577,7 +3459,7 @@ Obtains whether the notification sync feature is enabled for devices where the a ...@@ -3577,7 +3459,7 @@ Obtains whether the notification sync feature is enabled for devices where the a
**Example** **Example**
```js ```ts
let userId = 100; let userId = 100;
function getSyncNotificationEnabledWithoutAppCallback(err, data) { function getSyncNotificationEnabledWithoutAppCallback(err, data) {
...@@ -3588,11 +3470,11 @@ function getSyncNotificationEnabledWithoutAppCallback(err, data) { ...@@ -3588,11 +3470,11 @@ function getSyncNotificationEnabledWithoutAppCallback(err, data) {
} }
} }
Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback); notificationManager.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback);
``` ```
## Notification.getSyncNotificationEnabledWithoutApp ## notificationManager.getSyncNotificationEnabledWithoutApp
getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean> getSyncNotificationEnabledWithoutApp(userId: number): Promise\<boolean>
...@@ -3627,21 +3509,16 @@ Obtains whether the notification sync feature is enabled for devices where the a ...@@ -3627,21 +3509,16 @@ Obtains whether the notification sync feature is enabled for devices where the a
**Example** **Example**
```js ```ts
let userId = 100; let userId = 100;
Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { notificationManager.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
console.info('getSyncNotificationEnabledWithoutApp, data:' + data); console.info('getSyncNotificationEnabledWithoutApp, data:' + data);
}).catch((err) => { }).catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:' + err); console.info('getSyncNotificationEnabledWithoutApp, err:' + err);
}); });
.catch((err) => {
console.info('getSyncNotificationEnabledWithoutApp, err:', err);
});
``` ```
## DoNotDisturbDate ## DoNotDisturbDate
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
...@@ -3654,8 +3531,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => { ...@@ -3654,8 +3531,6 @@ Notification.getSyncNotificationEnabledWithoutApp(userId).then((data) => {
| begin | Date | Yes | Yes | DND start time.| | begin | Date | Yes | Yes | DND start time.|
| end | Date | Yes | Yes | DND end time.| | end | Date | Yes | Yes | DND end time.|
## DoNotDisturbType ## DoNotDisturbType
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
......
# @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. The **notificationSubscribe** module provides APIs for notification subscription, notification unsubscription, subscription removal, and more. In general cases, only system applications can call these APIs.
> **NOTE** > **NOTE**
> >
...@@ -9,7 +9,7 @@ The **NotificationSubscribe** module provides APIs for notification subscription ...@@ -9,7 +9,7 @@ The **NotificationSubscribe** module provides APIs for notification subscription
## Modules to Import ## Modules to Import
```js ```js
import NotificationSubscribe from '@ohos.notificationSubscribe'; import notificationSubscribe from '@ohos.notificationSubscribe';
``` ```
...@@ -56,17 +56,15 @@ function subscribeCallback(err) { ...@@ -56,17 +56,15 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
var info = { let info = {
bundleNames: ["bundleName1","bundleName2"] bundleNames: ["bundleName1","bundleName2"]
} };
NotificationSubscribe.subscribe(subscriber, info, subscribeCallback); notificationSubscribe.subscribe(subscriber, info, subscribeCallback);
``` ```
## NotificationSubscribe.subscribe ## NotificationSubscribe.subscribe
subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>): void
...@@ -107,10 +105,10 @@ function subscribeCallback(err) { ...@@ -107,10 +105,10 @@ function subscribeCallback(err) {
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
} };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -148,10 +146,10 @@ Subscribes to a notification with the subscription information specified. This A ...@@ -148,10 +146,10 @@ Subscribes to a notification with the subscription information specified. This A
function onConsumeCallback(data) { function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data)); console.info("Consume callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber).then(() => { notificationSubscribe.subscribe(subscriber).then(() => {
console.info("subscribe success"); console.info("subscribe success");
}); });
``` ```
...@@ -198,14 +196,12 @@ function unsubscribeCallback(err) { ...@@ -198,14 +196,12 @@ function unsubscribeCallback(err) {
function onDisconnectCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
} };
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
## NotificationSubscribe.unsubscribe ## NotificationSubscribe.unsubscribe
unsubscribe(subscriber: NotificationSubscriber): Promise\<void\> unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
...@@ -238,16 +234,14 @@ Unsubscribes from a notification. This API uses a promise to return the result. ...@@ -238,16 +234,14 @@ Unsubscribes from a notification. This API uses a promise to return the result.
function onDisconnectCallback(data) { function onDisconnectCallback(data) {
console.info("Cancel callback: " + JSON.stringify(data)); console.info("Cancel callback: " + JSON.stringify(data));
} }
var subscriber = { let subscriber = {
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
NotificationSubscribe.unsubscribe(subscriber).then(() => { notificationSubscribe.unsubscribe(subscriber).then(() => {
console.info("unsubscribe success"); console.info("unsubscribe success");
}); });
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveReason, callback: AsyncCallback\<void\>): void
...@@ -289,15 +283,15 @@ function removeCallback(err) { ...@@ -289,15 +283,15 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason, removeCallback); notificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
``` ```
...@@ -335,21 +329,19 @@ Removes a notification for a specified application. This API uses a promise to r ...@@ -335,21 +329,19 @@ Removes a notification for a specified application. This API uses a promise to r
**Example** **Example**
```js ```js
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
var notificationKey = { let notificationKey = {
id: 0, id: 0,
label: "label", label: "label",
} };
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(bundle, notificationKey, reason).then(() => { notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>): void
...@@ -382,7 +374,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu ...@@ -382,7 +374,7 @@ Removes a specified notification. This API uses an asynchronous callback to retu
**Example** **Example**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
function removeCallback(err) { function removeCallback(err) {
if (err) { if (err) {
...@@ -391,12 +383,10 @@ function removeCallback(err) { ...@@ -391,12 +383,10 @@ function removeCallback(err) {
console.info("remove success"); console.info("remove success");
} }
} }
var reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE; let reason = NotificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason, removeCallback); notificationSubscribe.remove(hashCode, reason, removeCallback);
``` ```
## NotificationSubscribe.remove ## NotificationSubscribe.remove
remove(hashCode: string, reason: RemoveReason): Promise\<void\> remove(hashCode: string, reason: RemoveReason): Promise\<void\>
...@@ -428,15 +418,13 @@ Removes a specified notification. This API uses a promise to return the result. ...@@ -428,15 +418,13 @@ Removes a specified notification. This API uses a promise to return the result.
**Example** **Example**
```js ```js
var hashCode = 'hashCode' let hashCode = 'hashCode';
var reason = NotificationSubscribe.RemoveReason.CLICK_REASON_REMOVE; let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
NotificationSubscribe.remove(hashCode, reason).then(() => { notificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success"); console.info("remove success");
}); });
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
...@@ -475,14 +463,12 @@ function removeAllCallback(err) { ...@@ -475,14 +463,12 @@ function removeAllCallback(err) {
console.info("removeAll success"); console.info("removeAll success");
} }
} }
var bundle = { let bundle = {
bundle: "bundleName1", bundle: "bundleName1",
} };
NotificationSubscribe.removeAll(bundle, removeAllCallback); NotificationSubscribe.removeAll(bundle, removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(callback: AsyncCallback\<void\>): void removeAll(callback: AsyncCallback\<void\>): void
...@@ -520,11 +506,9 @@ function removeAllCallback(err) { ...@@ -520,11 +506,9 @@ function removeAllCallback(err) {
} }
} }
NotificationSubscribe.removeAll(removeAllCallback); notificationSubscribe.removeAll(removeAllCallback);
``` ```
## NotificationSubscribe.removeAll ## NotificationSubscribe.removeAll
removeAll(bundle?: BundleOption): Promise\<void\> removeAll(bundle?: BundleOption): Promise\<void\>
...@@ -556,7 +540,7 @@ Removes all notifications for a specified application. This API uses a promise t ...@@ -556,7 +540,7 @@ Removes all notifications for a specified application. This API uses a promise t
```js ```js
// If no application is specified, notifications of all applications are deleted. // If no application is specified, notifications of all applications are deleted.
NotificationSubscribe.removeAll().then(() => { notificationSubscribe.removeAll().then(() => {
console.info("removeAll success"); console.info("removeAll success");
}); });
``` ```
...@@ -600,9 +584,9 @@ function removeAllCallback(err) { ...@@ -600,9 +584,9 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## Notification.removeAll ## Notification.removeAll
...@@ -643,13 +627,11 @@ function removeAllCallback(err) { ...@@ -643,13 +627,11 @@ function removeAllCallback(err) {
} }
} }
var userId = 1 let userId = 1;
NotificationSubscribe.removeAll(userId, removeAllCallback); notificationSubscribe.removeAll(userId, removeAllCallback);
``` ```
## NotificationSubscriber ## NotificationSubscriber
Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe). Provides callbacks for receiving or removing notifications and serves as the input parameter of [subscribe](#notificationsubscribe).
...@@ -689,11 +671,11 @@ function onConsumeCallback(data) { ...@@ -689,11 +671,11 @@ function onConsumeCallback(data) {
console.info('===> onConsume callback req.id:' + req.id); console.info('===> onConsume callback req.id:' + req.id);
}; };
var subscriber = { let subscriber = {
onConsume: onConsumeCallback onConsume: onConsumeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onCancel ### onCancel
...@@ -729,11 +711,11 @@ function onCancelCallback(data) { ...@@ -729,11 +711,11 @@ function onCancelCallback(data) {
console.info('===> onCancel callback req.id:' + req.id); console.info('===> onCancel callback req.id:' + req.id);
} }
var subscriber = { let subscriber = {
onCancel: onCancelCallback onCancel: onCancelCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onUpdate ### onUpdate
...@@ -767,11 +749,11 @@ function onUpdateCallback(map) { ...@@ -767,11 +749,11 @@ function onUpdateCallback(map) {
console.info('===> onUpdateCallback map:' + JSON.stringify(map)); console.info('===> onUpdateCallback map:' + JSON.stringify(map));
} }
var subscriber = { let subscriber = {
onUpdate: onUpdateCallback onUpdate: onUpdateCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onConnect ### onConnect
...@@ -799,11 +781,11 @@ function onConnectCallback() { ...@@ -799,11 +781,11 @@ function onConnectCallback() {
console.info('===> onConnect in test'); console.info('===> onConnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback onConnect: onConnectCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDisconnect ### onDisconnect
...@@ -841,15 +823,15 @@ function onDisconnectCallback() { ...@@ -841,15 +823,15 @@ function onDisconnectCallback() {
console.info('===> onDisconnect in test'); console.info('===> onDisconnect in test');
} }
var subscriber = { let subscriber = {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback onDisconnect: onDisconnectCallback
}; };
// The onConnect callback is invoked when subscription to the notification is complete. // The onConnect callback is invoked when subscription to the notification is complete.
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
// The onDisconnect callback is invoked when unsubscription to the notification is complete. // The onDisconnect callback is invoked when unsubscription to the notification is complete.
NotificationSubscribe.unsubscribe(subscriber, unsubscribeCallback); notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
``` ```
### onDestroy ### onDestroy
...@@ -877,11 +859,11 @@ function onDestroyCallback() { ...@@ -877,11 +859,11 @@ function onDestroyCallback() {
console.info('===> onDestroy in test'); console.info('===> onDestroy in test');
} }
var subscriber = { let subscriber = {
onDestroy: onDestroyCallback onDestroy: onDestroyCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
### onDoNotDisturbDateChange ### onDoNotDisturbDateChange
...@@ -915,11 +897,11 @@ function onDoNotDisturbDateChangeCallback(mode) { ...@@ -915,11 +897,11 @@ function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode); console.info('===> onDoNotDisturbDateChange:' + mode);
} }
var subscriber = { let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
...@@ -956,11 +938,11 @@ function onEnabledNotificationChangedCallback(callbackData) { ...@@ -956,11 +938,11 @@ function onEnabledNotificationChangedCallback(callbackData) {
console.info("enable: ", callbackData.enable); console.info("enable: ", callbackData.enable);
}; };
var subscriber = { let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback onEnabledNotificationChanged: onEnabledNotificationChangedCallback
}; };
NotificationSubscribe.subscribe(subscriber, subscribeCallback); notificationSubscribe.subscribe(subscriber, subscribeCallback);
``` ```
## BundleOption ## BundleOption
...@@ -1011,7 +993,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback); ...@@ -1011,7 +993,7 @@ NotificationSubscribe.subscribe(subscriber, subscribeCallback);
## NotificationSorting ## NotificationSorting
Provides sorting information of activity notifications. Provides sorting information of active notifications.
**System capability**: SystemCapability.Notification.Notification **System capability**: SystemCapability.Notification.Notification
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
The **device** module provides APIs for checking information about the current device. The **device** module provides APIs for checking information about the current device.
> **NOTE** > **NOTE**
>
> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [@ohos.deviceInfo](js-apis-device-info.md) instead. > - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [@ohos.deviceInfo](js-apis-device-info.md) instead.
> >
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```typescript
import device from '@system.device'; import device from '@system.device';
``` ```
...@@ -39,14 +40,14 @@ Obtains the device information. ...@@ -39,14 +40,14 @@ Obtains the device information.
| -------- | -------- | -------- | | -------- | -------- | -------- |
| brand | string | Brand.| | brand | string | Brand.|
| manufacturer | string | Manufacturer.| | manufacturer | string | Manufacturer.|
| model | string | Model. | | model | string | Model.|
| product | string | Product number.| | product | string | Product number.|
| language<sup>4+</sup> | string | System language.| | language<sup>4+</sup> | string | System language.|
| region<sup>4+</sup> | string | System region.| | region<sup>4+</sup> | string | System region.|
| windowWidth | number | Window width.| | windowWidth | number | Window width.|
| windowHeight | number | Window height.| | windowHeight | number | Window height.|
| screenDensity<sup>4+</sup> | number | Screen density.| | screenDensity<sup>4+</sup> | number | Screen density.|
| screenShape<sup>4+</sup> | string | Screen shape. The options are as follows:<br>- **rect**: rectangle screen<br>- **circle**: circle screen| | screenShape<sup>4+</sup> | string | Screen shape. The options are as follows:<br>- **rect**: rectangular screen<br>- **circle**: round screen|
| apiVersion<sup>4+</sup> | number | API version.| | apiVersion<sup>4+</sup> | number | API version.|
| releaseType<sup>4+</sup> | string | Release type. The value includes both the release type and the API version, for example, Beta1.<br>Available release types are as follows:<br>- **Canary**: For the same API version, different canary releases are compatible with each other, but not compatible with those of the **beta** and **release** type.<br>- **Beta**: For the same API version, different beta releases are compatible with each other, but not compatible with those of the **release** type.<br>- **Release**: Releases of this type are compatible with the latest five API versions.| | releaseType<sup>4+</sup> | string | Release type. The value includes both the release type and the API version, for example, Beta1.<br>Available release types are as follows:<br>- **Canary**: For the same API version, different canary releases are compatible with each other, but not compatible with those of the **beta** and **release** type.<br>- **Beta**: For the same API version, different beta releases are compatible with each other, but not compatible with those of the **release** type.<br>- **Release**: Releases of this type are compatible with the latest five API versions.|
| deviceType<sup>4+</sup> | string | Device type.| | deviceType<sup>4+</sup> | string | Device type.|
...@@ -55,11 +56,11 @@ Obtains the device information. ...@@ -55,11 +56,11 @@ Obtains the device information.
| Error Code| Description| | Error Code| Description|
| -------- | -------- | | -------- | -------- |
| 200 | The returned result contains information that cannot be obtained.| | 200 | Certain information cannot be obtained.|
**Example** **Example**
``` ```typescript
export default { export default {
getInfo() { getInfo() {
device.getInfo({ device.getInfo({
......
# @system.notification # @system.notification (Notification)
> **NOTE** > **NOTE**
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.notification`](js-apis-notification.md). > - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.notification`](js-apis-notification.md).
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
## Modules to Import ## Modules to Import
``` ```ts
import notification from '@system.notification'; import notification from '@system.notification';
``` ```
...@@ -59,9 +59,9 @@ export default { ...@@ -59,9 +59,9 @@ export default {
clickAction: { clickAction: {
bundleName: 'com.example.testapp', bundleName: 'com.example.testapp',
abilityName: 'notificationDemo', abilityName: 'notificationDemo',
uri: '/path/to/notification', uri: '/path/to/notification'
}, }
}); });
}, }
} }
``` ```
...@@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object. ...@@ -1735,9 +1735,9 @@ Creates a radial gradient and returns a **CanvasGradient** object.
// Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200) // Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200)
var gradient = ctx.createRadialGradient(200,200,50, 200,200,200); var gradient = ctx.createRadialGradient(200,200,50, 200,200,200);
// Add three color stops // Add three color stops
gradient.addColorStop(0.0, 'red'); gradient.addColorStop(0.0, '#ff0000');
gradient.addColorStop(0.5, 'white'); gradient.addColorStop(0.5, '#ffffff');
gradient.addColorStop(1.0, 'green'); gradient.addColorStop(1.0, '#00ff00');
// Set the fill style and draw a rectangle // Set the fill style and draw a rectangle
ctx.fillStyle = gradient; ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 500, 500); ctx.fillRect(0, 0, 500, 500);
......
...@@ -773,7 +773,7 @@ Clears the content in a rectangle on the canvas. ...@@ -773,7 +773,7 @@ Clears the content in a rectangle on the canvas.
Canvas(this.context) Canvas(this.context)
.width('100%') .width('100%')
.height('100%') .height('100%')
.backgroundColor('#ffffff') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.fillStyle = 'rgb(0,0,255)' this.context.fillStyle = 'rgb(0,0,255)'
this.context.fillRect(20,20,200,200) this.context.fillRect(20,20,200,200)
...@@ -1583,7 +1583,7 @@ struct Fill { ...@@ -1583,7 +1583,7 @@ struct Fill {
region.lineTo(270, 90) region.lineTo(270, 90)
region.closePath() region.closePath()
// Fill path // Fill path
this.context.fillStyle = 'green' this.context.fillStyle = '#00ff00'
this.context.fill(region, "evenodd") this.context.fill(region, "evenodd")
}) })
} }
...@@ -1749,7 +1749,7 @@ Rotates a canvas clockwise around its coordinate axes. ...@@ -1749,7 +1749,7 @@ Rotates a canvas clockwise around its coordinate axes.
.height('100%') .height('100%')
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.rotate(45 * Math.PI / 180) // Rotate the rectangle 45 degrees this.context.rotate(45 * Math.PI / 180)
this.context.fillRect(70, 20, 50, 50) this.context.fillRect(70, 20, 50, 50)
}) })
} }
...@@ -2417,7 +2417,7 @@ Restores the saved drawing context. ...@@ -2417,7 +2417,7 @@ Restores the saved drawing context.
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.save() // save the default state this.context.save() // save the default state
this.context.fillStyle = "green" this.context.fillStyle = "#00ff00"
this.context.fillRect(20, 20, 100, 100) this.context.fillRect(20, 20, 100, 100)
this.context.restore() // restore to the default state this.context.restore() // restore to the default state
this.context.fillRect(150, 75, 100, 100) this.context.fillRect(150, 75, 100, 100)
...@@ -2455,7 +2455,7 @@ Saves all states of the canvas in the stack. This API is usually called when the ...@@ -2455,7 +2455,7 @@ Saves all states of the canvas in the stack. This API is usually called when the
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
this.context.save() // save the default state this.context.save() // save the default state
this.context.fillStyle = "green" this.context.fillStyle = "#00ff00"
this.context.fillRect(20, 20, 100, 100) this.context.fillRect(20, 20, 100, 100)
this.context.restore() // restore to the default state this.context.restore() // restore to the default state
this.context.fillRect(150, 75, 100, 100) this.context.fillRect(150, 75, 100, 100)
...@@ -2502,9 +2502,9 @@ Creates a linear gradient. ...@@ -2502,9 +2502,9 @@ Creates a linear gradient.
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createLinearGradient(50,0, 300,100) var grad = this.context.createLinearGradient(50,0, 300,100)
grad.addColorStop(0.0, 'red') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, 'white') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, 'green') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 500, 500)
}) })
...@@ -2553,9 +2553,9 @@ Creates a linear gradient. ...@@ -2553,9 +2553,9 @@ Creates a linear gradient.
.backgroundColor('#ffff00') .backgroundColor('#ffff00')
.onReady(() =>{ .onReady(() =>{
var grad = this.context.createRadialGradient(200,200,50, 200,200,200) var grad = this.context.createRadialGradient(200,200,50, 200,200,200)
grad.addColorStop(0.0, 'red') grad.addColorStop(0.0, '#ff0000')
grad.addColorStop(0.5, 'white') grad.addColorStop(0.5, '#ffffff')
grad.addColorStop(1.0, 'green') grad.addColorStop(1.0, '#00ff00')
this.context.fillStyle = grad this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500) this.context.fillRect(0, 0, 500, 500)
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册