openharmony 鸿蒙 changelogs-notification

2022-12-13 浏览 (961)

事件通知子系统ChangeLog

cl.notification.1 API异常处理方式变更

事件通知部分接口使用业务逻辑返回值表示错误信息,不符合OpenHarmony接口错误码规范。

变更影响

基于此前版本开发的应用,需适配变更接口的错误信息返回方式,否则会影响原有业务逻辑。

关键接口/组件变更

为适配统一的API异常处理方式,对事件通知相关接口进行废弃(下表中 原接口 列内容),并新增对应接口(下表中 新接口 列内容)。新增接口支持统一的错误码异常处理规范,功能上与原接口保持一致。

原接口新接口
@ohos.commonEvent.d.ts@ohos.commonEventManager.d.ts
@ohos.notification.d.ts@ohos.notificationManager.d.ts
@ohos.notification.d.ts@ohos.notificationSubscribe.d.ts

适配指导

如上所述,仅将老接口平移到了新的namespace中,所以可以通过修改import来解决适配问题:

如原先接口使用了@ohos.commonEvent

import commonEvent from '@ohos.commonEvent';

可以通过直接修改import,来切换到新的namespace上:

import commonEvent from '@ohos.commonEventManager';

@ohos.notification拆分成了两个namespace,需要根据接口情况选择需要的新namespace进行适配。

此外还需要适配异常处理,具体参考新接口的接口文档。

cl.notification.2 接口变更

对事件通知部分接口名进行了变更。

关键的接口/组件变更

模块名类名方法/属性/枚举/常量变更类型
@ohos.notificationnotificationfunction enableNotification(bundle: BundleOption, enable: boolean, callback: AsyncCallback<void>): void;废弃
@ohos.notificationnotificationfunction enableNotification(bundle: BundleOption, enable: boolean): Promise<void>;废弃
@ohos.notificationManagernotificationManagerfunction setNotificationEnable(bundle: BundleOption, enable: boolean, callback: AsyncCallback<void>): void;新增
@ohos.notificationManagernotificationManagerfunction setNotificationEnable(bundle: BundleOption, enable: boolean): Promise<void>;新增
@ohos.notificationnotificationfunction enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback<void>): void;废弃
@ohos.notificationnotificationfunction enableNotificationSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise<void>;废弃
@ohos.notificationManagernotificationManagerfunction setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean, callback: AsyncCallback<void>): void;新增
@ohos.notificationManagernotificationManagerfunction setNotificationEnableSlot(bundle: BundleOption, type: SlotType, enable: boolean): Promise<void>;新增
@ohos.notificationnotificationfunction enableDistributed(enable: boolean, callback: AsyncCallback<void>): void;废弃
@ohos.notificationnotificationfunction enableDistributed(enable: boolean, callback: AsyncCallback<void>): void;废弃
@ohos.notificationManagernotificationManagerfunction setDistributedEnable(enable: boolean, callback: AsyncCallback<void>): void;新增
@ohos.notificationManagernotificationManagerfunction setDistributedEnable(enable: boolean): Promise<void>;新增
@ohos.notificationnotificationfunction enableDistributedByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback<void>): void;废弃
@ohos.notificationnotificationfunction enableDistributedByBundle(bundle: BundleOption, enable: boolean): Promise<void>;废弃
@ohos.notificationManagernotificationManagerfunction setDistributedEnableByBundle(bundle: BundleOption, enable: boolean, callback: AsyncCallback<void>): void;新增
@ohos.notificationManagernotificationManagerfunction setDistributedEnableByBundle(bundle: BundleOption, enable: boolean): Promise<void>;新增

你可能感兴趣的鸿蒙文章

harmony 鸿蒙分布式调度子系统ChangeLog

harmony 鸿蒙基础通信WIFI子系统ChangeLog

harmony 鸿蒙元能力子系统ChangeLog

harmony 鸿蒙帐号子系统ChangeLog

harmony 鸿蒙定制子系统ChangeLog

harmony 鸿蒙位置服务子系统ChangeLog

harmony 鸿蒙多媒体子系统ChangeLog

harmony 鸿蒙用户IAM子系统Changelog

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/5ddfcd09e70d4402ad317b0c1fe58ddd