1/* 2 * Copyright (c) 2021-2022 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 { AsyncCallback } from './basic'; 17import notification from './@ohos.notification'; 18import { NotificationSlot } from './notification/notificationSlot'; 19 20/** 21 * Providers static methods for managing reminders, including publishing or canceling a reminder. 22 * adding or removing a notification slot, and obtaining or cancelling all reminders of the current application. 23 * 24 * @since 7 25 * @syscap SystemCapability.Notification.ReminderAgent 26 * @deprecated since 9 27 * @useinstead reminderAgentManager 28 */ 29declare namespace reminderAgent { 30 /** 31 * Publishes a scheduled reminder. 32 * 33 * @since 7 34 * @syscap SystemCapability.Notification.ReminderAgent 35 * @permission ohos.permission.PUBLISH_AGENT_REMINDER 36 * @param reminderReq Indicates the reminder instance to publish. 37 * @param callback Indicates the callback function. 38 * @returns reminder id. 39 * @deprecated since 9 40 * @useinstead reminderAgentManager.publishReminder 41 */ 42 function publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback<number>): void; 43 function publishReminder(reminderReq: ReminderRequest): Promise<number>; 44 45 /** 46 * Cancels a reminder. 47 * 48 * @since 7 49 * @syscap SystemCapability.Notification.ReminderAgent 50 * @param reminderId Indicates the reminder id. 51 * @param callback Indicates the callback function. 52 * @deprecated since 9 53 * @useinstead reminderAgentManager.cancelReminder 54 */ 55 function cancelReminder(reminderId: number, callback: AsyncCallback<void>): void; 56 function cancelReminder(reminderId: number): Promise<void>; 57 58 /** 59 * Obtains all the valid reminders of current application. 60 * 61 * @since 7 62 * @syscap SystemCapability.Notification.ReminderAgent 63 * @param callback Indicates the callback function. 64 * @deprecated since 9 65 * @useinstead reminderAgentManager.getValidReminders 66 */ 67 function getValidReminders(callback: AsyncCallback<Array<ReminderRequest>>): void; 68 function getValidReminders(): Promise<Array<ReminderRequest>>; 69 70 /** 71 * Cancels all the reminders of current application. 72 * 73 * @since 7 74 * @syscap SystemCapability.Notification.ReminderAgent 75 * @param callback Indicates the callback function. 76 * @deprecated since 9 77 * @useinstead reminderAgentManager.cancelAllReminders 78 */ 79 function cancelAllReminders(callback: AsyncCallback<void>): void; 80 function cancelAllReminders(): Promise<void>; 81 82 /** 83 * Add notification slot. 84 * 85 * @since 7 86 * @syscap SystemCapability.Notification.ReminderAgent 87 * @param slot Indicates the slot. 88 * @param callback Indicates the callback function. 89 * @deprecated since 9 90 * @useinstead reminderAgentManager.addNotificationSlot 91 */ 92 function addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback<void>): void; 93 function addNotificationSlot(slot: NotificationSlot): Promise<void>; 94 95 /** 96 * Deletes a created notification slot based on the slot type. 97 * 98 * @since 7 99 * @syscap SystemCapability.Notification.ReminderAgent 100 * @param slotType Indicates the type of the slot. 101 * @param callback Indicates the callback function. 102 * @deprecated since 9 103 * @useinstead reminderAgentManager.removeNotificationSlot 104 */ 105 function removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback<void>): void; 106 function removeNotificationSlot(slotType: notification.SlotType): Promise<void>; 107 108 /** 109 * Declares action button type. 110 * 111 * @since 7 112 * @syscap SystemCapability.Notification.ReminderAgent 113 * @deprecated since 9 114 * @useinstead reminderAgentManager.ActionButtonType 115 */ 116 export enum ActionButtonType { 117 /** 118 * Button for closing the reminder. 119 * @since 7 120 * @syscap SystemCapability.Notification.ReminderAgent 121 * @deprecated since 9 122 * @useinstead reminderAgentManager.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE 123 */ 124 ACTION_BUTTON_TYPE_CLOSE = 0, 125 126 /** 127 * Button for snoozing the reminder. 128 * @since 7 129 * @syscap SystemCapability.Notification.ReminderAgent 130 * @deprecated since 9 131 * @useinstead reminderAgentManager.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE 132 */ 133 ACTION_BUTTON_TYPE_SNOOZE = 1 134 } 135 136 /** 137 * Declares reminder type. 138 * 139 * @since 7 140 * @syscap SystemCapability.Notification.ReminderAgent 141 * @deprecated since 9 142 * @useinstead reminderAgentManager.ReminderType 143 */ 144 export enum ReminderType { 145 /** 146 * Countdown reminder. 147 * @since 7 148 * @syscap SystemCapability.Notification.ReminderAgent 149 * @deprecated since 9 150 * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER 151 */ 152 REMINDER_TYPE_TIMER = 0, 153 154 /** 155 * Calendar reminder. 156 * @since 7 157 * @syscap SystemCapability.Notification.ReminderAgent 158 * @deprecated since 9 159 * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_CALENDAR 160 */ 161 REMINDER_TYPE_CALENDAR = 1, 162 163 /** 164 * Alarm reminder. 165 * @since 7 166 * @syscap SystemCapability.Notification.ReminderAgent 167 * @deprecated since 9 168 * @useinstead reminderAgentManager.ReminderType.REMINDER_TYPE_ALARM 169 */ 170 REMINDER_TYPE_ALARM = 2 171 } 172 173 /** 174 * Action button information. The button will show on displayed reminder. 175 * 176 * @since 7 177 * @syscap SystemCapability.Notification.ReminderAgent 178 * @deprecated since 9 179 * @useinstead reminderAgentManager.ActionButton 180 */ 181 interface ActionButton { 182 /** 183 * Text on the button. 184 * @since 7 185 * @syscap SystemCapability.Notification.ReminderAgent 186 * @deprecated since 9 187 * @useinstead reminderAgentManager.ActionButton.title 188 */ 189 title: string; 190 191 /** 192 * Button type. 193 * @since 7 194 * @syscap SystemCapability.Notification.ReminderAgent 195 * @deprecated since 9 196 * @useinstead reminderAgentManager.ActionButton.type 197 */ 198 type: ActionButtonType; 199 } 200 201 /** 202 * Want agent information. 203 * It will switch to target ability when you click the displayed reminder. 204 * 205 * @since 7 206 * @syscap SystemCapability.Notification.ReminderAgent 207 * @deprecated since 9 208 * @useinstead reminderAgentManager.WantAgent 209 */ 210 interface WantAgent { 211 /** 212 * Name of the package redirected to when the reminder notification is clicked. 213 * @since 7 214 * @syscap SystemCapability.Notification.ReminderAgent 215 * @deprecated since 9 216 * @useinstead reminderAgentManager.WantAgent.pkgName 217 */ 218 pkgName: string; 219 220 /** 221 * Name of the ability that is redirected to when the reminder notification is clicked. 222 * @since 7 223 * @syscap SystemCapability.Notification.ReminderAgent 224 * @deprecated since 9 225 * @useinstead reminderAgentManager.WantAgent.abilityName 226 */ 227 abilityName: string; 228 } 229 230 /** 231 * Max screen want agent information. 232 * 233 * @since 7 234 * @syscap SystemCapability.Notification.ReminderAgent 235 * @deprecated since 9 236 * @useinstead reminderAgentManager.MaxScreenWantAgent 237 */ 238 interface MaxScreenWantAgent { 239 /** 240 * Name of the package that is automatically started when the reminder arrives and the device is not in use. 241 * @since 7 242 * @syscap SystemCapability.Notification.ReminderAgent 243 * @deprecated since 9 244 * @useinstead reminderAgentManager.MaxScreenWantAgent.pkgName 245 */ 246 pkgName: string; 247 248 /** 249 * Name of the ability that is automatically started when the reminder arrives and the device is not in use. 250 * @since 7 251 * @syscap SystemCapability.Notification.ReminderAgent 252 * @deprecated since 9 253 * @useinstead reminderAgentManager.MaxScreenWantAgent.abilityName 254 */ 255 abilityName: string; 256 } 257 258 /** 259 * Reminder Common information. 260 * 261 * @since 7 262 * @syscap SystemCapability.Notification.ReminderAgent 263 * @deprecated since 9 264 * @useinstead reminderAgentManager.ReminderRequest 265 */ 266 interface ReminderRequest { 267 /** 268 * Type of the reminder. 269 * @since 7 270 * @syscap SystemCapability.Notification.ReminderAgent 271 * @deprecated since 9 272 * @useinstead reminderAgentManager.ReminderRequest.reminderType 273 */ 274 reminderType: ReminderType; 275 276 /** 277 * Action button displayed on the reminder notification. 278 * (The parameter is optional. Up to two buttons are supported). 279 * @since 7 280 * @syscap SystemCapability.Notification.ReminderAgent 281 * @deprecated since 9 282 * @useinstead reminderAgentManager.ReminderRequest.actionButton 283 */ 284 actionButton?: [ActionButton?, ActionButton?]; 285 286 /** 287 * Information about the ability that is redirected to when the notification is clicked. 288 * @since 7 289 * @syscap SystemCapability.Notification.ReminderAgent 290 * @deprecated since 9 291 * @useinstead reminderAgentManager.ReminderRequest.wantAgent 292 */ 293 wantAgent?: WantAgent; 294 295 /** 296 * Information about the ability that is automatically started when the reminder arrives. 297 * If the device is in use, a notification will be displayed. 298 * @since 7 299 * @syscap SystemCapability.Notification.ReminderAgent 300 * @deprecated since 9 301 * @useinstead reminderAgentManager.ReminderRequest.maxScreenWantAgent 302 */ 303 maxScreenWantAgent?: MaxScreenWantAgent; 304 305 /** 306 * Ringing duration. 307 * @since 7 308 * @syscap SystemCapability.Notification.ReminderAgent 309 * @deprecated since 9 310 * @useinstead reminderAgentManager.ReminderRequest.ringDuration 311 */ 312 ringDuration?: number; 313 314 /** 315 * Number of reminder snooze times. 316 * @since 7 317 * @syscap SystemCapability.Notification.ReminderAgent 318 * @deprecated since 9 319 * @useinstead reminderAgentManager.ReminderRequest.snoozeTimes 320 */ 321 snoozeTimes?: number; 322 323 /** 324 * Reminder snooze interval. 325 * @since 7 326 * @syscap SystemCapability.Notification.ReminderAgent 327 * @deprecated since 9 328 * @useinstead reminderAgentManager.ReminderRequest.timeInterval 329 */ 330 timeInterval?: number; 331 332 /** 333 * Reminder title. 334 * @since 7 335 * @syscap SystemCapability.Notification.ReminderAgent 336 * @deprecated since 9 337 * @useinstead reminderAgentManager.ReminderRequest.title 338 */ 339 title?: string; 340 341 /** 342 * Reminder content. 343 * @since 7 344 * @syscap SystemCapability.Notification.ReminderAgent 345 * @deprecated since 9 346 * @useinstead reminderAgentManager.ReminderRequest.content 347 */ 348 content?: string; 349 350 /** 351 * Content to be displayed when the reminder is expired. 352 * @since 7 353 * @syscap SystemCapability.Notification.ReminderAgent 354 * @deprecated since 9 355 * @useinstead reminderAgentManager.ReminderRequest.expiredContent 356 */ 357 expiredContent?: string; 358 359 /** 360 * Content to be displayed when the reminder is snoozing. 361 * @since 7 362 * @syscap SystemCapability.Notification.ReminderAgent 363 * @deprecated since 9 364 * @useinstead reminderAgentManager.ReminderRequest.snoozeContent 365 */ 366 snoozeContent?: string; 367 368 /** 369 * notification id. If there are reminders with the same ID, the later one will overwrite the earlier one. 370 * @since 7 371 * @syscap SystemCapability.Notification.ReminderAgent 372 * @deprecated since 9 373 * @useinstead reminderAgentManager.ReminderRequest.notificationId 374 */ 375 notificationId?: number; 376 377 /** 378 * Type of the slot used by the reminder. 379 * @since 7 380 * @syscap SystemCapability.Notification.ReminderAgent 381 * @deprecated since 9 382 * @useinstead reminderAgentManager.ReminderRequest.slotType 383 */ 384 slotType?: notification.SlotType; 385 } 386 387 /** 388 * @deprecated since 9 389 * @useinstead reminderAgentManager.ReminderRequestCalendar 390 */ 391 interface ReminderRequestCalendar extends ReminderRequest { 392 /** 393 * Reminder time. 394 * @since 7 395 * @syscap SystemCapability.Notification.ReminderAgent 396 * @deprecated since 9 397 * @useinstead reminderAgentManager.ReminderRequestCalendar.dateTime 398 */ 399 dateTime: LocalDateTime; 400 401 /** 402 * Month in which the reminder repeats. 403 * @since 7 404 * @syscap SystemCapability.Notification.ReminderAgent 405 * @deprecated since 9 406 * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatMonths 407 */ 408 repeatMonths?: Array<number>; 409 410 /** 411 * Date on which the reminder repeats. 412 * @since 7 413 * @syscap SystemCapability.Notification.ReminderAgent 414 * @deprecated since 9 415 * @useinstead reminderAgentManager.ReminderRequestCalendar.repeatDays 416 */ 417 repeatDays?: Array<number>; 418 } 419 420 /** 421 * Alarm reminder information. 422 * 423 * @since 7 424 * @syscap SystemCapability.Notification.ReminderAgent 425 * @deprecated since 9 426 * @useinstead reminderAgentManager.ReminderRequestAlarm 427 */ 428 interface ReminderRequestAlarm extends ReminderRequest { 429 /** 430 * Hour portion of the reminder time. 431 * @since 7 432 * @syscap SystemCapability.Notification.ReminderAgent 433 * @deprecated since 9 434 * @useinstead reminderAgentManager.ReminderRequestAlarm.hour 435 */ 436 hour: number; 437 438 /** 439 * minute portion of the remidner time. 440 * @since 7 441 * @syscap SystemCapability.Notification.ReminderAgent 442 * @deprecated since 9 443 * @useinstead reminderAgentManager.ReminderRequestAlarm.minute 444 */ 445 minute: number; 446 447 /** 448 * Days of a week when the reminder repeates. 449 * @since 7 450 * @syscap SystemCapability.Notification.ReminderAgent 451 * @deprecated since 9 452 * @useinstead reminderAgentManager.ReminderRequestAlarm.daysOfWeek 453 */ 454 daysOfWeek?: Array<number>; 455 } 456 457 /** 458 * CountDown reminder information. 459 * 460 * @since 7 461 * @syscap SystemCapability.Notification.ReminderAgent 462 * @deprecated since 9 463 * @useinstead reminderAgentManager.ReminderRequestTimer 464 */ 465 interface ReminderRequestTimer extends ReminderRequest { 466 triggerTimeInSeconds: number; 467 } 468 469 interface LocalDateTime { 470 /** 471 * value of year. 472 * @since 7 473 * @syscap SystemCapability.Notification.ReminderAgent 474 * @deprecated since 9 475 * @useinstead reminderAgentManager.ReminderRequestTimer.year 476 */ 477 year: number; 478 479 /** 480 * value of month. 481 * @since 7 482 * @syscap SystemCapability.Notification.ReminderAgent 483 * @deprecated since 9 484 * @useinstead reminderAgentManager.ReminderRequestTimer.month 485 */ 486 month: number; 487 488 /** 489 * value of day. 490 * @since 7 491 * @syscap SystemCapability.Notification.ReminderAgent 492 * @deprecated since 9 493 * @useinstead reminderAgentManager.ReminderRequestTimer.day 494 */ 495 day: number; 496 497 /** 498 * value of hour. 499 * @since 7 500 * @syscap SystemCapability.Notification.ReminderAgent 501 * @deprecated since 9 502 * @useinstead reminderAgentManager.ReminderRequestTimer.hour 503 */ 504 hour: number; 505 506 /** 507 * value of minute. 508 * @since 7 509 * @syscap SystemCapability.Notification.ReminderAgent 510 * @deprecated since 9 511 * @useinstead reminderAgentManager.ReminderRequestTimer.minute 512 */ 513 minute: number; 514 515 /** 516 * value of second. 517 * @since 7 518 * @syscap SystemCapability.Notification.ReminderAgent 519 * @deprecated since 9 520 * @useinstead reminderAgentManager.ReminderRequestTimer.second 521 */ 522 second?: number; 523 } 524} 525export default reminderAgent; 526