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 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 * @typedef NotificationRequest 28 * @syscap SystemCapability.Notification.Notification 29 * @since 7 30 */ 31export interface NotificationRequest { 32 /** 33 * Notification content. 34 * 35 * @type { NotificationContent } 36 * @syscap SystemCapability.Notification.Notification 37 * @since 7 38 */ 39 content: NotificationContent; 40 41 /** 42 * Notification ID. 43 * 44 * @type { ?number } 45 * @syscap SystemCapability.Notification.Notification 46 * @since 7 47 */ 48 id?: number; 49 50 /** 51 * Notification slot type. 52 * 53 * @type { ?notification.SlotType } 54 * @syscap SystemCapability.Notification.Notification 55 * @since 7 56 */ 57 slotType?: notification.SlotType; 58 59 /** 60 * Whether the notification is an ongoing notification. 61 * 62 * @type { ?boolean } 63 * @syscap SystemCapability.Notification.Notification 64 * @since 7 65 */ 66 isOngoing?: boolean; 67 68 /** 69 * Whether the notification can be removed. 70 * 71 * @type { ?boolean } 72 * @syscap SystemCapability.Notification.Notification 73 * @since 7 74 */ 75 isUnremovable?: boolean; 76 77 /** 78 * Time when the notification is sent. 79 * 80 * @type { ?number } 81 * @syscap SystemCapability.Notification.Notification 82 * @since 7 83 */ 84 deliveryTime?: number; 85 86 /** 87 * Whether the notification is automatically cleared. 88 * 89 * @type { ?boolean } 90 * @syscap SystemCapability.Notification.Notification 91 * @since 7 92 */ 93 tapDismissed?: boolean; 94 95 /** 96 * Time when the notification is automatically cleared. 97 * 98 * @type { ?number } 99 * @syscap SystemCapability.Notification.Notification 100 * @since 7 101 */ 102 autoDeletedTime?: number; 103 104 /** 105 * WantAgent instance to which the notification will be redirected after being clicked. 106 * 107 * @type { ?WantAgent } 108 * @syscap SystemCapability.Notification.Notification 109 * @since 7 110 */ 111 wantAgent?: WantAgent; 112 113 /** 114 * Extended parameter. 115 * 116 * @type { ?object } 117 * @syscap SystemCapability.Notification.Notification 118 * @since 7 119 */ 120 extraInfo?: { [key: string]: any }; 121 122 /** 123 * Background color of the notification. 124 * 125 * @type { ?number } 126 * @syscap SystemCapability.Notification.Notification 127 * @since 7 128 */ 129 color?: number; 130 131 /** 132 * Whether the notification background color can be enabled. 133 * 134 * @type { ?boolean } 135 * @syscap SystemCapability.Notification.Notification 136 * @since 7 137 */ 138 colorEnabled?: boolean; 139 140 /** 141 * Whether the notification triggers an alert only once. 142 * 143 * @type { ?boolean } 144 * @syscap SystemCapability.Notification.Notification 145 * @since 7 146 */ 147 isAlertOnce?: boolean; 148 149 /** 150 * Whether to display the stopwatch. 151 * 152 * @type { ?boolean } 153 * @syscap SystemCapability.Notification.Notification 154 * @since 7 155 */ 156 isStopwatch?: boolean; 157 158 /** 159 * Whether to display the countdown time. 160 * 161 * @type { ?boolean } 162 * @syscap SystemCapability.Notification.Notification 163 * @since 7 164 */ 165 isCountDown?: boolean; 166 167 /** 168 * Whether the notification is displayed as a floating icon. 169 * 170 * @type { ?boolean } 171 * @syscap SystemCapability.Notification.Notification 172 * @since 7 173 */ 174 isFloatingIcon?: boolean; 175 176 /** 177 * Notification label. 178 * 179 * @type { ?string } 180 * @syscap SystemCapability.Notification.Notification 181 * @since 7 182 */ 183 label?: string; 184 185 /** 186 * Notification badge type. 187 * 188 * @type { ?number } 189 * @syscap SystemCapability.Notification.Notification 190 * @since 7 191 */ 192 badgeIconStyle?: number; 193 194 /** 195 * Whether to display the time when the notification is delivered. 196 * 197 * @type { ?boolean } 198 * @syscap SystemCapability.Notification.Notification 199 * @since 7 200 */ 201 showDeliveryTime?: boolean; 202 203 /** 204 * Buttons in the notification. Up to two buttons are allowed. 205 * 206 * @type { ?Array<NotificationActionButton> } 207 * @syscap SystemCapability.Notification.Notification 208 * @since 7 209 */ 210 actionButtons?: Array<NotificationActionButton>; 211 212 /** 213 * Small notification icon. 214 * 215 * @type { ?image.PixelMap } 216 * @syscap SystemCapability.Notification.Notification 217 * @since 7 218 */ 219 smallIcon?: image.PixelMap; 220 221 /** 222 * Large notification icon. 223 * 224 * @type { ?image.PixelMap } 225 * @syscap SystemCapability.Notification.Notification 226 * @since 7 227 */ 228 largeIcon?: image.PixelMap; 229 230 /** 231 * The group information for this notification. 232 * 233 * @type { ?string } 234 * @syscap SystemCapability.Notification.Notification 235 * @since 8 236 */ 237 groupName?: string; 238 239 /** 240 * Read-only name of the package for which a notification is created. 241 * 242 * @type { ?string } 243 * @readonly 244 * @syscap SystemCapability.Notification.Notification 245 * @since 7 246 */ 247 readonly creatorBundleName?: string; 248 249 /** 250 * Read-only UID of the notification creator. 251 * 252 * @type { ?number } 253 * @readonly 254 * @syscap SystemCapability.Notification.Notification 255 * @since 7 256 */ 257 readonly creatorUid?: number; 258 259 /** 260 * Read-only PID of the notification creator. 261 * 262 * @type { ?number } 263 * @readonly 264 * @syscap SystemCapability.Notification.Notification 265 * @since 7 266 */ 267 readonly creatorPid?: number; 268 269 /** 270 * Read-only UserId of the notification creator. 271 * 272 * @type { ?number } 273 * @readonly 274 * @syscap SystemCapability.Notification.Notification 275 * @since 8 276 */ 277 readonly creatorUserId?: number; 278 279 /** 280 * Obtains the classification of this notification. 281 * 282 * @type { ?string } 283 * @syscap SystemCapability.Notification.Notification 284 * @systemapi 285 * @since 7 286 */ 287 classification?: string; 288 289 /** 290 * Obtains the unique hash code of a notification in the current application. 291 * 292 * @type { ?string } 293 * @readonly 294 * @syscap SystemCapability.Notification.Notification 295 * @since 7 296 */ 297 readonly hashCode?: string; 298 299 /** 300 * Whether the notification can be remove. 301 * 302 * @type { ?boolean } 303 * @default true 304 * @syscap SystemCapability.Notification.Notification 305 * @systemapi 306 * @since 8 307 */ 308 isRemoveAllowed?: boolean; 309 310 /** 311 * Notification source. enum SourceType 312 * 313 * @type { ?number } 314 * @syscap SystemCapability.Notification.Notification 315 * @systemapi 316 * @since 8 317 */ 318 readonly source?: number; 319 320 /** 321 * Obtains the template of this notification. 322 * 323 * @type { ?NotificationTemplate } 324 * @syscap SystemCapability.Notification.Notification 325 * @since 8 326 */ 327 template?: NotificationTemplate; 328 329 /** 330 * The options to distributed notification. 331 * 332 * @type { ?DistributedOptions } 333 * @syscap SystemCapability.Notification.Notification 334 * @since 8 335 */ 336 distributedOption?: DistributedOptions; 337 338 /** 339 * The device ID of the notification source. 340 * 341 * @type { ?string } 342 * @syscap SystemCapability.Notification.Notification 343 * @systemapi 344 * @since 8 345 */ 346 readonly deviceId?: string; 347 348 /** 349 * Obtains the set of identifiers for the notification. 350 * 351 * @type { ?NotificationFlags } 352 * @syscap SystemCapability.Notification.Notification 353 * @since 8 354 */ 355 readonly notificationFlags?: NotificationFlags; 356 357 /** 358 * WantAgent instance to which the notification will be redirected when removing notification. 359 * 360 * @type { ?WantAgent } 361 * @syscap SystemCapability.Notification.Notification 362 * @since 9 363 */ 364 removalWantAgent?: WantAgent; 365 366 /** 367 * Number of notifications displayed on the app icon. 368 * 369 * @type { ?number } 370 * @syscap SystemCapability.Notification.Notification 371 * @since 9 372 */ 373 badgeNumber?: number; 374} 375 376/** 377 * Describes distributed options. 378 * 379 * @typedef DistributedOptions 380 * @syscap SystemCapability.Notification.Notification 381 * @since 8 382 */ 383export interface DistributedOptions { 384 /** 385 * Obtains whether is the distributed notification. 386 * 387 * @type { ?boolean } 388 * @default true 389 * @syscap SystemCapability.Notification.Notification 390 * @since 8 391 */ 392 isDistributed?: boolean; 393 394 /** 395 * Obtains the types of devices to which the notification can be synchronized. 396 * 397 * @type { ?Array<string> } 398 * @syscap SystemCapability.Notification.Notification 399 * @since 8 400 */ 401 supportDisplayDevices?: Array<string>; 402 403 /** 404 * Obtains the devices on which notifications can be open. 405 * 406 * @type { ?Array<string> } 407 * @syscap SystemCapability.Notification.Notification 408 * @since 8 409 */ 410 supportOperateDevices?: Array<string>; 411 412 /** 413 * Obtains the remind mode of the notification. enum DeviceRemindType. 414 * 415 * @type { ?number } 416 * @syscap SystemCapability.Notification.Notification 417 * @systemapi 418 * @since 8 419 */ 420 readonly remindType?: number; 421} 422