• 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.ANS
26 * @devices phone, tablet, tv, wearable, car
27 * @permission N/A
28 * @systemapi Hide this for inner system use.
29 * @since 7
30 */
31export interface NotificationSubscriber {
32  onConsume?:(data: SubscribeCallbackData) => void;
33  onCancel?:(data: SubscribeCallbackData) => void;
34  onUpdate?:(data: NotificationSortingMap) => void;
35  onConnect?:() => void;
36  onDisconnect?:() => void;
37  onDestroy?:() => void;
38  onDisturbModeChange?:(mode: notification.DoNotDisturbMode) => void;
39}
40
41/**
42 * Provides methods that will be called back when the subscriber receives a new notification or
43 * a notification is canceled.
44 *
45 * @name SubscribeCallbackData
46 * @sysCap SystemCapability.Notification.ANS
47 * @devices phone, tablet, tv, wearable, car
48 * @permission N/A
49 * @systemapi Hide this for inner system use.
50 * @since 7
51 */
52export interface SubscribeCallbackData {
53  readonly request: NotificationRequest;
54  readonly sortingMap?: NotificationSortingMap;
55  readonly reason?: number;
56  readonly sound?: string;
57  readonly vibrationValues?: Array<number>;
58}