1.notificationManager.addSlot
支持设备Phone2in1TabletCarWearable
addSlot(type: SlotType, callback: AsyncCallback): void
创建指定类型的通知渠道。使用callback异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
// addslot回调
let addSlotCallBack = (err: BusinessError): void => {
if (err) {
console.error(`Failed to add slot. Code is ${err.code}, message is ${err.message}`);
} else {
console.info(`Succeeded in adding slot.`);
}
}
notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, addSlotCallBack);
2.notificationManager.addSlot
支持设备Phone2in1TabletCarWearable
addSlot(type: SlotType): Promise
创建指定类型的通知渠道。使用Promise异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
console.info(`Succeeded in adding slot.`);
}).catch((err: BusinessError) => {
console.error(`Failed to add slot. Code is ${err.code}, message is ${err.message}`);
});
本文主要参考引用自HarmonyOS官方网站