目录

pushCommon

This module provides common information of Push Kit, including the bound account type, scenario-specific message data PushPayload, extended notification message data, target content for an extended notification, data configured for the event to be triggered upon message tapping, and in-app call message data.

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

System capability: SystemCapability.Push.PushService

Start version: 4.0.0(10)

Module Import

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

AppProfileType

Enumerated values of the bound account type.

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

System capability: SystemCapability.Push.PushService

Start version: 4.0.0(10)

Name

Value

Description

PROFILE_TYPE_OS_DISTRIBUTED_ACCOUNT

1

HUAWEI ID.

PROFILE_TYPE_APPLICATION_ACCOUNT

2

Account in the app's own account system.

PushPayload

An app can use receiveMessage() to obtain the parameter definition of scenario-specific message data.

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

System capability: SystemCapability.Push.PushService

Start version: 4.0.0(10)

Parameter

Type

Read-only

Optional

Description

type

string

No

No

Message type transferred to the Ability.

data

string

No

No

Data transferred to the Ability.

  • When type is set to IM, a value example of data (formatted) is as follows:
    {
        "data": "extraData", // The value of data equals that of extraData contained in payload of the REST API.
        "header": {
            "token": "MA**"
        },
        "messageAction": 0,
        "notification": {
            "bigBody": "bigBodyXX",
            "bigTitle": "bigTitleXX",
            "body": "bodyXX",
            "data": "",
            "image": "https://**/image**.png",
            "notifyId": -1,
            "title": "titleXX"
        }
    }
  • When type is set to VoIP, BACKGROUND, or EMERGENCY, a value example of data (formatted) is as follows:
    {
        "data": "extraData", // The value of data equals that of extraData contained in payload of the REST API.
        "header": {
            "token": "MA**"
        }
    }

RemoteNotificationInfo

Extended notification message data, which is inherited from PushPayload.

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

System capability: SystemCapability.Push.PushService

Start version: 4.1.0(11)

Parameter

Type

Read-only

Optional

Description

id

number

No

No

Notification ID.

type

string

No

No

Message type transferred to RemoteNotificationExtensionAbility. This parameter is inherited from PushPayload.

data

string

No

No

Data transferred to RemoteNotificationExtensionAbility. This parameter is inherited from PushPayload.

RemoteNotificationContent

Target content of an extended notification.

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

System capability: SystemCapability.Push.PushService

Start version: 4.1.0(11)

Parameter

Type

Read-only

Optional

Description

title

string

No

Yes

Title of an extended notification.

NOTE:

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

text

string

No

Yes

Content of an extended notification.

NOTE:

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

overlayIcon

image.PixelMap

No

Yes

Overlay icon of an extended notification.

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

Badge number increment (but not the actual badge number displayed) during the display of an extended notification.

setBadgeNumber

number

No

Yes

Badge number displayed for an extended notification. If both this parameter and badgeNumber are returned, this parameter takes precedence over badgeNumber.

NOTE:

Start version: 5.0.0(12).

wantAgent

PushCommon.RemoteWantAgent

No

Yes

Data configured for the action to be triggered upon message tapping.

RemoteWantAgent

Data configured for the action to be triggered upon message tapping.

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

System capability: SystemCapability.Push.PushService

Start version: 4.1.0(11)

Parameter

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 is inherited from PushPayload.

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

System capability: SystemCapability.Push.PushService

Start version: 4.1.0(11)

Parameter

Type

Read-only

Optional

Description

callId

string

No

No

Unique ID of a call.

type

string

No

No

Message type transferred to VoIPExtensionAbility. This parameter is inherited from PushPayload.

data

string

No

No

Data transferred to VoIPExtensionAbility. This parameter is inherited from PushPayload.