
回复
1.notificationManager.getSlot
支持设备Phone2in1TabletCarWearable
getSlot(slotType: SlotType, callback: AsyncCallback<NotificationSlot>): void
获取一个指定类型的通知渠道。使用callback异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
// getSlot回调
let getSlotCallback = (err: BusinessError, data: notificationManager.NotificationSlot): void => {
if (err) {
console.error(`Failed to get slot. Code is ${err.code}, message is ${err.message}`);
} else {
console.info(`Succeeded in getting slot, data is ` + JSON.stringify(data));
}
}
let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
notificationManager.getSlot(slotType, getSlotCallback);
2.notificationManager.getSlot
支持设备Phone2in1TabletCarWearable
getSlot(slotType: SlotType): Promise<NotificationSlot>
获取一个指定类型的通知渠道。使用Promise异步回调。
系统能力:SystemCapability.Notification.Notification
示例:
import { BusinessError } from '@kit.BasicServicesKit';
let slotType: notificationManager.SlotType = notificationManager.SlotType.SOCIAL_COMMUNICATION;
notificationManager.getSlot(slotType).then((data: notificationManager.NotificationSlot) => {
console.info(`Succeeded in getting slot, data is ` + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.error(`Failed to get slot. Code is ${err.code}, message is ${err.message}`);
});
本文主要参考引用自HarmonyOS官方网站