目录

pushCommon

This module defines common APIs and enumerations related to Push Kit, providing support for core capabilities such as account binding, message receiving, and notification content replacement.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.0.0(10)

Modules to Import

import { pushCommon } from '@kit.PushKit';

AppProfileType

Enumerated bound account types.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.0.0(10)

Name Value Description
PROFILE_TYPE_OS_DISTRIBUTED_ACCOUNT 1 HUAWEI ID.
PROFILE_TYPE_APPLICATION_ACCOUNT 2 Application account.

PushPayload

Transmits data from Push Kit to your app. This is the core API for Push Kit to transfer data. You can call receiveMessage() to receive data of messages such as notification messages and text-to-speech messages.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.0.0(10)

Name Type Read-Only Optional Description
type string No No

Type of the message sent to the ability. The options are as follows:

IM: text-to-speech message

VoIP: in-app call message

BACKGROUND: background message

EMERGENCY: emergency event message (This type of message is available only to system apps now, and your app does not involve processing of these messages.)

ALERT: notification message

data string No No Data transferred to the Ability. See Value Example of data (formatted) for reference.

[h2]Value Example of data

RemoteNotificationInfo

Transfers text-to-speech message data received via onReceiveMessage() when your app is not running in the foreground. This API inherits from PushPayload.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.1.0(11)

Name Type Read-Only Optional Description
id number No No Notification ID.
type string No No Type of the message transferred to RemoteNotificationExtensionAbility. This parameter inherits from PushPayload.
data string No No Data transferred to RemoteNotificationExtensionAbility. This parameter inherits from PushPayload.

RemoteNotificationContent

Returns the updated notification attributes such as the notification title and content after you receive and process RemoteNotificationInfo.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.1.0(11)

Name Type Read-Only Optional Description
title string No Yes

Title of an extended notification, which will be used as title in the NotificationRequest object when a notification is published.

Note:

The title parameter is optional since version 5.0.0(12).

text string No Yes

Content of an extended notification, which will be used as text in the NotificationRequest object when a notification is published.

Note:

The text parameter is optional since version 5.0.0(12).

overlayIcon image.PixelMap No Yes

Overlay icon of an extended notification, which will be used as overlayIcon in the NotificationRequest object when a notification is published.

Note:

It is recommended that the image width x height be less than 128 x 128 pixels. Images larger than 49,152 pixels will not be displayed.

badgeNumber number No Yes Increment of the badge number. The value must be an integer. If the value is less than or equal to 0, the badge setting is ignored. The badge number is displayed on the app's home screen icon. This parameter will be used as badgeNumber in the NotificationRequest object when a notification is published.
setBadgeNumber number No Yes

Badge number to be set. The value is an integer. If the value is less than or equal to 0, the badge is cleared. If this parameter and badgeNumber are both returned, this parameter takes precedence over badgeNumber and will be used as setBadgeNumber in the NotificationRequest object when a notification is published.

Note:

Since: 5.0.0(12)

wantAgent RemoteWantAgent No Yes Replaceable data on a tap event, which will be used as wantAgent in the NotificationRequest object when a notification is published.

RemoteWantAgent

Replaceable data on a tap event. When RemoteNotificationContent is returned, you can call this API to implement custom notification tap actions, such as starting an ability.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.1.0(11)

Name Type Read-Only Optional Description
abilityName string No No Custom page name.
parameters Record<string, Object> No Yes Data transferred to an app.

VoIPInfo

In-app call message data, which inherits from PushPayload.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Push.PushService

Since: 4.1.0(11)

Name Type Read-Only Optional Description
callId string No No Unique ID of a call.
type string No No Type of the message transferred to VoIPExtensionAbility. This parameter inherits from PushPayload.
data string No No Data transferred to VoIPExtensionAbility. This parameter inherits from PushPayload.