We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
GuidesApplication ServicesNotification KitAbout This Kit

About This Kit

Notification Kit (user notification service) provides a publishing channel for local notifications. With Notification Kit, you can push notifications generated by your application directly to users on the client. Depending on the notification type and publishing scenario, a local notification produces the corresponding ringtone, vibration, banner, lock screen display, automatic screen-on, status bar icon, and display in the notification center.

When to Use

When an application is running, you can use Notification Kit to publish notifications to users.When the application process is terminated, you cannot publish local notifications. Instead, you need to access Push Kit to publish offline notifications on the cloud.

You can use the local notification capability in various scenarios, such as synchronizing upload and download progress, publishing instant customer service and payment notifications, and updating step counts.

Capability Scope

Notification Kit supports the following capabilities:

  • Publishes notifications in the form of text or progress bar.
  • Carries or updates the application notification badge.
  • Cancels one or all published notifications.
  • Queries the list of published notifications.
  • Queries the status of the notification function of an application.
  • Enables notification publishing (disabled by default) by triggering an authorization dialog to request user consent for sending notifications.

Service Flow

The main service flow of using Notification Kit is as follows:

  1. Request notification authorization.

  2. Publish a notification to Notification Kit.

  3. Display the notification in the notification center.

Notification Style

NOTE

The actual display effect depends on the device capabilities and the UI design style of the notification center.

Common notification styles in Notification Kit are as follows.

Expand
Type Notification Style Description
Text A maximum of three lines can be displayed in the notification text. Excess content is truncated by an ellipsis (...).
Multi-line text A maximum of three lines of content can be displayed. Excess content of each line is truncated by an ellipsis (...).
Notification badge Displayed as a number in the upper right corner.
Progress bar Progress notification.

Constraints

  • The number of published notifications from a single application that can be retained in system entries such as the notification center is limited (currently up to 24).
  • The notification cannot exceed 200 KB (due to cross-process serialization).
  • The publication and update frequencies for notifications must meet the following requirements. Otherwise, the publication or update fails and the corresponding error code is returned.
    • The total number of notifications published by an application cannot exceed 10 per second, and that of notifications updated cannot exceed 20 per second.
    • The total number of notifications published by all third-party applications cannot exceed 15 per second, and that of notifications updated cannot exceed 30 per second.

Penalties for Violations

Both cloud notifications and local notifications published by apps must comply with the Push Kit message classification standards. Incorrect message classification or other violations of these standards will be considered violations. For the classification standards for local notifications, see Notification Slots.

For violations and the corresponding measures, see Push Notification Violation Penalty Criteria.

  • Notifications created by Notification Kit are displayed immediately in system entries such as the notification center. If you want scheduled notifications that still remind users after the application moves to the background or its process is terminated, such as flash-sale reminders in shopping applications, you can create them through Background Tasks Kit. Currently, notification reminder features based on countdown, calendar, and alarm types are supported.
  • You can use the getWantAgent API of Ability Kit to set the WantAgent triggered when a user taps a notification.
  • You can use Push Kit to remotely push user notifications to the local device.

Supported Emulators

This kit is supported on the Emulator.

There are some general differences between the Emulator and real devices. For details, please refer to Differences Between the Emulator and the Real Device.