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