• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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
16import { NotificationRequest } from './notificationRequest';
17import { NotificationSortingMap } from './notificationSortingMap';
18import notification from '../@ohos.notification';
19
20/**
21 * Provides methods that will be called back when the subscriber receives a new notification or
22 * a notification is canceled.
23 *
24 * @name NotificationSubscriber
25 * @syscap SystemCapability.Notification.Notification
26 * @permission N/A
27 * @systemapi Hide this for inner system use.
28 * @since 7
29 */
30export interface NotificationSubscriber {
31  onConsume?:(data: SubscribeCallbackData) => void;
32  onCancel?:(data: SubscribeCallbackData) => void;
33  onUpdate?:(data: NotificationSortingMap) => void;
34  onConnect?:() => void;
35  onDisconnect?:() => void;
36  onDestroy?:() => void;
37
38  /**
39   * Callback when the Do Not Disturb setting changed.
40   * @syscap SystemCapability.Notification.Notification
41   * @since 8
42   */
43  onDoNotDisturbDateChange?:(mode: notification.DoNotDisturbDate) => void;
44
45  /**
46   * Callback when the notification permission is changed.
47   * @syscap SystemCapability.Notification.Notification
48   * @since 8
49   */
50  onEnabledNotificationChanged?:(callbackData: EnabledNotificationCallbackData) => void;
51}
52
53/**
54 * Provides methods that will be called back when the subscriber receives a new notification or
55 * a notification is canceled.
56 *
57 * @name SubscribeCallbackData
58 * @syscap SystemCapability.Notification.Notification
59 * @permission N/A
60 * @systemapi Hide this for inner system use.
61 * @since 7
62 */
63export interface SubscribeCallbackData {
64  readonly request: NotificationRequest;
65  readonly sortingMap?: NotificationSortingMap;
66  readonly reason?: number;
67  readonly sound?: string;
68  readonly vibrationValues?: Array<number>;
69}
70
71/**
72 * Describes the properties of the application that the permission to send notifications has changed.
73 *
74 * @name EnabledNotificationCallbackData
75 * @syscap SystemCapability.Notification.Notification
76 * @systemapi Hide this for inner system use.
77 * @since 8
78 */
79export interface EnabledNotificationCallbackData {
80  readonly bundle: string;
81  readonly uid: number;
82  readonly enable: boolean;
83}
84