[文章]HarmonyOS NEXT应用开发-Notification Kit(用户通知服务)notificationManager.addSlot

阅读量0
0
0

1.notificationManager.addSlot
支持设备Phone2in1TabletCarWearable
addSlot(type: SlotType, callback: AsyncCallback): void
创建指定类型的通知渠道。使用callback异步回调。
系统能力:SystemCapability.Notification.Notification
HarmonyOS NEXT应用开发-Notification Kit(用户通知服务)notificationManager.addSlot-鸿蒙开发者社区
HarmonyOS NEXT应用开发-Notification Kit(用户通知服务)notificationManager.addSlot-鸿蒙开发者社区
示例:

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
HarmonyOS NEXT应用开发-Notification Kit(用户通知服务)notificationManager.addSlot-鸿蒙开发者社区HarmonyOS NEXT应用开发-Notification Kit(用户通知服务)notificationManager.addSlot-鸿蒙开发者社区
示例:

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官方网站

回帖

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。 侵权投诉
链接复制成功,分享给好友