• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @typedef ActionResult
18 * @syscap SystemCapability.Notification.Notification
19 * @since 3
20 */
21export interface ActionResult {
22  /**
23   * Bundle name of the application to be redirected to after the notification is clicked.
24   *
25   * @type { string }
26   * @syscap SystemCapability.Notification.Notification
27   * @since 3
28   */
29  bundleName: string;
30
31  /**
32   * Ability name of the application to be redirected to after the notification is clicked.
33   *
34   * @type { string }
35   * @syscap SystemCapability.Notification.Notification
36   * @since 3
37   */
38  abilityName: string;
39
40  /**
41   * URI of the page to be redirected to. The supported URI formats are as follows:
42   * 1. Absolute path of the page, which is provided by the pages list in the config.json file. Example:
43   * pages/index/index
44   * pages/detail/detail
45   * 2. Particular path. If the value is a slash (/), the home page is displayed.
46   *
47   * @type { string }
48   * @syscap SystemCapability.Notification.Notification
49   * @since 3
50   */
51  uri: string;
52}
53
54/**
55 * @typedef ShowNotificationOptions
56 * @syscap SystemCapability.Notification.Notification
57 * @since 3
58 */
59export interface ShowNotificationOptions {
60  /**
61   * Notification title.
62   *
63   * @type { ?string }
64   * @syscap SystemCapability.Notification.Notification
65   * @since 3
66   */
67  contentTitle?: string;
68
69  /**
70   * Notification content.
71   *
72   * @type { ?string }
73   * @syscap SystemCapability.Notification.Notification
74   * @since 3
75   */
76  contentText?: string;
77
78  /**
79   * Action triggered after the notification is clicked.
80   *
81   * @type { ?ActionResult }
82   * @syscap SystemCapability.Notification.Notification
83   * @since 3
84   */
85  clickAction?: ActionResult;
86}
87
88/**
89 * @syscap SystemCapability.Notification.Notification
90 * @since 3
91 */
92export default class Notification {
93  /**
94   * Displays the notification.
95   *
96   * @param { ShowNotificationOptions } [options] - Options.
97   * @syscap SystemCapability.Notification.Notification
98   * @since 3
99   */
100  static show(options?: ShowNotificationOptions): void;
101}
102