# Notification The **Notification** module provides notification management capabilities, covering notifications, notification slots, notification subscription, notification enabled status, and notification badge status. Generally, only system applications have the permission to subscribe to and unsubscribe from notifications. > **NOTE** > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import ```js import Notification from '@ohos.notification'; ``` ## Notification.publish publish(request: NotificationRequest, callback: AsyncCallback\): void Publishes a notification. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | | request | [NotificationRequest](#notificationrequest) | Yes | **NotificationRequest** object.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js // publish callback function publishCallback(err) { console.info("==========================>publishCallback=======================>"); } // NotificationRequest object var notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", additionalText: "test_additionalText" } } } Notification.publish(notificationRequest, publishCallback) ``` ## Notification.publish publish(request: NotificationRequest): Promise\ Publishes a notification. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------------- | ---- | ------------------------------------------- | | request | [NotificationRequest](#notificationrequest) | Yes | **NotificationRequest** object.| **Example** ```js // NotificationRequest object var notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", additionalText: "test_additionalText" } } } Notification.publish(notificationRequest).then(() => { console.info("==========================>publishCallback=======================>"); }); ``` ## Notification.publish8+ publish(request: NotificationRequest, userId: number, callback: AsyncCallback\): void Publishes a notification. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------------------------------- | | request | [NotificationRequest](#notificationrequest) | Yes | **NotificationRequest** object.| | userId | number | Yes | ID of the user who receives the notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js // publish callback function publishCallback(err) { console.info("==========================>publishCallback=======================>"); } // ID of the user who receives the notification var userId = 1 // NotificationRequest object var notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", additionalText: "test_additionalText" } } } Notification.publish(notificationRequest, userId, publishCallback); ``` ## Notification.publish8+ publish(request: NotificationRequest, userId: number): Promise\ Publishes a notification. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------------------------- | ---- | ------------------------------------------- | | request | [NotificationRequest](#notificationrequest) | Yes | **NotificationRequest** object.| | userId | number | Yes | ID of the user who receives the notification. | **Example** ```js var notificationRequest = { notificationId: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", additionalText: "test_additionalText" } } } var userId = 1 Notification.publish(notificationRequest, userId).then(() => { console.info("==========================>publishCallback=======================>"); }); ``` ## Notification.cancel cancel(id: number, label: string, callback: AsyncCallback\): void Cancels a notification with the specified ID and label. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | id | number | Yes | Notification ID. | | label | string | Yes | Notification label. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js // cancel callback function cancelCallback(err) { console.info("==========================>cancelCallback=======================>"); } Notification.cancel(0, "label", cancelCallback) ``` ## Notification.cancel cancel(id: number, label?: string): Promise\ Cancels a notification with the specified ID and label. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | ----- | ------ | ---- | -------- | | id | number | Yes | Notification ID. | | label | string | No | Notification label.| **Example** ```js Notification.cancel(0).then(() => { console.info("==========================>cancelCallback=======================>"); }); ``` ## Notification.cancel cancel(id: number, callback: AsyncCallback\): void Cancels a notification with the specified ID. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | id | number | Yes | Notification ID. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js // cancel callback function cancelCallback(err) { console.info("==========================>cancelCallback=======================>"); } Notification.cancel(0, cancelCallback) ``` ## Notification.cancelAll cancelAll(callback: AsyncCallback\): void Cancels all notifications. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js // cancel callback function cancelAllCallback(err) { console.info("==========================>cancelAllCallback=======================>"); } Notification.cancelAll(cancelAllCallback) ``` ## Notification.cancelAll cancelAll(): Promise\ Cancels all notifications. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Example** ```js Notification.cancelAll().then(() => { console.info("==========================>cancelAllCallback=======================>"); }); ``` ## Notification.addSlot addSlot(slot: NotificationSlot, callback: AsyncCallback\): void Adds a notification slot. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | slot | [NotificationSlot](#notificationslot) | Yes | Notification slot to add.| | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js // addSlot callback function addSlotCallBack(err) { console.info("==========================>addSlotCallBack=======================>"); } // NotificationSlot object var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } Notification.addSlot(notificationSlot, addSlotCallBack) ``` ## Notification.addSlot addSlot(slot: NotificationSlot): Promise\ Adds a notification slot. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type | Mandatory| Description | | ---- | ---------------- | ---- | -------------------- | | slot | [NotificationSlot](#notificationslot) | Yes | Notification slot to add.| **Example** ```js // NotificationSlot object var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } Notification.addSlot(notificationSlot).then(() => { console.info("==========================>addSlotCallback=======================>"); }); ``` ## Notification.addSlot addSlot(type: SlotType, callback: AsyncCallback\): void Adds a notification slot. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------- | | type | [SlotType](#slottype) | Yes | Type of the notification slot to add.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js // addSlot callback function addSlotCallBack(err) { console.info("==========================>addSlotCallBack=======================>"); } Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack) ``` ## Notification.addSlot addSlot(type: SlotType): Promise\ Adds a notification slot. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name| Type | Mandatory| Description | | ---- | -------- | ---- | ---------------------- | | type | [SlotType](#slottype) | Yes | Type of the notification slot to add.| **Example** ```js Notification.addSlot(Notification.SlotType.SOCIAL_COMMUNICATION).then(() => { console.info("==========================>addSlotCallback=======================>"); }); ``` ## Notification.addSlots addSlots(slots: Array\, callback: AsyncCallback\): void Adds multiple notification slots. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ------------------------ | | slots | Array\<[NotificationSlot](#notificationslot)\> | Yes | Notification slots to add.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js // addSlots callback function addSlotsCallBack(err) { console.info("==========================>addSlotsCallBack=======================>"); } // NotificationSlot object var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } // NotificationSlotArray object var notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; Notification.addSlots(notificationSlotArray, addSlotsCallBack) ``` ## Notification.addSlots addSlots(slots: Array\): Promise\ Adds multiple notification slots. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ----- | ------------------------- | ---- | ------------------------ | | slots | Array\<[NotificationSlot](#notificationslot)\> | Yes | Notification slots to add.| **Example** ```js // NotificationSlot object var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } // NotificationSlotArray object var notificationSlotArray = new Array(); notificationSlotArray[0] = notificationSlot; Notification.addSlots(notificationSlotArray).then(() => { console.info("==========================>addSlotCallback=======================>"); }); ``` ## Notification.getSlot getSlot(slotType: SlotType, callback: AsyncCallback\): void Obtains a notification slot of the specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| | callback | AsyncCallback\<[NotificationSlot](#notificationslot)\> | Yes | Callback used to return the result. | **Example** ```js // getSlot callback function getSlotCallback(err,data) { console.info("==========================>getSlotCallback=======================>"); } var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.getSlot(slotType, getSlotCallback) ``` ## Notification.getSlot getSlot(slotType: SlotType): Promise\ Obtains a notification slot of the specified type. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.getSlot(slotType).then((data) => { console.info("==========================>getSlotCallback=======================>"); }); ``` ## Notification.getSlots getSlots(callback: AsyncCallback>): void Obtains all notification slots. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | -------------------- | | callback | AsyncCallback\\> | Yes | Callback used to return the result.| **Example** ```js // getSlots callback function getSlotsCallback(err,data) { console.info("==========================>getSlotsCallback=======================>"); } Notification.getSlots(getSlotsCallback) ``` ## Notification.getSlots getSlots(): Promise\> Obtains all notification slots of this application. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\\> | Promise used to return the result.| **Example** ```js Notification.getSlots().then((data) => { console.info("==========================>getSlotsCallback=======================>"); }); ``` ## Notification.removeSlot removeSlot(slotType: SlotType, callback: AsyncCallback\): void Removes a notification slot of the specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js // removeSlot callback function removeSlotCallback(err) { console.info("==========================>removeSlotCallback=======================>"); } var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType,removeSlotCallback) ``` ## Notification.removeSlot removeSlot(slotType: SlotType): Promise\ Removes a notification slot of the specified type. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | -------- | ---- | ----------------------------------------------------------- | | slotType | [SlotType](#slottype) | Yes | Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.| **Example** ```js var slotType = Notification.SlotType.SOCIAL_COMMUNICATION; Notification.removeSlot(slotType).then(() => { console.info("==========================>removeSlotCallback=======================>"); }); ``` ## Notification.removeAllSlots removeAllSlots(callback: AsyncCallback\): void Removes all notification slots. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function removeAllCallBack(err) { console.info("================>removeAllCallBack=======================>"); } Notification.removeAllSlots(removeAllCallBack) ``` ## Notification.removeAllSlots removeAllSlots(): Promise\ Removes all notification slots. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Example** ```js Notification.removeAllSlots().then(() => { console.info("==========================>removeAllCallBack=======================>"); }); ``` ## Notification.subscribe subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, callback: AsyncCallback\): void Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------- | ---- | ---------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | Yes | Subscription information. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js // subscribe callback function subscribeCallback(err) { console.info("==========================>subscribeCallback=======================>"); } function onConsumeCallback(data) { console.info("==========================>onConsumeCallback=======================>"); } var subscriber = { onConsume: onConsumeCallback } var info = { bundleNames: ["bundleName1","bundleName2"] } Notification.subscribe(subscriber, info, subscribeCallback); ``` ## Notification.subscribe subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void Subscribes to a notification with the subscription information specified. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ---------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function subscribeCallback(err) { console.info("==========================>subscribeCallback=======================>"); } function onConsumeCallback(data) { console.info("==========================>onConsumeCallback=======================>"); } var subscriber = { onConsume: onConsumeCallback } Notification.subscribe(subscriber, subscribeCallback); ``` ## Notification.subscribe subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo): Promise\ Subscribes to a notification with the subscription information specified. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ---------- | ------------------------- | ---- | ------------ | | subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber.| | info | [NotificationSubscribeInfo](#notificationsubscribeinfo) | No | Subscription information. | **Example** ```js function onConsumeCallback(data) { console.info("==========================>onConsumeCallback=======================>"); } var subscriber = { onConsume: onConsumeCallback }; Notification.subscribe(subscriber).then(() => { console.info("==========================>subscribeCallback=======================>"); }); ``` ## Notification.unsubscribe unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\): void Unsubscribes from a notification. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | -------------------- | | subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function unsubscribeCallback(err) { console.info("==========================>unsubscribeCallback=======================>"); } function onConsumeCallback(data) { console.info("==========================>onConsumeCallback=======================>"); } var subscriber = { onConsume: onConsumeCallback } Notification.unsubscribe(subscriber, unsubscribeCallback); ``` ## Notification.unsubscribe unsubscribe(subscriber: NotificationSubscriber): Promise\ Unsubscribes from a notification. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ------------ | | subscriber | [NotificationSubscriber](#notificationsubscriber) | Yes | Notification subscriber.| **Example** ```js function onConsumeCallback(data) { console.info("==========================>onConsumeCallback=======================>"); } var subscriber = { onConsume: onConsumeCallback }; Notification.unsubscribe(subscriber).then(() => { console.info("==========================>unsubscribeCallback=======================>"); }); ``` ## Notification.enableNotification enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void Sets whether to enable notification for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | enable | boolean | Yes | Whether to enable notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function enableNotificationCallback(err) { console.info("==========================>enableNotificationCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.enableNotification(bundle, false, enableNotificationCallback); ``` ## Notification.enableNotification enableNotification(bundle: BundleOption, enable: boolean): Promise\ Sets whether to enable notification for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| | enable | boolean | Yes | Whether to enable notification. | **Example** ```js var bundle = { bundle: "bundleName1", } Notification.enableNotification(bundle, false).then(() => { console.info("==========================>enableNotificationCallback=======================>"); }); ``` ## Notification.isNotificationEnabled isNotificationEnabled(bundle: BundleOption, callback: AsyncCallback\): void Checks whether notification is enabled for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function isNotificationEnabledCallback(err, data) { console.info("==========================>isNotificationEnabledCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.isNotificationEnabled(bundle, isNotificationEnabledCallback); ``` ## Notification.isNotificationEnabled isNotificationEnabled(bundle: BundleOption): Promise\ Checks whether notification is enabled for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js var bundle = { bundle: "bundleName1", } Notification.isNotificationEnabled(bundle).then((data) => { console.info("==========================>isNotificationEnabledCallback=======================>"); }); ``` ## Notification.isNotificationEnabled isNotificationEnabled(callback: AsyncCallback\): void Checks whether notification is enabled for this application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function isNotificationEnabledCallback(err, data) { console.info("==========================>isNotificationEnabledCallback=======================>"); } Notification.isNotificationEnabled(isNotificationEnabledCallback); ``` ## Notification.isNotificationEnabled isNotificationEnabled(): Promise\ Checks whether notification is enabled for this application. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js Notification.isNotificationEnabled().then((data) => { console.info("==========================>isNotificationEnabledCallback=======================>"); }); ``` ## Notification.displayBadge displayBadge(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void Sets whether to enable the notification badge for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | enable | boolean | Yes | Whether to enable notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function displayBadgeCallback(err) { console.info("==========================>displayBadgeCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.displayBadge(bundle, false, displayBadgeCallback); ``` ## Notification.displayBadge displayBadge(bundle: BundleOption, enable: boolean): Promise\ Sets the notification slot for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| | enable | boolean | Yes | Whether to enable notification. | **Example** ```js var bundle = { bundle: "bundleName1", } Notification.displayBadge(bundle, false).then(() => { console.info("==========================>displayBadgeCallback=======================>"); }); ``` ## Notification.isBadgeDisplayed isBadgeDisplayed(bundle: BundleOption, callback: AsyncCallback\): void Checks whether the notification badge is enabled for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ------------------------ | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function isBadgeDisplayedCallback(err, data) { console.info("==========================>isBadgeDisplayedCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.isBadgeDisplayed(bundle, isBadgeDisplayedCallback); ``` ## Notification.isBadgeDisplayed isBadgeDisplayed(bundle: BundleOption): Promise\ Checks whether the notification badge is enabled for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js var bundle = { bundle: "bundleName1", } Notification.isBadgeDisplayed(bundle).then((data) => { console.info("==========================>isBadgeDisplayedCallback=======================>"); }); ``` ## Notification.setSlotByBundle setSlotByBundle(bundle: BundleOption, slot: NotificationSlot, callback: AsyncCallback\): void Sets the notification slot for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | slot | [NotificationSlot](#notificationslot) | Yes | Notification slot. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function setSlotByBundleCallback(err) { console.info("==========================>setSlotByBundleCallback=======================>"); } var bundle = { bundle: "bundleName1", } var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } Notification.setSlotByBundle(bundle, notificationSlot, setSlotByBundleCallback); ``` ## Notification.setSlotByBundle setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise\ Sets the notification slot for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| | slot | [NotificationSlot](#notificationslot) | Yes | Whether to enable notification. | **Example** ```js var bundle = { bundle: "bundleName1", } var notificationSlot = { type: Notification.SlotType.SOCIAL_COMMUNICATION } Notification.setSlotByBundle(bundle, notificationSlot).then(() => { console.info("==========================>setSlotByBundleCallback=======================>"); }); ``` ## Notification.getSlotsByBundle getSlotsByBundle(bundle: BundleOption, callback: AsyncCallback>): void Obtains the notification slots of a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ---------------------------------------- | ---- | -------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | callback | AsyncCallback> | Yes | Callback used to return the result.| **Example** ```js function getSlotsByBundleCallback(err, data) { console.info("==========================>getSlotsByBundleCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.getSlotsByBundle(bundle, getSlotsByBundleCallback); ``` ## Notification.getSlotsByBundle getSlotsByBundle(bundle: BundleOption): Promise> Obtains the notification slots of a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise> | Promise used to return the result.| **Example** ```js var bundle = { bundle: "bundleName1", } Notification.getSlotsByBundle(bundle).then((data) => { console.info("==========================>getSlotsByBundleCallback=======================>"); }); ``` ## Notification.getSlotNumByBundle getSlotNumByBundle(bundle: BundleOption, callback: AsyncCallback\): void Obtains the number of notification slots of a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------- | ---- | ---------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function getSlotNumByBundleCallback(err, data) { console.info("==========================>getSlotNumByBundleCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.getSlotNumByBundle(bundle, getSlotNumByBundleCallback); ``` ## Notification.getSlotNumByBundle getSlotNumByBundle(bundle: BundleOption): Promise\ Obtains the number of notification slots of a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js var bundle = { bundle: "bundleName1", } Notification.getSlotNumByBundle(bundle).then((data) => { console.info("==========================>getSlotNumByBundleCallback=======================>"); }); ``` ## Notification.remove remove(bundle: BundleOption, notificationKey: NotificationKey, callback: AsyncCallback\): void Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | --------------- | ----------------------------------- | ---- | -------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function removeCallback(err) { console.info("==========================>removeCallback=======================>"); } var bundle = { bundle: "bundleName1", } var notificationKey = { id: 0, label: "label", } Notification.remove(bundle, notificationKey, removeCallback); ``` ## Notification.remove remove(bundle: BundleOption, notificationKey: NotificationKey): Promise\ Removes a notification for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | --------------- | --------------- | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information.| | notificationKey | [NotificationKey](#notificationkey) | Yes | Notification key. | **Example** ```js var bundle = { bundle: "bundleName1", } var notificationKey = { id: 0, label: "label", } Notification.remove(bundle, notificationKey).then(() => { console.info("==========================>removeCallback=======================>"); }); ``` ## Notification.remove remove(hashCode: string, callback: AsyncCallback\): void Removes a notification for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | hashCode | string | Yes | Unique notification ID. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js var hashCode = 'hashCode' function removeCallback(err) { console.info("==========================>removeCallback=======================>"); } Notification.remove(hashCode, removeCallback); ``` ## Notification.remove remove(hashCode: string): Promise\ Removes a notification for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ---------- | ---- | ---------- | | hashCode | string | Yes | Unique notification ID.| **Example** ```js var hashCode = 'hashCode' Notification.remove(hashCode).then(() => { console.info("==========================>removeCallback=======================>"); }); ``` ## Notification.removeAll removeAll(bundle: BundleOption, callback: AsyncCallback\): void Removes all notifications for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function removeAllCallback(err) { console.info("==========================>removeAllCallback=======================>"); } var bundle = { bundle: "bundleName1", } Notification.removeAll(bundle, removeAllCallback); ``` ## Notification.removeAll removeAll(callback: AsyncCallback\): void Removes all notifications. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | -------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function removeAllCallback(err) { console.info("==========================>removeAllCallback=======================>"); } Notification.removeAll(removeAllCallback); ``` ## Notification.removeAll removeAll(bundle?: BundleOption): Promise\ Removes all notifications for a specified user. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | bundle | [BundleOption](#bundleoption) | No | Bundle information.| **Example** ```js Notification.removeAll().then(() => { console.info("==========================>removeAllCallback=======================>"); }); ``` ## Notification.removeAll8+ removeAll(userId: number, callback: AsyncCallback\): void Removes all notifications for a specified user. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | userId | number | Yes | ID of the user who receives the notification.| | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function removeAllCallback(err) { console.info("==========================>removeAllCallback=======================>"); } var userId = 1 Notification.removeAll(userId, removeAllCallback); ``` ## Notification.removeAll8+ removeAll(userId: number): Promise\ Removes all notifications for a specified user. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ------------ | ---- | ---------- | | userId | number | Yes | ID of the user who receives the notification.| **Example** ```js function removeAllCallback(err) { console.info("==========================>removeAllCallback=======================>"); } var userId = 1 Notification.removeAll(userId, removeAllCallback); ``` ## Notification.getAllActiveNotifications getAllActiveNotifications(callback: AsyncCallback>): void Obtains all active notifications. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | -------------------- | | callback | AsyncCallback> | Yes | Callback used to return the result.| **Example** ```js function getAllActiveNotificationsCallback(err, data) { console.info("==========================>getAllActiveNotificationsCallback=======================>"); } Notification.getAllActiveNotifications(getAllActiveNotificationsCallback); ``` ## Notification.getAllActiveNotifications getAllActiveNotifications(): Promise\\> Obtains all active notifications. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\\> | Promise used to return the result.| **Example** ```js Notification.getAllActiveNotifications().then((data) => { console.info("==========================>getAllActiveNotificationsCallback=======================>"); }); ``` ## Notification.getActiveNotificationCount getActiveNotificationCount(callback: AsyncCallback\): void Obtains the number of active notifications. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ---------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function getActiveNotificationCountCallback(err, data) { console.info("==========================>getActiveNotificationCountCallback=======================>"); } Notification.getActiveNotificationCount(getActiveNotificationCountCallback); ``` ## Notification.getActiveNotificationCount getActiveNotificationCount(): Promise\ Obtains the number of active notifications. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js Notification.getActiveNotificationCount().then((data) => { console.info("==========================>getActiveNotificationCountCallback=======================>"); }); ``` ## Notification.getActiveNotifications getActiveNotifications(callback: AsyncCallback>): void Obtains active notifications of this application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------------------ | ---- | ------------------------------ | | callback | AsyncCallback> | Yes | Callback used to return the result.| **Example** ```js function getActiveNotificationsCallback(err, data) { console.info("==========================>getActiveNotificationsCallback=======================>"); } Notification.getActiveNotifications(getActiveNotificationsCallback); ``` ## Notification.getActiveNotifications getActiveNotifications(): Promise\\> Obtains active notifications of this application. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\\> | Promise used to return the result.| **Example** ```js Notification.getActiveNotifications().then((data) => { console.info("==========================>getActiveNotificationsCallback=======================>"); }); ``` ## Notification.cancelGroup8+ cancelGroup(groupName: string, callback: AsyncCallback\): void Cancels a notification group of this application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | --------- | --------------------- | ---- | ---------------------------- | | groupName | string | Yes | Name of the notification group. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function cancelGroupCallback(err) { console.info("==========================>cancelGroupCallback=======================>"); } var groupName = "GroupName"; Notification.cancelGroup(groupName, cancelGroupCallback); ``` ## Notification.cancelGroup8+ cancelGroup(groupName: string): Promise\ Cancels a notification group of this application. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | --------- | ------ | ---- | -------------- | | groupName | string | Yes | Name of the notification group.| **Example** ```js var groupName = "GroupName"; Notification.cancelGroup(groupName).then(() => { console.info("==========================>cancelGroupPromise=======================>"); }); ``` ## Notification.removeGroupByBundle8+ removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback\): void Removes a notification group for a specified bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | --------- | --------------------- | ---- | ---------------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | groupName | string | Yes | Name of the notification group. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function removeGroupByBundleCallback(err) { console.info("==========================>removeGroupByBundleCallback=======================>"); } var bundleOption = {bundle: "Bundle"}; var groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName, removeGroupByBundleCallback); ``` ## Notification.removeGroupByBundle8+ removeGroupByBundle(bundle: BundleOption, groupName: string): Promise\ Removes a notification group for a specified bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | --------- | ------------ | ---- | -------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | groupName | string | Yes | Name of the notification group.| **Example** ```js var bundleOption = {bundle: "Bundle"}; var groupName = "GroupName"; Notification.removeGroupByBundle(bundleOption, groupName).then(() => { console.info("==========================>removeGroupByBundlePromise=======================>"); }); ``` ## Notification.setDoNotDisturbDate8+ setDoNotDisturbDate(date: DoNotDisturbDate, callback: AsyncCallback\): void Sets the DND time. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------- | | date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function setDoNotDisturbDateCallback(err) { console.info("==========================>setDoNotDisturbDateCallback=======================>"); } var doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) } Notification.setDoNotDisturbDate(doNotDisturbDate, setDoNotDisturbDateCallback); ``` ## Notification.setDoNotDisturbDate8+ setDoNotDisturbDate(date: DoNotDisturbDate): Promise\ Sets the DND time. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type | Mandatory| Description | | ---- | ---------------- | ---- | -------------- | | date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set.| **Example** ```js var doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) } Notification.setDoNotDisturbDate(doNotDisturbDate).then(() => { console.info("==========================>setDoNotDisturbDatePromise=======================>"); }); ``` ## Notification.setDoNotDisturbDate8+ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number, callback: AsyncCallback\): void Sets the DND time for a specified user. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------- | ---- | ---------------------- | | date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set. | | userId | number | Yes | User ID.| | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function setDoNotDisturbDateCallback(err) { console.info("==========================>setDoNotDisturbDateCallback=======================>"); } var doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) } var userId = 1 Notification.setDoNotDisturbDate(doNotDisturbDate, userId, setDoNotDisturbDateCallback); ``` ## Notification.setDoNotDisturbDate8+ setDoNotDisturbDate(date: DoNotDisturbDate, userId: number): Promise\ Sets the DND time for a specified user. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | ------ | ---------------- | ---- | -------------- | | date | [DoNotDisturbDate](#donotdisturbdate8) | Yes | DND time to set.| | userId | number | Yes | User ID.| **Example** ```js var doNotDisturbDate = { type: Notification.DoNotDisturbType.TYPE_ONCE, begin: new Date(), end: new Date(2021, 11, 15, 18, 0) } var userId = 1 Notification.setDoNotDisturbDate(doNotDisturbDate, userId).then(() => { console.info("==========================>setDoNotDisturbDatePromise=======================>"); }); ``` ## Notification.getDoNotDisturbDate8+ getDoNotDisturbDate(callback: AsyncCallback\): void Obtains the DND time. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | ---------------------- | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes | Callback used to return the result.| **Example** ```js function getDoNotDisturbDateCallback(err,data) { console.info("==========================>getDoNotDisturbDateCallback=======================>"); } Notification.getDoNotDisturbDate(getDoNotDisturbDateCallback); ``` ## Notification.getDoNotDisturbDate8+ getDoNotDisturbDate(): Promise\ Obtains the DND time. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.| **Example** ```js Notification.getDoNotDisturbDate().then((data) => { console.info("==========================>getDoNotDisturbDatePromise=======================>"); }); ``` ## Notification.getDoNotDisturbDate8+ getDoNotDisturbDate(userId: number, callback: AsyncCallback\): void Obtains the DND time of a specified user. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | ---------------------- | | callback | AsyncCallback\<[DoNotDisturbDate](#donotdisturbdate8)\> | Yes | Callback used to return the result.| | userId | number | Yes | User ID.| **Example** ```js function getDoNotDisturbDateCallback(err,data) { console.info("==========================>getDoNotDisturbDateCallback=======================>"); } var userId = 1 Notification.getDoNotDisturbDate(userId, getDoNotDisturbDateCallback); ``` ## Notification.getDoNotDisturbDate8+ getDoNotDisturbDate(userId: number): Promise\ Obtains the DND time of a specified user. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | ---------------------- | | userId | number | Yes | User ID.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\<[DoNotDisturbDate](#donotdisturbdate8)\> | Promise used to return the result.| **Example** ```js var userId = 1 Notification.getDoNotDisturbDate(userId).then((data) => { console.info("==========================>getDoNotDisturbDatePromise=======================>"); }); ``` ## Notification.supportDoNotDisturbMode8+ supportDoNotDisturbMode(callback: AsyncCallback\): void Checks whether the DND mode is supported. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js function supportDoNotDisturbModeCallback(err,data) { console.info("==========================>supportDoNotDisturbModeCallback=======================>"); } Notification.supportDoNotDisturbMode(supportDoNotDisturbModeCallback); ``` ## Notification.supportDoNotDisturbMode8+ supportDoNotDisturbMode(): Promise\ Checks whether the DND mode is supported. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js Notification.supportDoNotDisturbMode().then((data) => { console.info("==========================>supportDoNotDisturbModePromise=======================>"); }); ``` ## Notification.isSupportTemplate8+ isSupportTemplate(templateName: string, callback: AsyncCallback\): void Checks whether a specified template exists. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | ------------ | ------------------------ | ---- | -------------------------- | | templateName | string | Yes | Template name. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```javascript var templateName = 'process'; function isSupportTemplateCallback(err, data) { console.info("isSupportTemplateCallback"); } Notification.isSupportTemplate(templateName, isSupportTemplateCallback); ``` ## Notification.isSupportTemplate8+ isSupportTemplate(templateName: string): Promise\ Checks whether a specified template exists. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | ------------ | ------ | ---- | -------- | | templateName | string | Yes | Template name.| **Return value** | Type | Description | | ------------------ | --------------- | | Promise\ | Promise used to return the result.| **Example** ```javascript var templateName = 'process'; Notification.isSupportTemplate(templateName).then((data) => { console.info("isSupportTemplateCallback"); }); ``` ## Notification.requestEnableNotification8+ requestEnableNotification(callback: AsyncCallback\): void Requests notification to be enabled for this application. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```javascript function requestEnableNotificationCallback() { console.log('------------- requestEnabledNotification --------------'); }; Notification.requestEnableNotification(requestEnableNotificationCallback); ``` ## Notification.requestEnableNotification8+ requestEnableNotification(): Promise\ Requests notification to be enabled for this application. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Example** ```javascript Notification.requestEnableNotification() .then(() => { console.info("requestEnableNotification "); }); ``` ## Notification.enableDistributed8+ enableDistributed(enable: boolean, callback: AsyncCallback\): void Sets whether this device supports distributed notifications. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | enable | boolean | Yes | Whether the device supports distributed notifications.
**true**: The device supports distributed notifications.
**false**: The device does not support distributed notifications.| | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```javascript function enabledNotificationCallback() { console.log('----------- enableDistributed ------------'); }; var enable = true Notification.enableDistributed(enable, enabledNotificationCallback); ``` ## Notification.enableDistributed8+ enableDistributed(enable: boolean): Promise\ Sets whether this device supports distributed notifications. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | enable | boolean | Yes | Whether the device supports distributed notifications.
**true**: The device supports distributed notifications.
**false**: The device does not support distributed notifications.| **Example** ```javascript var enable = true Notification.enableDistributed(enable) .then(() => { console.log('-------- enableDistributed ----------'); }); ``` ## Notification.isDistributedEnabled8+ isDistributedEnabled(callback: AsyncCallback\): void Obtains whether this device supports distributed notifications. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```javascript function isDistributedEnabledCallback() { console.log('----------- isDistributedEnabled ------------'); }; Notification.isDistributedEnabled(isDistributedEnabledCallback); ``` ## Notification.isDistributedEnabled8+ isDistributedEnabled(): Promise\ Obtains whether this device supports distributed notifications. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Return value** | Type | Description | | ------------------ | --------------- | | Promise\ | Promise used to return the result.
**true**: The device supports distributed notifications.
**false**: The device does not support distributed notifications.| **Example** ```javascript Notification.isDistributedEnabled() .then((data) => { console.log('-------- isDistributedEnabled ----------'); }); ``` ## Notification.enableDistributedByBundle8+ enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback\): void Sets whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | | enable | boolean | Yes | Whether the device supports distributed notifications. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```javascript function enableDistributedByBundleCallback() { console.log('----------- enableDistributedByBundle ------------'); }; var bundle = { bundle: "bundleName1", } var enable = true Notification.enableDistributedByBundle(bundle, enable, enableDistributedByBundleCallback); ``` ## Notification.enableDistributedByBundle8+ enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise\ Sets whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | | enable | boolean | Yes | Whether the device supports distributed notifications. | **Example** ```javascript var bundle = { bundle: "bundleName1", } var enable = true Notification.enableDistributedByBundle(bundle, enable) .then(() => { console.log('-------- enableDistributedByBundle ----------'); }); ``` ## Notification.isDistributedEnabledByBundle8+ isDistributedEnabledByBundle(bundle: BundleOption, callback: AsyncCallback\): void Obtains whether an application supports distributed notifications based on the bundle. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```javascript function isDistributedEnabledByBundleCallback(data) { console.log('----------- isDistributedEnabledByBundle ------------', data); }; var bundle = { bundle: "bundleName1", } Notification.isDistributedEnabledByBundle(bundle, isDistributedEnabledByBundleCallback); ``` ## Notification.isDistributedEnabledByBundle8+ isDistributedEnabledByBundle(bundle: BundleOption): Promise\ Obtains whether an application supports distributed notifications based on the bundle. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | ------------------------ | ---- | -------------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Application bundle. | **Return value** | Type | Description | | ------------------ | --------------- | | Promise\ | Promise used to return the result.
**true**: The device supports distributed notifications.
**false**: The device does not support distributed notifications.| **Example** ```javascript var bundle = { bundle: "bundleName1", } Notification.isDistributedEnabledByBundle(bundle) .then((data) => { console.log('-------- isDistributedEnabledByBundle ----------', data); }); ``` ## Notification.getDeviceRemindType8+ getDeviceRemindType(callback: AsyncCallback\): void Obtains the notification reminder type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------- | --------------------------------- | ---- | -------------------------- | | callback | AsyncCallback\<[DeviceRemindType](#deviceremindtype8)\> | Yes | Callback used to return the result.| **Example** ```javascript function getDeviceRemindTypeCallback(data) { console.log('----------- getDeviceRemindType ------------', data); }; Notification.getDeviceRemindType(getDeviceRemindTypeCallback); ``` ## Notification.getDeviceRemindType8+ getDeviceRemindType(): Promise\ Obtains the notification reminder type. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Return value** | Type | Description | | ------------------ | --------------- | | Promise\<[DeviceRemindType](#deviceremindtype8)\> | Promise used to return the result.| **Example** ```javascript Notification.getDeviceRemindType() .then((data) => { console.log('-------- getDeviceRemindType ----------', data); }); ``` ## Notification.publishAsBundle9+ publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number, callback: AsyncCallback\): void Publishes an agent-powered notification. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | request | [NotificationRequest](#notificationrequest) | Yes | **NotificationRequest** object.| | representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | | userId | number | Yes | ID of the user who receives the notification. | | callback | AsyncCallback | Yes | Callback used to return the result. | **Example** ```js // Callback for publishAsBundle function publishAsBundleCallback(err) { console.info("==========================>publishAsBundleCallback=======================>"); } // Bundle name of the application whose notification function is taken over by the reminder agent let representativeBundle = "com.example.demo" // ID of the user who receives the notification let userId = 100 // NotificationRequest object let notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", additionalText: "test_additionalText" } } } Notification.publishAsBundle(notificationRequest, representativeBundle, userId, publishAsBundleCallback); ``` ## Notification.publishAsBundle9+ publishAsBundle(request: NotificationRequest, representativeBundle: string, userId: number): Promise\ Publishes a notification through the reminder agent. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ------------------------------------------- | ---- | --------------------------------------------- | | request | [NotificationRequest](#notificationrequest) | Yes | **NotificationRequest** object.| | representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | | userId | number | Yes | ID of the user who receives the notification. | **Example** ```js // Bundle name of the application whose notification function is taken over by the reminder agent let representativeBundle = "com.example.demo" // ID of the user who receives the notification let userId = 100 // NotificationRequest object var notificationRequest = { id: 1, content: { contentType: Notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: { title: "test_title", text: "test_text", additionalText: "test_additionalText" } } } Notification.publishAsBundle(notificationRequest, representativeBundle, userId).then(() => { console.info("==========================>publishAsBundleCallback=======================>"); }); ``` ## Notification.cancelAsBundle9+ cancelAsBundle(id: number, representativeBundle: string, userId: number, callback: AsyncCallback\): void Cancels a notification published by the reminder agent. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ------------- | ---- | ------------------------ | | id | number | Yes | Notification ID. | | representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent. | | userId | number | Yes | ID of the user who receives the notification. | | callback | AsyncCallback | Yes | Callback used to return the result.| **Example** ```js //cancelAsBundle function cancelAsBundleCallback(err) { console.info("==========================>cancelAsBundleCallback=======================>"); } // Bundle name of the application whose notification function is taken over by the reminder agent let representativeBundle = "com.example.demo" // ID of the user who receives the notification let userId = 100 Notification.cancelAsBundle(0, representativeBundle, userId, cancelAsBundleCallback); ``` ## Notification.cancelAsBundle9+ cancelAsBundle(id: number, representativeBundle: string, userId: number): Promise\ Publishes a notification through the reminder agent. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.NOTIFICATION_AGENT_CONTROLLER **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name | Type | Mandatory| Description | | -------------------- | ------ | ---- | ------------------ | | id | number | Yes | Notification ID. | | representativeBundle | string | Yes | Bundle name of the application whose notification function is taken over by the reminder agent.| | userId | number | Yes | ID of the user who receives the notification.| **Example** ```js // Bundle name of the application whose notification function is taken over by the reminder agent let representativeBundle = "com.example.demo" // ID of the user who receives the notification let userId = 100 Notification.cancelAsBundle(0, representativeBundle, userId).then(() => { console.info("==========================>cancelAsBundleCallback=======================>"); }); ``` ## Notification.enableNotificationSlot 9+ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback\): void Sets the enabled status for a notification slot of a specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ---------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | type | [SlotType](#slottype) | Yes | Notification slot type. | | enable | boolean | Yes | Whether to enable notification. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js //enableNotificationSlot function enableSlotCallback(err) { console.log('===================>enableSlotCallback==================>'); }; Notification.enableNotificationSlot( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION, true, enableSlotCallback); ``` ## Notification.enableNotificationSlot 9+ enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise\ Sets the enabled status for a notification slot of a specified type. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | -------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | type | [SlotType](#slottype) | Yes | Notification slot type.| | enable | boolean | Yes | Whether to enable notification. | **Example** ```js //enableNotificationSlot Notification.enableNotificationSlot( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION, true).then(() => { console.log('====================>enableNotificationSlot====================>'); }); ``` ## Notification.isNotificationSlotEnabled 9+ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType, callback: AsyncCallback\): void Obtains the enabled status of the notification slot of a specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ---------------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | type | [SlotType](#slottype) | Yes | Notification slot type. | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js //isNotificationSlotEnabled function getEnableSlotCallback(err, data) { console.log('===================>getEnableSlotCallback=================='); }; Notification.isNotificationSlotEnabled( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION, getEnableSlotCallback); ``` ## Notification.isNotificationSlotEnabled 9+ isNotificationSlotEnabled(bundle: BundleOption, type: SlotType): Promise\ Obtains the enabled status of the notification slot of a specified type. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | -------------- | | bundle | [BundleOption](#bundleoption) | Yes | Bundle information. | | type | [SlotType](#slottype) | Yes | Notification slot type.| **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the enabled status of the notification slot of the specified type.| **Example** ```js //isNotificationSlotEnabled Notification.isNotificationSlotEnabled( { bundle: "ohos.samples.notification", }, Notification.SlotType.SOCIAL_COMMUNICATION ).then((data) => { console.log('====================>isNotificationSlotEnabled====================>'); }); ``` ## Notification.setSyncNotificationEnabledWithoutApp9+ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean, callback: AsyncCallback\): void Sets whether to sync notifications to devices where the application is not installed. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | -------------- | | userId | number | Yes | User ID. | | enable | boolean | Yes | Whether the feature is enabled.
**true**: enabled
**false**: disabled | | callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** ```js let userId = 100; let enable = true; function setSyncNotificationEnabledWithoutAppCallback(err) { console.log('setSyncNotificationEnabledWithoutAppCallback'); } Notification.setSyncNotificationEnabledWithoutApp(userId, enable, setSyncNotificationEnabledWithoutAppCallback); ``` ## Notification.setSyncNotificationEnabledWithoutApp9+ setSyncNotificationEnabledWithoutApp(userId: number, enable: boolean): Promise\ Sets whether to sync notifications to devices where the application is not installed. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | -------------- | | userId | number | Yes | User ID. | | enable | boolean | Yes | Whether the feature is enabled.
**true**: enabled
**false**: disabled | **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.| **Example** ```js let userId = 100; let enable = true; Notification.setSyncNotificationEnabledWithoutApp(userId, enable) .then((data) => { console.log('setSyncNotificationEnabledWithoutApp'); }) .catch((err) => { console.log('setSyncNotificationEnabledWithoutApp, err:', err); }); ``` ## Notification.getSyncNotificationEnabledWithoutApp9+ getSyncNotificationEnabledWithoutApp(userId: number, callback: AsyncCallback\): void Obtains whether notifications are synced to devices where the application is not installed. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | -------------- | | userId | number | Yes | User ID. | | callback | AsyncCallback\ | Yes | Callback used to return the result.
**true**: Notifications are synced to devices where the application is not installed.
**false**: Notifications are not synced to devices where the application is not installed.| **Example** ```js let userId = 100; function getSyncNotificationEnabledWithoutAppCallback(data, err) { if (err) { console.log('getSyncNotificationEnabledWithoutAppCallback, err' + err); } else { console.log('getSyncNotificationEnabledWithoutAppCallback, data' + data); } } Notification.getSyncNotificationEnabledWithoutApp(userId, getSyncNotificationEnabledWithoutAppCallback); ``` ## Notification.getSyncNotificationEnabledWithoutApp9+ getSyncNotificationEnabledWithoutApp(userId: number): Promise\ Obtains whether notifications are synced to devices where the application is not installed. This API uses a promise to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Required permissions**: ohos.permission.NOTIFICATION_CONTROLLER **Parameters** | Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | -------------- | | userId | number | Yes | User ID. | **Return value** | Type | Description | | ----------------------------------------------------------- | ------------------------------------------------------------ | | Promise\ | Promise used to return the result.
**true**: Notifications are synced to devices where the application is not installed.
**false**: Notifications are not synced to devices where the application is not installed.| **Example** ```js let userId = 100; Notification.getSyncNotificationEnabledWithoutApp(userId) .then((data) => { console.log('getSyncNotificationEnabledWithoutApp, data:', data); }) .catch((err) => { console.log('getSyncNotificationEnabledWithoutApp, err:', err); }); ``` ## NotificationSubscriber **System API**: This is a system API and cannot be called by third-party applications. ### onConsume onConsume?: (data: [SubscribeCallbackData](#subscribecallbackdata)) => void Callback for receiving notifications. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type| Mandatory| Description| | ------------ | ------------------------ | ---- | -------------------------- | | data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.| **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onConsumeCallback(data) { console.info('===> onConsume in test'); let req = data.request; console.info('===> onConsume callback req.id:' + req.id); let wantAgent = data.wantAgent; wantAgent .getWant(wantAgent) .then((data1) => { console.log('===> getWant success want:' + JSON.stringify(data1)); }) .catch((err) => { console.error('===> getWant failed because' + JSON.stringify(err)); }); console.info('===> onConsume callback req.wantAgent:' + JSON.stringify(req.wantAgent)); }; var subscriber = { onConsume: onConsumeCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onCancel onCancel?:(data: [SubscribeCallbackData](#subscribecallbackdata)) => void Callback for removing notifications. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type| Mandatory| Description| | ------------ | ------------------------ | ---- | -------------------------- | | data | AsyncCallback\<[SubscribeCallbackData](#subscribecallbackdata)\> | Yes| Notification information returned.| **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onCancelCallback(data) { console.info('===> onCancel in test'); let req = data.request; console.info('===> onCancel callback req.id:' + req.id); } var subscriber = { onCancel: onCancelCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onUpdate onUpdate?:(data: [NotificationSortingMap](#notificationsortingmap)) => void Callback for notification sorting updates. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type| Mandatory| Description| | ------------ | ------------------------ | ---- | -------------------------- | | data | [NotificationSortingMap](#notificationsortingmap) | Yes| Notification information returned.| **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onUpdateCallback() { console.info('===> onUpdate in test'); } var subscriber = { onUpdate: onUpdateCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onConnect onConnect?:() => void Callback for subscription. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onConnectCallback() { console.info('===> onConnect in test'); } var subscriber = { onConnect: onConnectCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onDisconnect onDisconnect?:() => void Callback for unsubscription. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onDisconnectCallback() { console.info('===> onDisconnect in test'); } var subscriber = { onDisconnect: onDisconnectCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onDestroy onDestroy?:() => void Callback for service disconnection. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onDestroyCallback() { console.info('===> onDestroy in test'); } var subscriber = { onDestroy: onDestroyCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onDoNotDisturbDateChange8+ onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](#donotdisturbdate8)) => void Callback for DND time setting updates. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type| Mandatory| Description| | ------------ | ------------------------ | ---- | -------------------------- | | mode | notification.[DoNotDisturbDate](#donotdisturbdate8) | Yes| DND time setting updates.| **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onDoNotDisturbDateChangeCallback() { console.info('===> onDoNotDisturbDateChange in test'); } var subscriber = { onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ### onEnabledNotificationChanged8+ onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](#enablednotificationcallbackdata8)) => void Listens for the notification enable status changes. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. **Parameters** | Name| Type| Mandatory| Description| | ------------ | ------------------------ | ---- | -------------------------- | | callback | AsyncCallback\<[EnabledNotificationCallbackData](#enablednotificationcallbackdata8)\> | Yes| Callback used to return the result.| **Example** ```javascript function subscribeCallback(err) { if (err.code) { console.info("subscribe failed " + JSON.stringify(err)); } else { console.info("subscribeCallback"); } }; function onEnabledNotificationChangedCallback(callbackData) { console.info("bundle: ", callbackData.bundle); console.info("uid: ", callbackData.uid); console.info("enable: ", callbackData.enable); }; var subscriber = { onEnabledNotificationChanged: onEnabledNotificationChangedCallback }; Notification.subscribe(subscriber, subscribeCallback); ``` ## SubscribeCallbackData **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Readable| Writable| Type | Description | | --------------- | ---- | --- | ------------------------------------------------- | -------- | | request | Yes | No | [NotificationRequest](#notificationrequest) | Notification content.| | sortingMap | Yes | No | [NotificationSortingMap](#notificationsortingmap) | Notification sorting information.| | reason | Yes | No | number | Reason for deletion.| | sound | Yes | No | string | Sound used for notification.| | vibrationValues | Yes | No | Array\ | Vibration used for notification.| ## EnabledNotificationCallbackData8+ **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Readable| Writable| Type | Description | | ------ | ---- | --- | ------- | ---------------- | | bundle | Yes | No | string | Bundle name of the application. | | uid | Yes | No | number | UID of the application. | | enable | Yes | No | boolean | Notification enabled status of the application.| ## DoNotDisturbDate8+ **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Readable| Writable| Type | Description | | ----- | ---- | --- | ------------------------------------- | ------------------------ | | type | Yes | No | [DoNotDisturbType](#donotdisturbtype8) | DND time type.| | begin | Yes | No | Date | DND start time.| | end | Yes | No | Date | DND end time.| ## DoNotDisturbType8+ **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Value | Description | | ------------ | ---------------- | ------------------------------------------ | | TYPE_NONE | 0 | Non-DND. | | TYPE_ONCE | 1 | One-shot DND at the specified time segment (only considering the hour and minute).| | TYPE_DAILY | 2 | Daily DND at the specified time segment (only considering the hour and minute).| | TYPE_CLEARLY | 3 | DND at the specified time segment (considering the year, month, day, hour, and minute). | ## ContentType **System capability**: SystemCapability.Notification.Notification | Name | Value | Description | | --------------------------------- | ----------- | ------------------ | | NOTIFICATION_CONTENT_BASIC_TEXT | NOTIFICATION_CONTENT_BASIC_TEXT | Normal text notification. | | NOTIFICATION_CONTENT_LONG_TEXT | NOTIFICATION_CONTENT_LONG_TEXT | Long text notification. | | NOTIFICATION_CONTENT_PICTURE | NOTIFICATION_CONTENT_PICTURE | Picture-attached notification. | | NOTIFICATION_CONTENT_CONVERSATION | NOTIFICATION_CONTENT_CONVERSATION | Conversation notification. | | NOTIFICATION_CONTENT_MULTILINE | NOTIFICATION_CONTENT_MULTILINE | Multi-line text notification.| ## SlotLevel **System capability**: SystemCapability.Notification.Notification | Name | Value | Description | | --------------------------------- | ----------- | ------------------ | | LEVEL_NONE | 0 | The notification function is disabled. | | LEVEL_MIN | 1 | The notification function is enabled, but the notification icon is not displayed in the status bar, with no banner or alert tone.| | LEVEL_LOW | 2 | The notification function is enabled, and the notification icon is displayed in the status bar, with no banner or alert tone.| | LEVEL_DEFAULT | 3 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone but no banner.| | LEVEL_HIGH | 4 | The notification feature is enabled, and the notification icon is displayed in the status bar, with an alert tone and banner.| ## BundleOption **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | ------ | ---- | --- | ------ | ------ | | bundle | Yes | Yes | string | Bundle name. | | uid | Yes | Yes | number | User ID.| ## NotificationKey **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | ----- | ---- | --- | ------ | -------- | | id | Yes | Yes | number | Notification ID. | | label | Yes | Yes | string | Notification label.| ## SlotType **System capability**: SystemCapability.Notification.Notification | Name | Value | Description | | -------------------- | -------- | ---------- | | UNKNOWN_TYPE | 0 | Unknown type.| | SOCIAL_COMMUNICATION | 1 | Notification slot for social communication.| | SERVICE_INFORMATION | 2 | Notification slot for service information.| | CONTENT_INFORMATION | 3 | Notification slot for content consultation.| | OTHER_TYPES | 0xFFFF | Notification slot for other purposes.| ## NotificationActionButton **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | --------- | --- | ---- | ----------------------------------------------- | ------------------------- | | title | Yes | Yes | string | Button title. | | wantAgent | Yes | Yes | WantAgent | **WantAgent** of the button.| | extras | Yes | Yes | { [key: string]: any } | Extra information of the button. | | userInput8+ | Yes | Yes | [NotificationUserInput](#notificationuserinput8) | User input object. | ## NotificationBasicContent **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | -------------- | ---- | ---- | ------ | ---------------------------------- | | title | Yes | Yes | string | Notification title. | | text | Yes | Yes | string | Notification content. | | additionalText | Yes | Yes | string | Additional information of the notification.| ## NotificationLongTextContent **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | -------------- | ---- | --- | ------ | -------------------------------- | | title | Yes | Yes | string | Notification title. | | text | Yes | Yes | string | Notification content. | | additionalText | Yes | Yes | string | Additional information of the notification.| | longText | Yes | Yes | string | Long text of the notification. | | briefText | Yes | Yes | string | Brief text of the notification.| | expandedTitle | Yes | Yes | string | Title of the notification in the expanded state. | ## NotificationMultiLineContent **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | -------------- | --- | --- | --------------- | -------------------------------- | | title | Yes | Yes | string | Notification title. | | text | Yes | Yes | string | Notification content. | | additionalText | Yes | Yes | string | Additional information of the notification.| | briefText | Yes | Yes | string | Brief text of the notification.| | longTitle | Yes | Yes | string | Title of the notification in the expanded state. | | lines | Yes | Yes | Array\ | Multi-line text of the notification. | ## NotificationPictureContent **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | -------------- | ---- | --- | -------------- | -------------------------------- | | title | Yes | Yes | string | Notification title. | | text | Yes | Yes | string | Notification content. | | additionalText | Yes | Yes | string | Additional information of the notification.| | briefText | Yes | Yes | string | Brief text of the notification.| | expandedTitle | Yes | Yes | string | Title of the notification in the expanded state. | | picture | Yes | Yes | image.PixelMap | Picture attached to the notification. | ## NotificationContent **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | ----------- | ---- | --- | ------------------------------------------------------------ | ------------------ | | contentType | Yes | Yes | [ContentType](#contenttype) | Notification content type. | | normal | Yes | Yes | [NotificationBasicContent](#notificationbasiccontent) | Normal text. | | longText | Yes | Yes | [NotificationLongTextContent](#notificationlongtextcontent) | Long text.| | multiLine | Yes | Yes | [NotificationMultiLineContent](#notificationmultilinecontent) | Multi-line text. | | picture | Yes | Yes | [NotificationPictureContent](#notificationpicturecontent) | Picture-attached. | ## NotificationFlagStatus8+ **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Value | Description | | -------------- | --- | --------------------------------- | | TYPE_NONE | 0 | The default flag is used. | | TYPE_OPEN | 1 | The notification flag is enabled. | | TYPE_CLOSE | 2 | The notification flag is disabled. | ## NotificationFlags8+ **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | ---------------- | ---- | ---- | ---------------------- | --------------------------------- | | soundEnabled | Yes | No | NotificationFlagStatus | Whether to enable the sound alert for the notification. | | vibrationEnabled | Yes | No | NotificationFlagStatus | Whether to enable vibration for the notification. | ## NotificationRequest **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | --------------------- | ---- | --- | --------------------------------------------- | -------------------------- | | content | Yes | Yes | [NotificationContent](#notificationcontent) | Notification content. | | id | Yes | Yes | number | Notification ID. | | slotType | Yes | Yes | [SlotType](#slottype) | Slot type. | | isOngoing | Yes | Yes | boolean | Whether the notification is an ongoing notification. | | isUnremovable | Yes | Yes | boolean | Whether the notification can be removed. | | deliveryTime | Yes | Yes | number | Time when the notification is sent. | | tapDismissed | Yes | Yes | boolean | Whether the notification is automatically cleared. | | autoDeletedTime | Yes | Yes | number | Time when the notification is automatically cleared. | | wantAgent | Yes | Yes | WantAgent | **WantAgent** instance to which the notification will be redirected after being clicked. | | extraInfo | Yes | Yes | {[key: string]: any} | Extended parameters. | | color | Yes | Yes | number | Background color of the notification. | | colorEnabled | Yes | Yes | boolean | Whether the notification background color is enabled. | | isAlertOnce | Yes | Yes | boolean | Whether the notification triggers an alert only once.| | isStopwatch | Yes | Yes | boolean | Whether to display the stopwatch. | | isCountDown | Yes | Yes | boolean | Whether to display the countdown time. | | isFloatingIcon | Yes | Yes | boolean | Whether the notification is displayed as a floating icon. | | label | Yes | Yes | string | Notification label. | | badgeIconStyle | Yes | Yes | number | Notification badge type. | | showDeliveryTime | Yes | Yes | boolean | Whether to display the time when the notification is delivered. | | actionButtons | Yes | Yes | Array\<[NotificationActionButton](#notificationactionbutton)\> | Buttons in the notification. Up to two buttons are allowed. | | smallIcon | Yes | Yes | PixelMap | Small notification icon. | | largeIcon | Yes | Yes | PixelMap | Large notification icon. | | creatorBundleName | Yes | No | string | Name of the bundle that creates the notification. | | creatorUid | Yes | No | number | UID used for creating the notification. | | creatorPid | Yes | No | number | PID used for creating the notification. | | creatorUserId8+| Yes | No | number | ID of the user who creates the notification. | | hashCode | Yes | No | string | Unique ID of the notification. | | classification | Yes | Yes | string | Notification category.
**System API**: This is a system API and cannot be called by third-party applications. | | groupName8+| Yes | Yes | string | Group notification name. | | template8+ | Yes | Yes | [NotificationTemplate](#notificationtemplate8) | Notification template. | | isRemoveAllowed8+ | Yes | No | boolean | Whether the notification can be removed.
**System API**: This is a system API and cannot be called by third-party applications. | | source8+ | Yes | No | number | Notification source.
**System API**: This is a system API and cannot be called by third-party applications. | | distributedOption8+ | Yes | Yes | [DistributedOptions](#distributedoptions8) | Option of distributed notification. | | deviceId8+ | Yes | No | string | Device ID of the notification source.
**System API**: This is a system API and cannot be called by third-party applications. | | notificationFlags8+ | Yes | No | [NotificationFlags](#notificationflags8) | Notification flags. | | removalWantAgent9+ | Yes | Yes | WantAgent | **WantAgent** instance to which the notification will be redirected when it is removed. | | badgeNumber9+ | Yes | Yes | number | Number of notifications displayed on the application icon. | ## DistributedOptions8+ **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | ---------------------- | ---- | ---- | -------------- | ---------------------------------- | | isDistributed | Yes | Yes | boolean | Whether the notification is a distributed notification. | | supportDisplayDevices | Yes | Yes | Array\ | Types of the devices to which the notification can be synchronized. | | supportOperateDevices | Yes | Yes | Array\ | Devices on which notification can be enabled. | | remindType | Yes | No | number | Notification reminder type.
**System API**: This is a system API and cannot be called by third-party applications. | ## NotificationSlot **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | -------------------- | ---- | --- | --------------------- | ------------------------------------------ | | type | Yes | Yes | [SlotType](#slottype) | Slot type. | | level | Yes | Yes | number | Notification level. If this parameter is not set, the default value is used based on the notification slot type.| | desc | Yes | Yes | string | Notification slot description. | | badgeFlag | Yes | Yes | boolean | Whether to display the badge. | | bypassDnd | Yes | Yes | boolean | Whether to bypass the DND mode in the system. | | lockscreenVisibility | Yes | Yes | number | Mode for displaying the notification on the lock screen. | | vibrationEnabled | Yes | Yes | boolean | Whether vibration is supported for the notification. | | sound | Yes | Yes | string | Notification alert tone. | | lightEnabled | Yes | Yes | boolean | Whether the indicator blinks for the notification. | | lightColor | Yes | Yes | number | Indicator color of the notification. | | vibrationValues | Yes | Yes | Array\ | Vibration mode of the notification. | | enabled9+ | Yes | No | boolean | Enabled status of the notification slot. | ## NotificationSorting **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Readable| Writable| Type | Description | | -------- | ---- | --- | ------------------------------------- | ------------ | | slot | Yes | No | [NotificationSlot](#notificationslot) | Notification slot content.| | hashCode | Yes | No | string | Unique ID of the notification.| | ranking | Yes | No | number | Notification sequence number.| ## NotificationSortingMap **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Readable| Writable| Type | Description | | -------------- | ---- | --- | ------------------------------------------------------------ | ---------------- | | sortings | Yes | No | {[key: string]: [NotificationSorting](#notificationsorting)} | Array of notification sorting information.| | sortedHashCode | Yes | No | Array\ | Array of unique notification IDs.| ## NotificationSubscribeInfo **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Readable| Writable| Type | Description | | ----------- | --- | ---- | --------------- | ------------------------------- | | bundleNames | Yes | Yes | Array\ | Bundle names of the applications whose notifications are to be subscribed to.| | userId | Yes | Yes | number | User whose notifications are to be subscribed to. | ## NotificationTemplate8+ **System capability**: SystemCapability.Notification.Notification | Name| Type | Readable| Writable| Description | | ---- | ---------------------- | ---- | ---- | ---------- | | name | string | Yes | Yes | Template name.| | data | {[key:string]: Object} | Yes | Yes | Template data.| ## NotificationUserInput8+ **System capability**: SystemCapability.Notification.Notification | Name | Readable| Writable| Type | Description | | -------- | --- | ---- | ------ | ----------------------------- | | inputKey | Yes | Yes | string | Key to identify the user input.| ## DeviceRemindType8+ **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Value | Description | | -------------------- | --- | --------------------------------- | | IDLE_DONOT_REMIND | 0 | The device is not in use. No notification is required. | | IDLE_REMIND | 1 | The device is not in use. | | ACTIVE_DONOT_REMIND | 2 | The device is in use. No notification is required. | | ACTIVE_REMIND | 3 | The device is in use. | ## SourceType8+ **System capability**: SystemCapability.Notification.Notification **System API**: This is a system API and cannot be called by third-party applications. | Name | Value | Description | | -------------------- | --- | -------------------- | | TYPE_NORMAL | 0 | Normal notification. | | TYPE_CONTINUOUS | 1 | Continuous notification. | | TYPE_TIMER | 2 | Timed notification. |