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 type notificationManager from '../@ohos.notificationManager'; 19import type notificationSubscribe from '../@ohos.notificationSubscribe'; 20import { WantAgent } from '../@ohos.wantAgent'; 21import { NotificationContent } from './notificationContent'; 22import { NotificationActionButton } from './notificationActionButton'; 23import { NotificationTemplate } from './notificationTemplate'; 24import { NotificationFlags } from './notificationFlags'; 25import type { BundleOption } from './NotificationCommonDef'; 26 27/** 28 * Defines a NotificationRequest instance. 29 * 30 * @typedef NotificationRequest 31 * @syscap SystemCapability.Notification.Notification 32 * @since 7 33 */ 34export interface NotificationRequest { 35 /** 36 * Notification content. 37 * 38 * @type { NotificationContent } 39 * @syscap SystemCapability.Notification.Notification 40 * @since 7 41 */ 42 content: NotificationContent; 43 44 /** 45 * Notification ID. 46 * 47 * @type { ?number } 48 * @syscap SystemCapability.Notification.Notification 49 * @since 7 50 */ 51 id?: number; 52 53 /** 54 * Notification slot type. 55 * 56 * @type { ?notification.SlotType } 57 * @syscap SystemCapability.Notification.Notification 58 * @since 7 59 * @deprecated since 11 60 * @useinstead NotificationRequest#notificationSlotType 61 */ 62 slotType?: notification.SlotType; 63 64 /** 65 * Notification slot type. 66 * 67 * @type { ?notificationManager.SlotType } 68 * @syscap SystemCapability.Notification.Notification 69 * @since 11 70 */ 71 notificationSlotType?: notificationManager.SlotType; 72 73 /** 74 * Whether the notification is an ongoing notification. 75 * 76 * @type { ?boolean } 77 * @syscap SystemCapability.Notification.Notification 78 * @since 7 79 */ 80 isOngoing?: boolean; 81 82 /** 83 * Whether the notification can be removed. 84 * 85 * @type { ?boolean } 86 * @syscap SystemCapability.Notification.Notification 87 * @since 7 88 */ 89 isUnremovable?: boolean; 90 91 /** 92 * Time when the notification is sent. 93 * 94 * @type { ?number } 95 * @syscap SystemCapability.Notification.Notification 96 * @since 7 97 */ 98 deliveryTime?: number; 99 100 /** 101 * Whether the notification is automatically cleared. 102 * 103 * @type { ?boolean } 104 * @syscap SystemCapability.Notification.Notification 105 * @since 7 106 */ 107 tapDismissed?: boolean; 108 109 /** 110 * Time when the notification is automatically cleared. 111 * 112 * @type { ?number } 113 * @syscap SystemCapability.Notification.Notification 114 * @since 7 115 */ 116 autoDeletedTime?: number; 117 118 /** 119 * WantAgent instance to which the notification will be redirected after being clicked. 120 * 121 * @type { ?WantAgent } 122 * @syscap SystemCapability.Notification.Notification 123 * @since 7 124 */ 125 wantAgent?: WantAgent; 126 127 /** 128 * Extended parameter. 129 * 130 * @type { ?object } 131 * @syscap SystemCapability.Notification.Notification 132 * @since 7 133 */ 134 extraInfo?: { [key: string]: any }; 135 136 /** 137 * Background color of the notification. 138 * 139 * @type { ?number } 140 * @syscap SystemCapability.Notification.Notification 141 * @since 7 142 */ 143 color?: number; 144 145 /** 146 * Whether the notification background color can be enabled. 147 * 148 * @type { ?boolean } 149 * @syscap SystemCapability.Notification.Notification 150 * @since 7 151 */ 152 colorEnabled?: boolean; 153 154 /** 155 * Whether the notification triggers an alert only once. 156 * 157 * @type { ?boolean } 158 * @syscap SystemCapability.Notification.Notification 159 * @since 7 160 */ 161 isAlertOnce?: boolean; 162 163 /** 164 * Whether to display the stopwatch. 165 * 166 * @type { ?boolean } 167 * @syscap SystemCapability.Notification.Notification 168 * @since 7 169 */ 170 isStopwatch?: boolean; 171 172 /** 173 * Whether to display the countdown time. 174 * 175 * @type { ?boolean } 176 * @syscap SystemCapability.Notification.Notification 177 * @since 7 178 */ 179 isCountDown?: boolean; 180 181 /** 182 * Whether the notification is displayed as a floating icon. 183 * 184 * @type { ?boolean } 185 * @syscap SystemCapability.Notification.Notification 186 * @since 7 187 */ 188 isFloatingIcon?: boolean; 189 190 /** 191 * Notification label. 192 * 193 * @type { ?string } 194 * @syscap SystemCapability.Notification.Notification 195 * @since 7 196 */ 197 label?: string; 198 199 /** 200 * Notification badge type. 201 * 202 * @type { ?number } 203 * @syscap SystemCapability.Notification.Notification 204 * @since 7 205 */ 206 badgeIconStyle?: number; 207 208 /** 209 * Whether to display the time when the notification is delivered. 210 * 211 * @type { ?boolean } 212 * @syscap SystemCapability.Notification.Notification 213 * @since 7 214 */ 215 showDeliveryTime?: boolean; 216 217 /** 218 * Buttons in the notification. Up to two buttons are allowed. 219 * 220 * @type { ?Array<NotificationActionButton> } 221 * @syscap SystemCapability.Notification.Notification 222 * @since 7 223 */ 224 actionButtons?: Array<NotificationActionButton>; 225 226 /** 227 * Small notification icon. 228 * 229 * @type { ?image.PixelMap } 230 * @syscap SystemCapability.Notification.Notification 231 * @since 7 232 */ 233 smallIcon?: image.PixelMap; 234 235 /** 236 * Large notification icon. 237 * 238 * @type { ?image.PixelMap } 239 * @syscap SystemCapability.Notification.Notification 240 * @since 7 241 */ 242 largeIcon?: image.PixelMap; 243 244 /** 245 * Overlay notification icon. 246 * 247 * @type { ?image.PixelMap } 248 * @syscap SystemCapability.Notification.Notification 249 * @systemapi 250 * @since 11 251 */ 252 overlayIcon?: image.PixelMap; 253 254 /** 255 * The group information for this notification. 256 * 257 * @type { ?string } 258 * @syscap SystemCapability.Notification.Notification 259 * @since 8 260 */ 261 groupName?: string; 262 263 /** 264 * Read-only name of the package for which a notification is created. 265 * 266 * @type { ?string } 267 * @readonly 268 * @syscap SystemCapability.Notification.Notification 269 * @since 7 270 */ 271 readonly creatorBundleName?: string; 272 273 /** 274 * Read-only UID of the notification creator. 275 * 276 * @type { ?number } 277 * @readonly 278 * @syscap SystemCapability.Notification.Notification 279 * @since 7 280 */ 281 readonly creatorUid?: number; 282 283 /** 284 * Read-only PID of the notification creator. 285 * 286 * @type { ?number } 287 * @readonly 288 * @syscap SystemCapability.Notification.Notification 289 * @since 7 290 */ 291 readonly creatorPid?: number; 292 293 /** 294 * Read-only UserId of the notification creator. 295 * 296 * @type { ?number } 297 * @readonly 298 * @syscap SystemCapability.Notification.Notification 299 * @since 8 300 */ 301 readonly creatorUserId?: number; 302 303 /** 304 * Obtains the classification of this notification. 305 * 306 * @type { ?string } 307 * @syscap SystemCapability.Notification.Notification 308 * @systemapi 309 * @since 7 310 */ 311 classification?: string; 312 313 /** 314 * Obtains the unique hash code of a notification in the current application. 315 * 316 * @type { ?string } 317 * @readonly 318 * @syscap SystemCapability.Notification.Notification 319 * @since 7 320 */ 321 readonly hashCode?: string; 322 323 /** 324 * Whether the notification can be remove. 325 * 326 * @type { ?boolean } 327 * @default true 328 * @syscap SystemCapability.Notification.Notification 329 * @systemapi 330 * @since 8 331 */ 332 /** 333 * Whether the notification can be remove. 334 * 335 * @permission ohos.permission.SET_UNREMOVABLE_NOTIFICATION 336 * @type { ?boolean } 337 * @default true 338 * @syscap SystemCapability.Notification.Notification 339 * @systemapi 340 * @since 11 341 */ 342 isRemoveAllowed?: boolean; 343 344 /** 345 * Notification source. enum SourceType 346 * 347 * @type { ?number } 348 * @syscap SystemCapability.Notification.Notification 349 * @systemapi 350 * @since 8 351 */ 352 readonly source?: number; 353 354 /** 355 * Obtains the template of this notification. 356 * 357 * @type { ?NotificationTemplate } 358 * @syscap SystemCapability.Notification.Notification 359 * @since 8 360 */ 361 template?: NotificationTemplate; 362 363 /** 364 * The options to distributed notification. 365 * 366 * @type { ?DistributedOptions } 367 * @syscap SystemCapability.Notification.Notification 368 * @since 8 369 */ 370 distributedOption?: DistributedOptions; 371 372 /** 373 * The device ID of the notification source. 374 * 375 * @type { ?string } 376 * @syscap SystemCapability.Notification.Notification 377 * @systemapi 378 * @since 8 379 */ 380 readonly deviceId?: string; 381 382 /** 383 * Obtains the set of identifiers for the notification. 384 * 385 * @type { ?NotificationFlags } 386 * @syscap SystemCapability.Notification.Notification 387 * @since 8 388 */ 389 readonly notificationFlags?: NotificationFlags; 390 391 /** 392 * WantAgent instance to which the notification will be redirected when removing notification. 393 * 394 * @type { ?WantAgent } 395 * @syscap SystemCapability.Notification.Notification 396 * @since 9 397 */ 398 removalWantAgent?: WantAgent; 399 400 /** 401 * Number of notifications displayed on the app icon. 402 * 403 * @type { ?number } 404 * @syscap SystemCapability.Notification.Notification 405 * @since 9 406 */ 407 badgeNumber?: number; 408} 409 410/** 411 * Describes distributed options. 412 * 413 * @typedef DistributedOptions 414 * @syscap SystemCapability.Notification.Notification 415 * @since 8 416 */ 417export interface DistributedOptions { 418 /** 419 * Obtains whether is the distributed notification. 420 * 421 * @type { ?boolean } 422 * @default true 423 * @syscap SystemCapability.Notification.Notification 424 * @since 8 425 */ 426 isDistributed?: boolean; 427 428 /** 429 * Obtains the types of devices to which the notification can be synchronized. 430 * 431 * @type { ?Array<string> } 432 * @syscap SystemCapability.Notification.Notification 433 * @since 8 434 */ 435 supportDisplayDevices?: Array<string>; 436 437 /** 438 * Obtains the devices on which notifications can be open. 439 * 440 * @type { ?Array<string> } 441 * @syscap SystemCapability.Notification.Notification 442 * @since 8 443 */ 444 supportOperateDevices?: Array<string>; 445 446 /** 447 * Obtains the remind mode of the notification. enum DeviceRemindType. 448 * 449 * @type { ?number } 450 * @syscap SystemCapability.Notification.Notification 451 * @systemapi 452 * @since 8 453 */ 454 readonly remindType?: number; 455} 456 457/** 458 * Describes notification filter. 459 * 460 * @typedef NotificationFilter 461 * @syscap SystemCapability.Notification.Notification 462 * @systemapi 463 * @since 11 464 */ 465export interface NotificationFilter { 466 /** 467 * BundleOption of the notification. 468 * 469 * @type { BundleOption } 470 * @syscap SystemCapability.Notification.Notification 471 * @systemapi 472 * @since 11 473 */ 474 bundle: BundleOption; 475 476 /** 477 * Indicates the label and id of the notification. 478 * 479 * @type { notificationSubscribe.NotificationKey } 480 * @syscap SystemCapability.Notification.Notification 481 * @systemapi 482 * @since 11 483 */ 484 notificationKey: notificationSubscribe.NotificationKey; 485 486 /** 487 * Indicates the additional information filter keys list. 488 * 489 * @type { ?Array<string> } 490 * @syscap SystemCapability.Notification.Notification 491 * @systemapi 492 * @since 11 493 */ 494 extraInfoKeys?: Array<string>; 495} 496 497/** 498 * Describes notification check information. 499 * 500 * @typedef NotificationCheckRequest 501 * @syscap SystemCapability.Notification.Notification 502 * @systemapi 503 * @since 11 504 */ 505export interface NotificationCheckRequest { 506 /** 507 * The notification content type. 508 * 509 * @type { notificationManager.ContentType } 510 * @syscap SystemCapability.Notification.Notification 511 * @systemapi 512 * @since 11 513 */ 514 contentType: notificationManager.ContentType; 515 516 /** 517 * Type of the notification slot.. 518 * 519 * @type { notificationManager.SlotType } 520 * @syscap SystemCapability.Notification.Notification 521 * @systemapi 522 * @since 11 523 */ 524 slotType: notificationManager.SlotType; 525 526 /** 527 * Additional information of the notification. 528 * 529 * @type { Array<string> } 530 * @syscap SystemCapability.Notification.Notification 531 * @systemapi 532 * @since 11 533 */ 534 extraInfoKeys: Array<string>; 535} 536