harmony 鸿蒙Common Event and Notification Subsystem ChangeLog

  • 2023-06-24
  • 浏览 (341)

Common Event and Notification Subsystem ChangeLog

cl.notification.1 Deleting Deprecated APIs (Version 9)

In the event notification exception handling rectification, some APIs in API version 9 are marked as deprecated, and these APIs need to be deleted, according to OpenHarmony API specifications.

Change Impacts

The application developed based on earlier versions needs to use new APIs to replace the deleted ones. Otherwise, the application compilation will be affected.

Key API/Component Changes

Deprecated APIs in API version 9 will be deleted, and they will be replaced with new ones with same names.

Original API New 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

APIs or attributes are deleted:

  • @ohos.notification.d.ts
    • The publishAsBundle, cancelAsBundle, isNotificationSlotEnabled, setSyncNotificationEnabledWithoutApp, and getSyncNotificationEnabledWithoutApp APIs are deleted. Replace them with APIs with same names in api/@ohos.notificationManager.d.ts.
    • The enableNotificationSlot API is deleted. Replace it with setNotificationEnableSlot in api/@ohos.notificationManager.d.ts.
    • The export classes NotificationActionButton, NotificationBasicContent, NotificationContent, NotificationLongTextContent, NotificationMultiLineContent, NotificationPictureContent, NotificationFlags, NotificationFlagStatus, NotificationRequest, DistributedOptions, NotificationSlot, NotificationSorting, NotificationTemplate, and NotificationUserInput are deleted. Replace them with the export classes with the same names in api/@ohos.notificationManager.d.ts.
    • The export classes NotificationSubscribeInfo, NotificationSubscriber, SubscribeCallbackData, and EnabledNotificationCallbackData are deleted. Replace them with the export classes with the same names in api/@ohos.notificationSubscribe.d.ts.

Adaptation Guide

The original APIs are only migrated to the new namespace. Therefore, you can modify import to solve the adaptation problem.

If the original API uses @ohos.commonEvent:

import commonEvent from '@ohos.commonEvent';

You can directly modify import to switch to the new namespace:

import commonEvent from '@ohos.commonEventManager';

@ohos.notification is split into two namespaces. You need to select a new namespace for adaptation.

In addition, exception handling is needed. For details, see the API reference for the new APIs.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Readme

harmony 鸿蒙Example Subsystem Changelog

harmony 鸿蒙Ability Framework Changelog

harmony 鸿蒙Account Subsystem Changelog

harmony 鸿蒙ArkUI Subsystem ChangeLog

harmony 鸿蒙Multimedia Subsystem Changelog

harmony 鸿蒙Common Library Subsystem Changelog

harmony 鸿蒙Distributed Data Management Subsystem JS API Changelog

harmony 鸿蒙File Management Subsystem Changelog

harmony 鸿蒙Input Method Framework ChangeLog

0  赞