1# Managing Notification Slots 2The system supports a range of notification slots. Different notification slots are assigned different reminder modes. You can choose notification slots for your application and manage them as required, such as creating, querying, and deleting notification slots. 3 4## Notification Slots 5 6The following table lists the notification slots and their reminder modes. **Y** indicates that the feature is supported, and **N** indicates that the feature is not supported. 7 8<!--RP1--> 9<!--RP1End--> 10 11| SlotType | Value | Category | Notification Panel| Banner| Lock Screen| Alert Tone/Vibration| Status Bar Icon| Automatic Screen-on| 12| -------------------- | ------ | --------| ------- |------|------|----------|-----------|---------| 13| UNKNOWN_TYPE | 0 | Unknown| Y | N | N | N | N | N | 14| SOCIAL_COMMUNICATION | 1 | Social communication| Y | Y | Y | Y | Y | Y | 15| SERVICE_INFORMATION | 2 | Service notification| Y | Y | Y | Y | Y | Y | 16| CONTENT_INFORMATION | 3 | Content and news| Y | N | N | N | N | N | 17| CUSTOMER_SERVICE | 5 | Customer service| Y | N | N | Y | Y | N | 18| OTHER_TYPES | 0xFFFF | Other | Y | N | N | N | N | N | 19 20 21## Available APIs 22 23The main notification slot APIs are as follows. For details about other APIs, see [@ohos.notificationManager (NotificationManager)](../reference/apis-notification-kit/js-apis-notificationManager.md). 24 25| **API**| **Description**| 26| ---------- | -------- | 27| addSlot(type: SlotType): Promise\<void\> | Adds a notification slot. | 28| getSlot(slotType: SlotType): Promise\<NotificationSlot\> | Obtains a notification slot. | 29| removeSlot(slotType: SlotType): Promise\<void\> | Removes a notification slot for this application. | 30 31In addition to using **addslot()**, you can also create a notification slot by passing **notificationSlotType** in the [NotificationRequest](../reference/apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest-1). If the specified notification slot does not exist, it is automatically created. 32 33## How to Develop 34 351. Import the **notificationManager** module. 36 37 ```ts 38 import { notificationManager } from '@kit.NotificationKit'; 39 import { BusinessError } from '@kit.BasicServicesKit'; 40 import { hilog } from '@kit.PerformanceAnalysisKit'; 41 42 const TAG: string = '[PublishOperation]'; 43 const DOMAIN_NUMBER: number = 0xFF00; 44 ``` 45 462. Add a notification slot. 47 48 ```ts 49 // addSlot callback 50 let addSlotCallBack = (err: BusinessError): void => { 51 if (err) { 52 hilog.error(DOMAIN_NUMBER, TAG, `addSlot failed, code is ${err.code}, message is ${err.message}`); 53 } else { 54 hilog.info(DOMAIN_NUMBER, TAG, `addSlot success`); 55 } 56 } 57 notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack); 58 ``` 59 603. Obtain a notification slot. 61 62 Obtain whether the corresponding slot is created and the notification modes supported by the slot, for example, whether there is an alert tone, whether there is vibration, and whether the lock screen is visible. 63 ```ts 64 // getSlot callback 65 let getSlotCallback = (err: BusinessError, data: notificationManager.NotificationSlot): void => { 66 if (err) { 67 hilog.error(DOMAIN_NUMBER, TAG, `Failed to get slot. Code is ${err.code}, message is ${err.message}`); 68 } else { 69 hilog.info(DOMAIN_NUMBER, TAG, `Succeeded in getting slot.`); 70 if (data != null) { 71 hilog.info(DOMAIN_NUMBER, TAG, `slot enable status is ${JSON.stringify(data.enabled)}`); 72 hilog.info(DOMAIN_NUMBER, TAG, `slot level is ${JSON.stringify(data.level)}`); 73 hilog.info(DOMAIN_NUMBER, TAG, `vibrationEnabled status is ${JSON.stringify(data.vibrationEnabled)}`); 74 hilog.info(DOMAIN_NUMBER, TAG, `lightEnabled status is ${JSON.stringify(data.lightEnabled)}`); 75 } 76 } 77 } 78 let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION; 79 notificationManager.getSlot(slotType, getSlotCallback); 80 ``` 81 824. Remove a notification slot. 83 84 ```ts 85 // removeSlot callback 86 let removeSlotCallback = (err: BusinessError): void => { 87 if (err) { 88 hilog.error(DOMAIN_NUMBER, TAG, `removeSlot failed, code is ${JSON.stringify(err.code)}, message is ${JSON.stringify(err.message)}`); 89 } else { 90 hilog.info(DOMAIN_NUMBER, TAG, "removeSlot success"); 91 } 92 } 93 let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION; 94 notificationManager.removeSlot(slotType, removeSlotCallback); 95 ``` 96