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 notification from '../@ohos.notification'; 17import image from '../@ohos.multimedia.image'; 18import { WantAgent } from '../@ohos.wantAgent'; 19import { NotificationContent } from './notificationContent'; 20import { NotificationActionButton } from './notificationActionButton'; 21import { NotificationTemplate } from './notificationTemplate'; 22import { NotificationFlags } from './notificationFlags'; 23 24/** 25 * Defines a NotificationRequest instance. 26 * 27 * @name NotificationRequest 28 * @since 7 29 * @syscap SystemCapability.Notification.Notification 30 * @permission N/A 31 */ 32export interface NotificationRequest { 33 /** 34 * Notification content. 35 */ 36 content: NotificationContent; 37 38 /** 39 * Notification ID. 40 */ 41 id?: number; 42 43 /** 44 * Notification slot type. 45 */ 46 slotType?: notification.SlotType; 47 48 /** 49 * Whether the notification is an ongoing notification. 50 */ 51 isOngoing?: boolean; 52 53 /** 54 * Whether the notification can be removed. 55 */ 56 isUnremovable?: boolean; 57 58 /** 59 * Time when the notification is sent. 60 */ 61 deliveryTime?: number; 62 63 /** 64 * Whether the notification is automatically cleared. 65 */ 66 tapDismissed?: boolean; 67 68 /** 69 * Time when the notification is automatically cleared. 70 */ 71 autoDeletedTime?: number; 72 73 /** 74 * WantAgent instance to which the notification will be redirected after being clicked. 75 */ 76 wantAgent?: WantAgent; 77 78 /** 79 * Extended parameter. 80 */ 81 extraInfo?: {[key: string]: any}; 82 83 /** 84 * Background color of the notification. 85 */ 86 color?: number; 87 88 /** 89 * Whether the notification background color can be enabled. 90 */ 91 colorEnabled?: boolean; 92 93 /** 94 * Whether the notification triggers an alert only once. 95 */ 96 isAlertOnce?: boolean; 97 98 /** 99 * Whether to display the stopwatch. 100 */ 101 isStopwatch?: boolean; 102 103 /** 104 * Whether to display the countdown time. 105 */ 106 isCountDown?: boolean; 107 108 /** 109 * Whether the notification is displayed as a floating icon. 110 */ 111 isFloatingIcon?: boolean; 112 113 /** 114 * Notification label. 115 */ 116 label?: string; 117 118 /** 119 * Notification badge type. 120 */ 121 badgeIconStyle?: number; 122 123 /** 124 * Whether to display the time when the notification is delivered. 125 */ 126 showDeliveryTime?: boolean; 127 128 /** 129 * Buttons in the notification. Up to two buttons are allowed. 130 */ 131 actionButtons?: Array<NotificationActionButton>; 132 133 /** 134 * Small notification icon. 135 */ 136 smallIcon?: image.PixelMap; 137 138 /** 139 * Large notification icon. 140 */ 141 largeIcon?: image.PixelMap; 142 143 /** 144 * The group information for this notification. 145 * 146 * @since 8 147 */ 148 groupName?: string; 149 150 /** 151 * Read-only name of the package for which a notification is created. 152 */ 153 readonly creatorBundleName?: string; 154 155 /** 156 * Read-only UID of the notification creator. 157 */ 158 readonly creatorUid?: number; 159 160 /** 161 * Read-only PID of the notification creator. 162 */ 163 readonly creatorPid?: number; 164 165 /** 166 * @since 8 167 * Read-only UserId of the notification creator. 168 */ 169 readonly creatorUserId?: number; 170 171 /** 172 * Obtains the classification of this notification. 173 * 174 * @systemapi Hide this for inner system use. 175 */ 176 classification?: string; 177 178 /** 179 * Obtains the unique hash code of a notification in the current application. 180 */ 181 readonly hashCode?: string; 182 183 /** 184 * Whether the notification can be remove. 185 * 186 * @default true 187 * @since 8 188 * @systemapi Hide this for inner system use. 189 */ 190 readonly isRemoveAllowed?: boolean; 191 192 /** 193 * Notification source. enum SourceType 194 * 195 * @since 8 196 * @systemapi Hide this for inner system use. 197 */ 198 readonly source?: number; 199 200 /** 201 * Obtains the template of this notification. 202 * 203 * @since 8 204 */ 205 template?: NotificationTemplate; 206 207 /** 208 * The options to distributed notification. 209 * 210 * @since 8 211 */ 212 distributedOption?: DistributedOptions; 213 214 /** 215 * The device ID of the notification source. 216 * 217 * @since 8 218 * @systemapi Hide this for inner system use. 219 */ 220 readonly deviceId?: string; 221 222 /** 223 * Obtains the set of identifiers for the notification. 224 * 225 * @since 8 226 */ 227 readonly notificationFlags?: NotificationFlags; 228 229 /** 230 * WantAgent instance to which the notification will be redirected when removing notification. 231 * 232 * @since 9 233 */ 234 removalWantAgent?: WantAgent; 235 236 /** 237 * Number of notifications displayed on the app icon. 238 * 239 * @since 9 240 */ 241 badgeNumber?: number; 242} 243 244/** 245 * Describes distributed options. 246 * 247 * @name DistributedOptions 248 * @since 8 249 * @syscap SystemCapability.Notification.Notification 250 * @permission N/A 251 */ 252export interface DistributedOptions { 253 /** 254 * Obtains whether is the distributed notification. 255 * 256 * @default true 257 */ 258 isDistributed?: boolean; 259 260 /** 261 * Obtains the types of devices to which the notification can be synchronized. 262 */ 263 supportDisplayDevices?: Array<string>; 264 265 /** 266 * Obtains the devices on which notifications can be open. 267 */ 268 supportOperateDevices?: Array<string>; 269 270 /** 271 * Obtains the remind mode of the notification. enum DeviceRemindType. 272 273 * @systemapi Hide this for inner system use. 274 */ 275 readonly remindType?: number; 276} 277