代码拉取完成,页面将自动刷新
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"),
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file Provides methods that will be called back when the subscriber receives a new notification or a notification is canceled
* @kit NotificationKit
*/
import { NotificationRequest } from './notificationRequest';
import { NotificationSortingMap } from './notificationSortingMap';
/*** if arkts 1.1 */
import notification from '../@ohos.notification';
import type notificationManager from '../@ohos.notificationManager';
/*** endif */
/**
* Provides methods that will be called back when the subscriber receives a new notification or
* a notification is canceled.
*
* @interface NotificationSubscriber
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
export interface NotificationSubscriber {
/**
* The callback function that receives a new notification.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 7
*/
onConsume?: (data: SubscribeCallbackData) => void;
/**
* The callback function that cancels the notification.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 7
*/
onCancel?: (data: SubscribeCallbackData) => void;
/**
* The callback function that updates the sort of notifications.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 7
*/
onUpdate?: (data: NotificationSortingMap) => void;
/**
* The callback function of the completed subscription.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 7
*/
onConnect?: () => void;
/**
* The callback function to unsubscribe.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 7
*/
onDisconnect?: () => void;
/**
* The callback function that service disconnected.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 7
*/
onDestroy?: () => void;
/**
* Callback when the Do Not Disturb setting changed.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 8
* @deprecated since 11
* @useinstead NotificationSubscriber#onDoNotDisturbChanged
*/
onDoNotDisturbDateChange?: (mode: notification.DoNotDisturbDate) => void;
/**
* Callback when the Do Not Disturb setting changed.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 11
*/
onDoNotDisturbChanged?: (mode: notificationManager.DoNotDisturbDate) => void;
/**
* Callback when the notification permission is changed.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 8
*/
onEnabledNotificationChanged?: (callbackData: EnabledNotificationCallbackData) => void;
/**
* Callback when badge number changed.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 10
*/
onBadgeChanged?: (data: BadgeNumberCallbackData) => void;
/**
* Callback when badge enabled state changed.
*
* @type { ?BadgeEnabledChangedCallback }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 12
*/
onBadgeEnabledChanged?: BadgeEnabledChangedCallback;
/**
* Callback when badge cancel notifications.
*
* @type { ?function }
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 11
*/
onBatchCancel?: (data: Array<SubscribeCallbackData>) => void;
}
/**
* Provides methods that will be called back when the subscriber receives a new notification or
* a notification is canceled.
*
* @typedef SubscribeCallbackData
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
export interface SubscribeCallbackData {
/**
* Content of the notice.
*
* @type { NotificationRequest }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly request: NotificationRequest;
/**
* Notify sorting information.
*
* @type { ?NotificationSortingMap }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly sortingMap?: NotificationSortingMap;
/**
* The reason for the deletion.(1:CLICK_REASON_REMOVE,2:CANCEL_REASON_REMOVE)
*
* @type { ?number }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly reason?: number;
/**
* Notification sound.
*
* @type { ?string }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly sound?: string;
/**
* Notice the vibration.
*
* @type { ?Array<number> }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'7', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly vibrationValues?: Array<number>;
}
/**
* Describes the properties of the application that the permission to send notifications
* or the badge enabled state has changed.
*
* @typedef EnabledNotificationCallbackData
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'8', '1.2':'20'}
* @arkts 1.1&1.2
*/
export interface EnabledNotificationCallbackData {
/**
* The bundle name of the application.
*
* @type { string }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'8', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly bundle: string;
/**
* The uid of the application.
*
* @type { number }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'8', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly uid: number;
/**
* Apply notification enable status.
*
* @type { boolean }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'8', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly enable: boolean;
}
/**
* Describes the badge number of the application has changed.
*
* @typedef BadgeNumberCallbackData
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
export interface BadgeNumberCallbackData {
/**
* bundle name
*
* @type { string }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly bundle: string;
/**
* The uid of the application.
*
* @type { number }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly uid: number;
/**
* badge number
*
* @type { number }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'10', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly badgeNumber: number;
/**
* Application instance key.
*
* @type { ?number }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 12
* @deprecated since 15
* @useinstead BadgeNumberCallbackData#appInstanceKey
*/
readonly instanceKey?: number;
/**
* Application instance key.
*
* @type { ?string }
* @readonly
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since arkts {'1.1':'15', '1.2':'20'}
* @arkts 1.1&1.2
*/
readonly appInstanceKey?: string;
}
/**
* Defines the callback of BadgeEnabledChanged.
* @typedef BadgeEnabledChangedCallback
* @syscap SystemCapability.Notification.Notification
* @since 12
*/
export interface BadgeEnabledChangedCallback {
/**
* Defines the BadgeEnabledChanged callback.
* @param { EnabledNotificationCallbackData } data
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 12
*/
(data: EnabledNotificationCallbackData): void;
}
/**
* Defines the BadgeEnabledChanged callback.
* @param { EnabledNotificationCallbackData } data
* @syscap SystemCapability.Notification.Notification
* @systemapi
* @since 20
* @arkts 1.2
*/
export type BadgeEnabledChangedCallback = (data: EnabledNotificationCallbackData) => void;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。