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