HarmonyOS Live View push guide

更新时间:
复制 MD 格式

Preparations

Before you can use the HarmonyOS Live View feature, you must complete the following preparations:

  1. Integrate the software development kit (SDK) and register the HarmonyOS PushToken. For more information, see Integrate the HarmonyOS SDK.

  2. Design your Live View notification template based on the provided style templates. For more information, see Live View design specifications.

  3. Request the Live View permission in AppGallery Connect. For more information, see Development preparations.

Getting started

After you complete the preparations, you can use the following example to quickly create a Live View for a ride-hailing service:

PushRequest pushRequest = new PushRequest();
// Basic parameters
pushRequest.setAppKey(appKey);
pushRequest.setPushType("NOTICE");
pushRequest.setDeviceType("HARMONY");
pushRequest.setTarget(target);
pushRequest.setTargetValue(targetValue);
pushRequest.setHarmonyTestMessage(true);

// Set parameters to remotely create a Live View
String startLiveViewPayload = """
{
  "activityId": 1,
  "operation": 0,
  "event": "TAXI",
  "status": "DRIVER_ON_THE_WAY",
  "activityData": {
    "notificationData": {
      "type": 3,       
      "contentTitle": "{{status}}",
      "contentText": [
        {
          "text": "Distance to you"
        },
        {
          "text": "1.2 km",
          "foregroundColor": "#FF317AF7"
        },
        {
          "text": " | "
        },
        {
          "text": "5 minutes",
          "foregroundColor": "#FF317AF7"
        }
      ],
      "clickAction": {
        "actionType": 1,
        "action": "xxxxxx"
      },
      "richProgress": {
        "type": 0,
        "nodeIcons": ["icon1.png", "icon2.png", "icon3.png"],
        "indicatorIcon": "taxi.png",
        "progress": 40,
        "indicatorType": 1,
        "color": "#FF317AF7",
        "bgColor": "#19000000"
      },
      "extend": {
        "type": 3,
        "pic": "phone.png",
        "clickAction": {
          "actionType": 0
        }
      }
    },
    "capsuleData": {
      "type": 1,
      "status": 1,
      "icon": "icon.svg",
      "bgColor": "#FF317AF7",
      "remind": "EXPAND",
      "title": "Driver en route",
      "content": "ETA 5 minutes"
    }
  }
}
""";
pushRequest.setHarmonyLiveViewPayload(startLiveViewPayload);

// Send the push message
PushResponse pushResponse = client.getAcsResponse(pushRequest);
System.out.printf("RequestId: %s, MessageId: %s\n", 
    pushResponse.getRequestId(), pushResponse.getMessageId());

The client displays the following:

screenshot_20250924_111450screenshot_20250924_111500

Core concepts

HarmonyOS Live View is a new notification type in the HarmonyOS NEXT system. It helps users focus on ongoing tasks by providing quick-view and immediate-action capabilities. Mobile Push now supports creating, updating, and ending Live Views, which gives developers a simple way to manage them.

What is a Live View?

A Live View is a notification type that is time-bound, time-sensitive, and dynamic. It can be displayed on the lock screen, in the notification center, and on the status bar. It has two main display formats: capsule and card.

imageimageimageimage

Core features

  • Time-bound: The event or service has a defined duration with a clear start and end time.

  • Time-sensitive: The content relates to an ongoing or real-time event that is valuable to the user for a limited period.

  • Dynamic: The displayed content updates dynamically to reflect the latest status.

Reminder methods

Live View can display cards on the lock screen and in the notification center. It also supports the following features:

  1. Displaying a capsule on the status bar. When a user taps the capsule, it expands into a floating card.

  2. Displaying a capsule and a card on the lock screen. A user can long-press or tap the card's header image to enter an immersive lock screen mode.

These multiple display methods deliver information to users instantly. This prevents users from having to repeatedly open and close application or service pages. By default, the notification center displays all Live Views at the top. In other locations, Live Views are displayed based on user settings and business importance. For more information about the styles of different display methods, see Live View.

  1. A single event appears in only one form at a time. For example, if the event's landing page is in the foreground, no capsule is displayed. If the user is viewing the notification center or lock screen, the status bar capsule is not shown.

  2. Live View cards appear at the top of the notification center by default. You should avoid overusing this feature to prevent disturbing users.

image

Basic interactions

image

When a user taps a capsule, a floating card is displayed and the capsule disappears. Tapping the blank area of the card navigates the user to the corresponding details page.

image

Entering immersive mode: This is the default mode after the screen is locked. You can also enter this mode by tapping the header image of a lock screen card or by tapping a lock screen capsule.

Exiting immersive mode: Use the side back gesture to return to the previous state. You can swipe down to collapse the view into a capsule or swipe up to enter the lock screen card state.

Supported scenario types for Live View

Scenario type

EVENT value

Scenario description

Scope

Ride-hailing

TAXI

After a user books a ride online, show information such as the driver's pickup wait time, and the remaining distance and time during the trip.

Applies to scenarios such as online ride-hailing, taxis, carpooling, and hitchhiking.

Instant delivery

DELIVERY

A business scenario where a courier delivers meals or goods to a user-specified location. The delivery is usually completed in a short time.

Applies to scenarios such as food delivery, fresh produce delivery, and intra-city delivery.

Flights

FLIGHT

When a user follows a flight, show key flight updates, such as boarding started, flight departed, flight delayed, flight canceled, or flight arrived.

Applies to scenarios where a user is traveling by air or actively following a flight's progress.

High-speed rail/Train

TRAIN

When a user travels by high-speed rail or train, show information such as the gate, seat number, train number, and train status.

Applies to high-speed rail and train travel scenarios.

Queuing

QUEUE

A business scenario where services are provided to users in order by calling queue numbers.

Applies to queuing scenarios in service halls, hospitals, banks, and restaurants.

Pickup

PICK_UP

A scenario where a user picks up a meal or item after placing an order.

Applies to offline pickup reminders for restaurants, including queue status, preparation progress, and pickup notifications.

Match scores

SCORE

Show changes in the scores of both teams in a match.

Applies to scenarios that show score changes, such as gaming tournaments and sports events.

Shared rentals

RENT

A scenario where a user uses a temporary rental service. It shows real-time rental information such as duration and cost.

Applies to scenarios such as shared bikes, shared power banks, and temporary parking.

Timer

TIMER

A scenario where a user has a continuous count-up timer for a short period or a countdown timer before a task.

Applies to focus timers, Pomodoro timers, and ticket-grabbing countdown reminders. Only utility applications can request this feature.

Workout

WORKOUT

During a workout, show real-time information such as duration and progress.

Applies to recording outdoor or indoor activities, such as running and cycling.

Navigation

NAVIGATION

When a user uses a navigation service, show upcoming route changes.

Applies to walking, cycling, and driving navigation.

The three operation types for Live Views (create, update, and end) have the following restrictions for each scenario:

Live View message operation type

Description

Create Live View

Only the Flight (FLIGHT), Ride-hailing (TAXI), and High-speed rail/Train (TRAIN) scenarios support remote creation of Live Views using the Mobile Push API. For other scenarios, create Live Views locally using the HarmonyOS Live View Kit.

Update Live View

All scenarios support remote updates of Live Views using the Mobile Push API.

End Live View

All scenarios support remotely ending Live Views using the Mobile Push API.

Live View style templates

A Live View card consists of three sections: a fixed area, an auxiliary area, and an extension area. The fixed area is required, while the auxiliary and extension areas are optional.

image

Progress visualization template

The progress visualization template is suitable for scenarios such as ride-hailing and food delivery.

Emphasized text template

The emphasized text template is suitable for scenarios such as pickup and queuing.

Side-by-side text template

The side-by-side text template is suitable for scenarios such as high-speed rail and flights.

Match score template

The match score template is suitable for sports match scenarios.

Navigation template

The navigation template is suitable for travel navigation scenarios.

image

Note

The navigation template can only be managed through local operations using the HarmonyOS Live View Kit. It cannot be managed remotely using the Mobile Push API.

Create, update, or end a Live View locally using the HarmonyOS Live View Kit

When the application process is active, you can manage a Live View locally on the client using the liveViewManager of the HarmonyOS Live View Kit. The startLiveView, updateLiveView, and stopLiveView methods are used to create, update, and end a Live View, respectively. For the code for each template, see Build a local Live View. For more information about the data structure of a Live View, see liveViewManager.LiveView.

Remotely create, update, or end a Live View using the Mobile Push API

Mobile Push supports remotely creating, updating, and ending Live Views using the Push or MassPush API. Remote creation is only supported for the Flight (FLIGHT), Ride-hailing (TAXI), and High-speed rail/Train (TRAIN) scenarios. There are no scenario restrictions for updating or ending Live Views.

Parameter settings

When you call the API, take note of the following key parameters:

  • PushType: Set this parameter to NOTICE to indicate that a live window is pushed.

  • HarmonyTestMessage: Set to true for test messages and false for official messages.

  • HarmonyLiveViewPayload: The JSON string of the LiveViewPayload data structure. Set the operation parameter to 0 to create, 1 to update, or 2 to end a Live View.

The structure of LiveViewPayload is shown in the following table:

Parameter

Required

Parameter type

Description

activityId

Yes

Integer

The unique identifier for the Live View. The value ranges from -2147483648 to 2147483647. It is generated by the developer. This corresponds to the id field in the Live View Kit.

Important

If the Live View corresponding to the sent activityId does not exist (in update or end scenarios), sending Live View messages with this activityId will be restricted for 24 hours.

operation

Yes

Integer

The operation type for the Live View message:

  • 0: Create a Live View message. Only allowed for event values FLIGHT, TAXI, and TRAIN. For more information, see Constraints on creating Live Views.

  • 1: Update a Live View message. Make sure the Live View corresponding to activityId exists.

  • 2: End a Live View message. Make sure the Live View corresponding to activityId exists.

When updating or ending a Live View, if an optional field has no special instructions or default value, it inherits the previous state if not included.

event

Yes

String

The business scenario value. It must be one of the following:

  • TAXI: Ride-hailing

  • DELIVERY: Instant delivery (food, fresh produce)

  • FLIGHT: Flights

  • TRAIN: High-speed rail/Train

  • QUEUE: Queuing

  • PICK_UP: Pickup

  • SCORE: Match scores

  • RENT: Shared rentals

  • TIMER: Timer

  • WORKOUT: Workout

  • NAVIGATION: Navigation

You need to request permissions for the corresponding scenario. For more information, see Live View permission request requirements.

Important

When creating a Live View message (operation is 0), the event value can only be FLIGHT, TAXI, or TRAIN.

status

No

String

The status of the Live View message.

This is required when operation is 0, or when operation is 1 and the Live View being updated was created remotely through Mobile Push.

The value range of status depends on the scenario type. For more information, see Status value range.

For information about using the {{status}} placeholder in the message body, see Fields that support placeholders. When the requirements are met, the placeholder in the field is replaced with the target value.

title

No

String

Optional. The title displayed in the notification bar when the system does not support Live View notifications.

content

No

String

Optional. The content displayed in the notification bar when the system does not support Live View notifications.

mute

No

Boolean

Indicates whether an update to the message requires a reminder.

  • true: Silent reminder (default)

  • false: Ringtone and vibration reminder

version

No

Integer

The version number for the Live View notification update. It must be greater than or equal to 0. The new version number must be greater than the current version number, otherwise the refresh will fail.

activityData

Yes

ActivityData Object

The detailed data for the Live View notification. For specific fields, see the ActivityData struct.

Example code

Remotely create a Live View

PushRequest pushRequest = new PushRequest();
// Basic parameters
pushRequest.setAppKey(appKey);
pushRequest.setPushType("NOTICE");
pushRequest.setDeviceType("HARMONY");
pushRequest.setTarget(target);
pushRequest.setTargetValue(targetValue);
pushRequest.setHarmonyTestMessage(true);

// Set parameters to remotely create a Live View
String startLiveViewPayload = """
{
  "activityId": 1,
  "operation": 0,
  "event": "TAXI",
  "status": "DRIVER_ON_THE_WAY",
  "activityData": {
    "notificationData": {
      "type": 3,       
      "contentTitle": "{{status}}",
      "contentText": [
        {
          "text": "Distance to you"
        },
        {
          "text": "1.2 km",
          "foregroundColor": "#FF317AF7"
        },
        {
          "text": " | "
        },
        {
          "text": "5 minutes",
          "foregroundColor": "#FF317AF7"
        }
      ],
      "clickAction": {
        "actionType": 1,
        "action": "xxxxxx"
      },
      "richProgress": {
        "type": 0,
        "nodeIcons": ["icon1.png", "icon2.png", "icon3.png"],
        "indicatorIcon": "taxi.png",
        "progress": 40,
        "indicatorType": 1,
        "color": "#FF317AF7",
        "bgColor": "#19000000"
      },
      "extend": {
        "type": 3,
        "pic": "phone.png",
        "clickAction": {
          "actionType": 0
        }
      }
    },
    "capsuleData": {
      "type": 1,
      "status": 1,
      "icon": "icon.svg",
      "bgColor": "#FF317AF7",
      "remind": "EXPAND",
      "title": "Driver en route",
      "content": "ETA 5 minutes"
    }
  }
}
""";
pushRequest.setHarmonyLiveViewPayload(startLiveViewPayload);

// Send the push message
PushResponse pushResponse = client.getAcsResponse(pushRequest);
System.out.printf("RequestId: %s, MessageId: %s\n", 
    pushResponse.getRequestId(), pushResponse.getMessageId());

Remotely update a Live View

PushRequest pushRequest = new PushRequest();
// Basic parameters
pushRequest.setAppKey(appKey);
pushRequest.setPushType("NOTICE");
pushRequest.setDeviceType("HARMONY");
pushRequest.setTarget(target);
pushRequest.setTargetValue(targetValue);
pushRequest.setHarmonyTestMessage(true);

// Set parameters to remotely update a Live View
String updateLiveViewPayload = """
{
  "activityId": 1,
  "operation": 1,
  "event": "TAXI",
  "status": "DRIVER_ARRIVE",
  "activityData": {
    "notificationData": {
      "type": 3,       
      "contentTitle": "{{status}}",
      "contentText": [
        {
          "text": "Distance to you"
        },
        {
          "text": "0.5 km",
          "foregroundColor": "#FF317AF7"
        },
        {
          "text": " | "
        },
        {
          "text": "2 minutes",
          "foregroundColor": "#FF317AF7"
        }
      ],
      "clickAction": {
        "actionType": 1,
        "action": "xxxxxx"
      },
      "richProgress": {
        "type": 0,
        "nodeIcons": ["icon1.png", "icon2.png", "icon3.png"],
        "indicatorIcon": "taxi.png",
        "progress": 40,
        "indicatorType": 1,
        "color": "#FF317AF7",
        "bgColor": "#19000000"
      },
      "extend": {
        "type": 3,
        "pic": "phone.png",
        "clickAction": {
          "actionType": 0
        }
      }
    },
    "capsuleData": {
      "type": 1,
      "status": 1,
      "icon": "icon.svg",
      "bgColor": "#FF317AF7",
      "remind": "EXPAND",
      "title": "Driver has arrived at the pickup point",
      "content": "ETA 2 minutes"
    }
  }
}
""";
pushRequest.setHarmonyLiveViewPayload(updateLiveViewPayload);

// Send the push message
PushResponse pushResponse = client.getAcsResponse(pushRequest);
System.out.printf("RequestId: %s, MessageId: %s\n", 
    pushResponse.getRequestId(), pushResponse.getMessageId());

Remotely end a Live View

PushRequest pushRequest = new PushRequest();
// Basic parameters
pushRequest.setAppKey(appKey);
pushRequest.setPushType("NOTICE");
pushRequest.setDeviceType("HARMONY");
pushRequest.setTarget(target);
pushRequest.setTargetValue(targetValue);
pushRequest.setHarmonyTestMessage(true);

// Set parameters to remotely end a Live View
String stopLiveViewPayload = """
{
  "activityId": 1,
  "operation": 2,
  "event": "TAXI",
  "status": "DRIVER_ARRIVE",
  "activityData": {
    "notificationData": {
      "type": 3,       
      "contentTitle": "{{status}}",
      "contentText": [
        {
          "text": "Distance to you"
        },
        {
          "text": "0.5 km",
          "foregroundColor": "#FF317AF7"
        },
        {
          "text": " | "
        },
        {
          "text": "2 minutes",
          "foregroundColor": "#FF317AF7"
        }
      ],
      "clickAction": {
        "actionType": 1,
        "action": "xxxxxx"
      },
      "richProgress": {
        "type": 0,
        "nodeIcons": ["icon1.png", "icon2.png", "icon3.png"],
        "indicatorIcon": "taxi.png",
        "progress": 40,
        "indicatorType": 1,
        "color": "#FF317AF7",
        "bgColor": "#19000000"
      },
      "extend": {
        "type": 3,
        "pic": "phone.png",
        "clickAction": {
          "actionType": 0
        }
      }
    },
    "capsuleData": {
      "type": 1,
      "status": 1,
      "icon": "icon.svg",
      "bgColor": "#FF317AF7",
      "remind": "EXPAND",
      "title": "Driver has arrived at the pickup point",
      "content": "ETA 2 minutes"
    }
  }
}
""";
pushRequest.setHarmonyLiveViewPayload(stopLiveViewPayload);

// Send the push message
PushResponse pushResponse = client.getAcsResponse(pushRequest);
System.out.printf("RequestId: %s, MessageId: %s\n", 
    pushResponse.getRequestId(), pushResponse.getMessageId());

Live View limitations

Lifecycle limitations

  • A single Live View has a maximum lifecycle of 8 hours. After 8 hours, the system automatically ends the Live View.

  • If a Live View is not updated for more than 2 hours, its status bar capsule and lock screen display are hidden. However, it is still displayed in the notification center.

  • If a Live View is not updated for more than 4 hours, the system automatically ends it and purges it from all display locations.

  • A user can delete a Live View notification at any time. After a Live View is deleted, subsequent updates to it will not be displayed.

Frequency limitations

Testing phase:

  • Each project can push a maximum of 1,000 test messages per day. To push test messages, set HarmonyTestMessage to true.

Official phase:

  • The total number of messages that can be pushed to a single device from a single application per day is limited by device message frequency control. The total number of all scenario-based messages sent cannot exceed 3,000.

  • For a single Live View, the update frequency varies by scenario. For the Ride-hailing and Match score scenarios, a Live View can be updated a maximum of 30 times every 5 minutes and 180 times per hour per device. For other scenarios, a Live View can be updated a maximum of 10 times every 5 minutes and 60 times per hour per device. Updates that exceed the frequency limit are discarded and not delivered.

Limitations on remote creation of Live Views

  • Remote creation of Live Views using Mobile Push is supported only for the FLIGHT, TAXI, and TRAIN scenarios.

  • You cannot remotely create a Live View with the same activityId on the same device using Mobile Push within a 12-hour period.

  • When you create a Live View, different event types have the following scenario constraints on the layout type (activityData.notificationData.type) and required fields:

event

Allowed layout types for creation

Required fields for creation

Required fields for updating messages created by the REST API

FLIGHT

Side-by-side text template type

status activityData.notificationData.keywords

status

TAXI

Progress visualization type

Emphasized text template type

Side-by-side text template type

Event Type

status

status

TRAIN

Side-by-side text template type

status activityData.notificationData.keywords

status

  • For different layout types (activityData.notificationData.type), you must include the {{status}} placeholder for status at least once in the fields that support placeholders. If the keywords field is also required for the event, you must also include the corresponding placeholder at least once in the fields that support placeholders. For more information about placeholders, see the description of the keywords field.

  • For Live Views created remotely using Mobile Push, updates must meet both the status and keywords requirements. For Live Views created with the Live View Kit (Live View service), you can leave the status and keywords fields empty when you update them remotely with Mobile Push. If you choose to populate these fields, they must meet the status and keywords requirements.

Troubleshooting

Failed to create a Live View

  1. Check whether you have requested the Live View permission for the corresponding scenario in AppGallery Connect.

  2. To check if a device supports Live View, refer to Build a local Live View or call the liveViewManager.isLiveViewEnabled() method.

  3. Check whether the frequency limitations have been triggered.

  4. For Live Views created remotely using Mobile Push, check whether the limitations on remote creation of Live Views have been triggered.

  5. Use the message ID and device ID to check the Live View push link on the **Troubleshoot Message** page of the Mobile Push console.

Failed to update or end a Live View

  1. Check whether the activityId in the HarmonyLiveViewPayload parameter is the same as the one used when the Live View was created.

  2. Check whether the version in the HarmonyLiveViewPayload parameter is set correctly.

  3. Check whether the frequency limitations have been triggered.

  4. Use the message ID and device ID to check the Live View push link on the **Troubleshoot Message** page of the Mobile Push console.

Abnormal Live View style

  1. Check whether the type in the HarmonyLiveViewPayload parameter matches the corresponding template.

  2. Check whether the resource file path is correct.