1# @ohos.reminderAgentManager (Agent-Powered Reminders) 2 3The reminderAgentManager module provides APIs related to agent-powered reminders. When your application is frozen or exits, the timing and notification functions of your application will be taken over by a system service running in the background. You can use the APIs to create scheduled reminders for countdown timers, calendar events, and alarm clocks. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9 10## Modules to Import 11 12```ts 13import { reminderAgentManager } from '@kit.BackgroundTasksKit'; 14``` 15 16## reminderAgentManager.publishReminder 17 18publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>): void 19 20Publishes a reminder. This API uses an asynchronous callback to return the result. 21 22> **NOTE** 23> 24> This API can be called only after the [NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10) permission is obtained. 25> 26> <!--RP1--><!--RP1End--> 27 28**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER 29 30**System capability**: SystemCapability.Notification.ReminderAgent 31 32**Parameters** 33 34 | Name| Type| Mandatory| Description| 35 | -------- | -------- | -------- | -------- | 36 | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.| 37 | callback | AsyncCallback\<number> | Yes| Callback used to return the published reminder's ID.| 38 39**Error codes** 40 41For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 42 43| ID | Error Message| 44| --------- | ------- | 45| 401 | If the input parameter is not valid parameter. | 46| 1700001 | Notification is not enabled. | 47| 1700002 | The number of reminders exceeds the limit. | 48 49**Example** 50```ts 51import { BusinessError } from '@kit.BasicServicesKit'; 52 53let timer: reminderAgentManager.ReminderRequestTimer = { 54 reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, 55 triggerTimeInSeconds: 10 56} 57 58reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => { 59 if (err.code) { 60 console.error("callback err code:" + err.code + " message:" + err.message); 61 } else { 62 console.log("callback, reminderId = " + reminderId); 63 } 64}); 65``` 66 67## reminderAgentManager.publishReminder 68 69publishReminder(reminderReq: ReminderRequest): Promise\<number> 70 71Publishes a reminder. This API uses a promise to return the result. 72 73> **NOTE** 74> 75> This API can be called only after the [NotificationManager.requestEnableNotification](../apis-notification-kit/js-apis-notificationManager.md#notificationmanagerrequestenablenotification10) permission is obtained. 76> 77> <!--RP1--><!--RP1End--> 78 79**Required permissions**: ohos.permission.PUBLISH_AGENT_REMINDER 80 81**System capability**: SystemCapability.Notification.ReminderAgent 82 83**Parameters** 84 | Name| Type| Mandatory| Description| 85 | -------- | -------- | -------- | -------- | 86 | reminderReq | [ReminderRequest](#reminderrequest) | Yes| Request used for publishing the reminder.| 87 88**Return value** 89 | Type| Description| 90 | -------- | -------- | 91 | Promise\<number> | Promise used to return the published reminder ID.| 92 93**Error codes** 94 95For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 96 97| ID | Error Message| 98| --------- | ------- | 99| 401 | If the input parameter is not valid parameter. | 100| 1700001 | Notification is not enabled. | 101| 1700002 | The number of reminders exceeds the limit. | 102 103**Example** 104```ts 105import { BusinessError } from '@kit.BasicServicesKit'; 106 107let timer: reminderAgentManager.ReminderRequestTimer = { 108 reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER, 109 triggerTimeInSeconds: 10 110} 111 112reminderAgentManager.publishReminder(timer).then((reminderId: number) => { 113 console.log("promise, reminderId = " + reminderId); 114}).catch((err: BusinessError) => { 115 console.error("promise err code:" + err.code + " message:" + err.message); 116}); 117``` 118 119 120## reminderAgentManager.cancelReminder 121 122cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void 123 124Cancels a reminder published. This API uses an asynchronous callback to return the result. 125 126**System capability**: SystemCapability.Notification.ReminderAgent 127 128**Parameters** 129 130| Name| Type| Mandatory| Description| 131| -------- | -------- | -------- | -------- | 132| reminderId | number | Yes| ID of the reminder to cancel.| 133| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the reminder is canceled, **err** is **undefined**. Otherwise, **err** is an error object.| 134 135**Error codes** 136 137For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 138 139| ID | Error Message| 140| --------- | ------- | 141| 401 | If the input parameter is not valid parameter. | 142| 1700003 | The reminder does not exist. | 143| 1700004 | The bundle name does not exist. | 144 145**Example** 146 147```ts 148import { BusinessError } from '@kit.BasicServicesKit'; 149 150let reminderId: number = 1; 151reminderAgentManager.cancelReminder(reminderId, (err: BusinessError) => { 152 if (err.code) { 153 console.error("callback err code:" + err.code + " message:" + err.message); 154 } else { 155 console.log("cancelReminder callback"); 156 } 157}); 158``` 159 160## reminderAgentManager.cancelReminder 161 162cancelReminder(reminderId: number): Promise\<void> 163 164Cancels a reminder published. This API uses a promise to return the result. 165 166**System capability**: SystemCapability.Notification.ReminderAgent 167 168**Parameters** 169 170| Name| Type| Mandatory| Description| 171| -------- | -------- | -------- | -------- | 172| reminderId | number | Yes| ID of the reminder to cancel.| 173 174**Return value** 175 176| Type| Description| 177| -------- | -------- | 178| Promise\<void> | Promise that returns no value.| 179 180**Error codes** 181 182For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 183 184| ID | Error Message| 185| --------- | ------- | 186| 401 | If the input parameter is not valid parameter. | 187| 1700003 | The reminder does not exist. | 188| 1700004 | The bundle name does not exist. | 189 190**Example** 191 192```ts 193import { BusinessError } from '@kit.BasicServicesKit'; 194 195let reminderId: number = 1; 196reminderAgentManager.cancelReminder(reminderId).then(() => { 197 console.log("cancelReminder promise"); 198}).catch((err: BusinessError) => { 199 console.error("promise err code:" + err.code + " message:" + err.message); 200}); 201``` 202 203## reminderAgentManager.getValidReminders 204 205getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void 206 207Obtains all valid (not yet expired) reminders set by the current application. This API uses an asynchronous callback to return the result. 208 209> **NOTE** 210> 211> When the preset reminder time arrives, a notification message is displayed in the notification center. The reminder is valid before the user touches the CLOSE button to close the message. 212> 213> For an alarm reminder that repeats every day, the reminder is valid regardless of whether the user touches the CLOSE button. 214 215**System capability**: SystemCapability.Notification.ReminderAgent 216 217**Parameters** 218 219| Name| Type| Mandatory| Description| 220| -------- | -------- | -------- | -------- | 221| callback | AsyncCallback\<Array\<[ReminderRequest](#reminderrequest)>> | Yes| Callback used to return all the valid reminders.| 222 223**Error codes** 224 225For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 226 227| ID | Error Message| 228| --------- | ------- | 229| 401 | If the input parameter is not valid parameter. | 230| 1700004 | The bundle name does not exist. | 231 232**Example** 233 234```ts 235import { BusinessError } from '@kit.BasicServicesKit'; 236 237reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => { 238 if (err.code) { 239 console.error("callback err code:" + err.code + " message:" + err.message); 240 } else { 241 console.log("callback, getValidReminders length = " + reminders.length); 242 for (let i = 0; i < reminders.length; i++) { 243 console.log("getValidReminders = " + reminders[i]); 244 console.log("getValidReminders, reminderType = " + reminders[i].reminderType); 245 const actionButton = reminders[i].actionButton || []; 246 for (let j = 0; j < actionButton.length; j++) { 247 console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title); 248 console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type); 249 } 250 console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName); 251 console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName); 252 console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent?.pkgName); 253 console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent?.abilityName); 254 console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration); 255 console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes); 256 console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval); 257 console.log("getValidReminders, title = " + reminders[i].title); 258 console.log("getValidReminders, content = " + reminders[i].content); 259 console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent); 260 console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent); 261 console.log("getValidReminders, notificationId = " + reminders[i].notificationId); 262 console.log("getValidReminders, slotType = " + reminders[i].slotType); 263 } 264 } 265}); 266``` 267 268## reminderAgentManager.getValidReminders 269 270getValidReminders(): Promise\<Array\<ReminderRequest>> 271 272Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the result. 273 274> **NOTE** 275> 276> When the preset reminder time arrives, a notification message is displayed in the notification center. The reminder is valid before the user touches the CLOSE button to close the message. 277> 278> For an alarm reminder that repeats every day, the reminder is valid regardless of whether the user touches the CLOSE button. 279 280**System capability**: SystemCapability.Notification.ReminderAgent 281 282**Return value** 283 284| Type| Description| 285| -------- | -------- | 286| Promise\<Array\<[ReminderRequest](#reminderrequest)>> | Promise used to return all the valid reminders.| 287 288**Error codes** 289 290For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 291 292| ID | Error Message| 293| --------- | ------- | 294| 401 | If the input parameter is not valid parameter. | 295| 1700004 | The bundle name does not exist. | 296 297**Example** 298 299```ts 300import { BusinessError } from '@kit.BasicServicesKit'; 301 302reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => { 303 console.log("promise, getValidReminders length = " + reminders.length); 304 for (let i = 0; i < reminders.length; i++) { 305 console.log("getValidReminders = " + reminders[i]); 306 console.log("getValidReminders, reminderType = " + reminders[i].reminderType); 307 const actionButton = reminders[i].actionButton || []; 308 for (let j = 0; j < actionButton.length; j++) { 309 console.log("getValidReminders, actionButton.title = " + actionButton[j]?.title); 310 console.log("getValidReminders, actionButton.type = " + actionButton[j]?.type); 311 } 312 console.log("getValidReminders, wantAgent.pkgName = " + reminders[i].wantAgent?.pkgName); 313 console.log("getValidReminders, wantAgent.abilityName = " + reminders[i].wantAgent?.abilityName); 314 console.log("getValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].maxScreenWantAgent?.pkgName); 315 console.log("getValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].maxScreenWantAgent?.abilityName); 316 console.log("getValidReminders, ringDuration = " + reminders[i].ringDuration); 317 console.log("getValidReminders, snoozeTimes = " + reminders[i].snoozeTimes); 318 console.log("getValidReminders, timeInterval = " + reminders[i].timeInterval); 319 console.log("getValidReminders, title = " + reminders[i].title); 320 console.log("getValidReminders, content = " + reminders[i].content); 321 console.log("getValidReminders, expiredContent = " + reminders[i].expiredContent); 322 console.log("getValidReminders, snoozeContent = " + reminders[i].snoozeContent); 323 console.log("getValidReminders, notificationId = " + reminders[i].notificationId); 324 console.log("getValidReminders, slotType = " + reminders[i].slotType); 325 } 326}).catch((err: BusinessError) => { 327 console.error("promise err code:" + err.code + " message:" + err.message); 328}); 329``` 330 331## reminderAgentManager.cancelAllReminders 332 333cancelAllReminders(callback: AsyncCallback\<void>): void 334 335Cancels all reminders set by the current application. This API uses an asynchronous callback to return the result. 336 337**System capability**: SystemCapability.Notification.ReminderAgent 338 339**Parameters** 340 341| Name| Type| Mandatory| Description| 342| -------- | -------- | -------- | -------- | 343| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If all the reminders are canceled, **err** is **undefined**. Otherwise, **err** is an error object. | 344 345**Error codes** 346 347For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 348 349| ID | Error Message| 350| --------- | ------- | 351| 401 | If the input parameter is not valid parameter. | 352| 1700004 | The bundle name does not exist. | 353 354**Example** 355 356```ts 357import { BusinessError } from '@kit.BasicServicesKit'; 358 359reminderAgentManager.cancelAllReminders((err: BusinessError) =>{ 360 if (err.code) { 361 console.error("callback err code:" + err.code + " message:" + err.message); 362 } else { 363 console.log("cancelAllReminders callback") 364 } 365}); 366``` 367 368## reminderAgentManager.cancelAllReminders 369 370cancelAllReminders(): Promise\<void> 371 372Cancels all reminders set by the current application. This API uses a promise to return the result. 373 374**System capability**: SystemCapability.Notification.ReminderAgent 375 376**Return value** 377 378| Type| Description| 379| -------- | -------- | 380| Promise\<void> | Promise that returns no value.| 381 382**Error codes** 383 384For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md). 385 386| ID | Error Message| 387| --------- | ------- | 388| 401 | If the input parameter is not valid parameter. | 389| 1700004 | The bundle name does not exist. | 390 391**Example** 392 393```ts 394import { BusinessError } from '@kit.BasicServicesKit'; 395 396reminderAgentManager.cancelAllReminders().then(() => { 397 console.log("cancelAllReminders promise") 398}).catch((err: BusinessError) => { 399 console.error("promise err code:" + err.code + " message:" + err.message); 400}); 401``` 402 403 404## reminderAgentManager.addNotificationSlot 405 406addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): void 407 408Adds a notification slot. This API uses an asynchronous callback to return the result. 409 410**System capability**: SystemCapability.Notification.ReminderAgent 411 412**Parameters** 413 414| Name| Type| Mandatory| Description| 415| -------- | -------- | -------- | -------- | 416| slot | [NotificationSlot](../apis-notification-kit/js-apis-inner-notification-notificationSlot.md#notificationslot) | Yes| notificationManager\.slot instance. Only **notificationType** can be set.| 417| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the notification slot is added, **err** is **undefined**. Otherwise, **err** is an error object.| 418 419**Error codes** 420 421For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 422 423| ID| Error Message | 424| -------- | ---------------------------------------------- | 425| 401 | If the input parameter is not valid parameter. | 426 427**Example** 428 429```ts 430import { notificationManager } from '@kit.NotificationKit'; 431import { BusinessError } from '@kit.BasicServicesKit'; 432 433let mySlot: notificationManager.NotificationSlot = { 434 notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION 435} 436 437reminderAgentManager.addNotificationSlot(mySlot, (err: BusinessError) => { 438 if (err.code) { 439 console.error("callback err code:" + err.code + " message:" + err.message); 440 } else { 441 console.log("addNotificationSlot callback"); 442 } 443}); 444``` 445 446 447## reminderAgentManager.addNotificationSlot 448 449addNotificationSlot(slot: NotificationSlot): Promise\<void> 450 451Adds a notification slot. This API uses a promise to return the result. 452 453**System capability**: SystemCapability.Notification.ReminderAgent 454 455**Parameters** 456 457| Name| Type| Mandatory| Description| 458| -------- | -------- | -------- | -------- | 459| slot | [NotificationSlot](../apis-notification-kit/js-apis-inner-notification-notificationSlot.md#notificationslot) | Yes| notificationManager\.slot instance. Only **notificationType** can be set.| 460 461**Return value** 462 463| Type| Description| 464| -------- | -------- | 465| Promise\<void> | Promise that returns no value.| 466 467**Error codes** 468 469For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 470 471| ID| Error Message | 472| -------- | ---------------------------------------------- | 473| 401 | If the input parameter is not valid parameter. | 474 475**Example** 476 477```ts 478import { notificationManager } from '@kit.NotificationKit'; 479import { BusinessError } from '@kit.BasicServicesKit'; 480 481let mySlot: notificationManager.NotificationSlot = { 482 notificationType: notificationManager.SlotType.SOCIAL_COMMUNICATION 483} 484reminderAgentManager.addNotificationSlot(mySlot).then(() => { 485 console.log("addNotificationSlot promise"); 486}).catch((err: BusinessError) => { 487 console.error("promise err code:" + err.code + " message:" + err.message); 488}); 489``` 490 491 492## reminderAgentManager.removeNotificationSlot 493 494removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\<void>): void 495 496Removes a notification slot. This API uses an asynchronous callback to return the result. 497 498**System capability**: SystemCapability.Notification.ReminderAgent 499 500**Parameters** 501 502| Name| Type| Mandatory| Description| 503| -------- | -------- | -------- | -------- | 504| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.| 505| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the notification slot is removed, **err** is **undefined**. Otherwise, **err** is an error object.| 506 507**Error codes** 508 509For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 510 511| ID| Error Message | 512| -------- | ---------------------------------------------- | 513| 401 | If the input parameter is not valid parameter. | 514 515**Example** 516 517```ts 518import { notificationManager } from '@kit.NotificationKit'; 519import { BusinessError } from '@kit.BasicServicesKit'; 520 521reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION, 522 (err: BusinessError) => { 523 if (err.code) { 524 console.error("callback err code:" + err.code + " message:" + err.message); 525 } else { 526 console.log("removeNotificationSlot callback"); 527 } 528}); 529``` 530 531 532## reminderAgentManager.removeNotificationSlot 533 534removeNotificationSlot(slotType: notification.SlotType): Promise\<void> 535 536Removes a notification slot. This API uses a promise to return the result. 537 538**System capability**: SystemCapability.Notification.ReminderAgent 539 540**Parameters** 541 542| Name| Type| Mandatory| Description| 543| -------- | -------- | -------- | -------- | 544| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notification.md#slottype) | Yes| Type of the notification slot to remove.| 545 546**Return value** 547 548| Type| Description| 549| -------- | -------- | 550| Promise\<void> | Promise that returns no value.| 551 552**Error codes** 553 554For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 555 556| ID| Error Message | 557| -------- | ---------------------------------------------- | 558| 401 | If the input parameter is not valid parameter. | 559 560**Example** 561 562```ts 563import { notificationManager } from '@kit.NotificationKit'; 564import { BusinessError } from '@kit.BasicServicesKit'; 565 566reminderAgentManager.removeNotificationSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => { 567 console.log("removeNotificationSlot promise"); 568}).catch((err: BusinessError) => { 569 console.error("promise err code:" + err.code + " message:" + err.message); 570}); 571``` 572 573## reminderAgentManager.getAllValidReminders<sup>12+</sup> 574 575getAllValidReminders(): Promise\<Array\<ReminderInfo>> 576 577Obtains all valid (not yet expired) reminders set by the current application. This API uses a promise to return the result. 578 579> **NOTE** 580> 581> When the preset reminder time arrives, a notification message is displayed in the notification center. The reminder is valid before the user touches the CLOSE button to close the message. 582> 583> For an alarm reminder that repeats every day, the reminder is valid regardless of whether the user touches the CLOSE button. 584 585**System capability**: SystemCapability.Notification.ReminderAgent 586 587**Return value** 588 589| Type | Description | 590| ------------------------------------------------- | ------------------------------------------------------------ | 591| Promise\<Array\<[ReminderInfo](#reminderinfo12)>> | Promise used to return all the valid reminders.| 592 593**Error codes** 594 595For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 596 597| ID| Error Message | 598| -------- | ------------------ | 599| 201 | Permission denied. | 600 601**Example** 602 603```ts 604import { BusinessError } from '@kit.BasicServicesKit'; 605 606reminderAgentManager.getAllValidReminders().then((reminders: Array<reminderAgentManager.ReminderInfo>) => { 607 console.log("promise, getAllValidReminders length = " + reminders.length); 608 for (let i = 0; i < reminders.length; i++) { 609 console.log("getAllValidReminders, reminderId = " + reminders[i].reminderId); 610 console.log("getAllValidReminders, reminderType = " + reminders[i].reminderReq.reminderType); 611 const actionButton = reminders[i].reminderReq.actionButton || []; 612 for (let j = 0; j < actionButton.length; j++) { 613 console.log("getAllValidReminders, actionButton.title = " + actionButton[j]?.title); 614 console.log("getAllValidReminders, actionButton.type = " + actionButton[j]?.type); 615 } 616 console.log("getAllValidReminders, wantAgent.pkgName = " + reminders[i].reminderReq.wantAgent?.pkgName); 617 console.log("getAllValidReminders, wantAgent.abilityName = " + reminders[i].reminderReq.wantAgent?.abilityName); 618 console.log("getAllValidReminders, maxScreenWantAgent.pkgName = " + reminders[i].reminderReq.maxScreenWantAgent?.pkgName); 619 console.log("getAllValidReminders, maxScreenWantAgent.abilityName = " + reminders[i].reminderReq.maxScreenWantAgent?.abilityName); 620 console.log("getAllValidReminders, ringDuration = " + reminders[i].reminderReq.ringDuration); 621 console.log("getAllValidReminders, snoozeTimes = " + reminders[i].reminderReq.snoozeTimes); 622 console.log("getAllValidReminders, timeInterval = " + reminders[i].reminderReq.timeInterval); 623 console.log("getAllValidReminders, title = " + reminders[i].reminderReq.title); 624 console.log("getAllValidReminders, content = " + reminders[i].reminderReq.content); 625 console.log("getAllValidReminders, expiredContent = " + reminders[i].reminderReq.expiredContent); 626 console.log("getAllValidReminders, snoozeContent = " + reminders[i].reminderReq.snoozeContent); 627 console.log("getAllValidReminders, notificationId = " + reminders[i].reminderReq.notificationId); 628 console.log("getAllValidReminders, slotType = " + reminders[i].reminderReq.slotType); 629 } 630}).catch((err: BusinessError) => { 631 console.error("promise err code:" + err.code + " message:" + err.message); 632}); 633``` 634 635## reminderAgentManager.addExcludeDate<sup>12+</sup> 636 637addExcludeDate(reminderId: number, date: Date): Promise\<void> 638 639Adds a date to be excluded for a duplicate calendar event with the specified ID. No reminder is triggered within the date. This API uses a promise to return the result. 640 641**System capability**: SystemCapability.Notification.ReminderAgent 642 643**Parameters** 644 645| Name | Type | Mandatory| Description | 646| ---------- | ------ | ---- | -------------------------------- | 647| reminderId | number | Yes | ID of the duplicate calendar event.| 648| date | Date | Yes | Date to be excluded. | 649 650**Return value** 651 652| Type | Description | 653| -------------- | ------------------------- | 654| Promise\<void> | Promise that returns no value.| 655 656**Error codes** 657 658For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 659 660| ID| Error Message | 661| -------- | ---------------------------------------------- | 662| 201 | Permission denied. | 663| 401 | If the input parameter is not valid parameter. | 664| 1700003 | The reminder does not exist. | 665 666**Example** 667 668```ts 669import { BusinessError } from '@kit.BasicServicesKit'; 670 671let reminderId: number = 1; 672let date = new Date(); 673reminderAgentManager.addExcludeDate(reminderId, date).then(() => { 674 console.log("addExcludeDate promise"); 675}).catch((err: BusinessError) => { 676 console.error("promise err code:" + err.code + " message:" + err.message); 677}); 678``` 679 680## reminderAgentManager.deleteExcludeDates<sup>12+</sup> 681 682deleteExcludeDates(reminderId: number): Promise\<void> 683 684Deletes all excluded dates set for a duplicate calendar event with the specified ID. This API uses a promise to return the result. 685 686**System capability**: SystemCapability.Notification.ReminderAgent 687 688**Parameters** 689 690| Name | Type | Mandatory| Description | 691| ---------- | ------ | ---- | -------------------------------- | 692| reminderId | number | Yes | ID of the duplicate calendar event.| 693 694**Return value** 695 696| Type | Description | 697| -------------- | ------------------------- | 698| Promise\<void> | Promise that returns no value.| 699 700**Error codes** 701 702For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 703 704| ID| Error Message | 705| -------- | ---------------------------- | 706| 201 | Permission denied. | 707| 1700003 | The reminder does not exist. | 708 709**Example** 710 711```ts 712import { BusinessError } from '@kit.BasicServicesKit'; 713 714let reminderId: number = 1; 715reminderAgentManager.deleteExcludeDates(reminderId).then(() => { 716 console.log("deleteExcludeDates promise"); 717}).catch((err: BusinessError) => { 718 console.error("promise err code:" + err.code + " message:" + err.message); 719}); 720``` 721 722## reminderAgentManager.getExcludeDates<sup>12+</sup> 723 724getExcludeDates(reminderId: number): Promise\<Array\<Date>> 725 726Obtains all excluded dates set for a duplicate calendar event with the specified ID. This API uses a promise to return the result. 727 728**System capability**: SystemCapability.Notification.ReminderAgent 729 730**Parameters** 731 732| Name | Type | Mandatory| Description | 733| ---------- | ------ | ---- | -------------------------------- | 734| reminderId | number | Yes | ID of the duplicate calendar event.| 735 736**Return value** 737 738| Type | Description | 739| ---------------------- | --------------------------------- | 740| Promise\<Array\<Date>> | Promise used to return all the excluded dates.| 741 742**Error codes** 743 744For details about the error codes, see [reminderAgentManager Error Codes](errorcode-reminderAgentManager.md) and [Universal Error Codes](../errorcode-universal.md). 745 746| ID| Error Message | 747| -------- | ---------------------------- | 748| 201 | Permission denied. | 749| 1700003 | The reminder does not exist. | 750 751**Example** 752 753```ts 754import { BusinessError } from '@kit.BasicServicesKit'; 755 756let reminderId: number = 1; 757reminderAgentManager.getExcludeDates(reminderId).then((dates) => { 758 console.log("getExcludeDates promise length: " + dates.length); 759 for (let i = 0; i < dates.length; i++) { 760 console.log("getExcludeDates promise date is: " + dates[i].toString()); 761 } 762}).catch((err: BusinessError) => { 763 console.error("promise err code:" + err.code + " message:" + err.message); 764}); 765``` 766 767## ActionButtonType 768 769Enumerates the button types. 770 771**System capability**: SystemCapability.Notification.ReminderAgent 772 773| Name| Value| Description| 774| -------- | -------- | -------- | 775| ACTION_BUTTON_TYPE_CLOSE | 0 | Button for closing the reminder.| 776| ACTION_BUTTON_TYPE_SNOOZE | 1 | Button for snoozing the reminder.| 777 778## ReminderType 779 780Enumerates the reminder types. 781 782**System capability**: SystemCapability.Notification.ReminderAgent 783 784| Name| Value| Description| 785| -------- | -------- | -------- | 786| REMINDER_TYPE_TIMER | 0 | Countdown reminder.| 787| REMINDER_TYPE_CALENDAR | 1 | Calendar reminder.| 788| REMINDER_TYPE_ALARM | 2 | Alarm reminder.| 789 790 791## ActionButton 792 793Defines the button on the reminder displayed. 794 795**System capability**: SystemCapability.Notification.ReminderAgent 796 797| Name| Type| Mandatory| Description| 798| -------- | -------- | -------- | -------- | 799| title | string | Yes| Text on the button.| 800| titleResource<sup>11+</sup> | string | No| Resource ID of the title. This parameter is used to read the title information after the system language is switched.| 801| type | [ActionButtonType](#actionbuttontype) | Yes| Button type.| 802 803 804## WantAgent 805 806Defines the information about the redirected-to ability. 807 808**System capability**: SystemCapability.Notification.ReminderAgent 809 810 811| Name| Type| Mandatory| Description| 812| -------- | -------- | -------- | -------- | 813| pkgName | string | Yes| Name of the target package.| 814| abilityName | string | Yes| Name of the target ability.| 815| parameters<sup>12+</sup> | Record\<string, Object> | No| Parameters to be transferred to the target.| 816| uri<sup>12+</sup> | string | No| URI of the target ability.| 817 818 819## MaxScreenWantAgent 820 821Provides the information about the ability that is started automatically and displayed in full-screen mode when the reminder arrives. This API is reserved. 822 823**System capability**: SystemCapability.Notification.ReminderAgent 824 825| Name| Type| Mandatory| Description| 826| -------- | -------- | -------- | -------- | 827| pkgName | string | Yes| Name of the target package. (If the device is in use, only a notification banner is displayed.)| 828| abilityName | string | Yes| Name of the target ability. (If the device is in use, only a notification banner is displayed.)| 829 830 831## ReminderRequest 832 833Defines the request for publishing a reminder. 834 835**System capability**: SystemCapability.Notification.ReminderAgent 836 837| Name| Type| Mandatory| Description| 838| -------- | -------- | -------- | -------- | 839| reminderType | [ReminderType](#remindertype) | Yes| Type of the reminder.| 840| actionButton | [[ActionButton?, ActionButton?, ActionButton?]](#actionbutton) | No| Buttons displayed for the reminder notification.<br>- For common applications, a maximum of two buttons are supported.<br>- For system applications, a maximum of two buttons are supported in API version 9, and a maximum of three buttons are supported in API version 10 and later versions.| 841| wantAgent | [WantAgent](#wantagent) | No| Information about the ability that is redirected to when the reminder is clicked.| 842| maxScreenWantAgent | [MaxScreenWantAgent](#maxscreenwantagent) | No| Information about the ability that is started automatically and displayed in full-screen mode when the reminder arrives. If the device is in use, only a notification banner is displayed.<br> This API is reserved.| 843| ringDuration | number | No| Ringing duration, in seconds. The default value is **1**.| 844| snoozeTimes | number | No| Number of reminder snooze times. The default value is **0**. (It is not applicable to countdown reminders.)| 845| timeInterval | number | No| Reminder snooze interval, in seconds. The minimum value is 5 minutes. (It is not applicable to countdown reminders.)| 846| title | string | No| Reminder title.| 847| content | string | No| Reminder content.| 848| expiredContent | string | No| Content to be displayed after the reminder expires.| 849| snoozeContent | string | No| Content to be displayed when the reminder is snoozing. (It is not applicable to countdown reminders.)| 850| notificationId | number | No| Notification ID used by the reminder. You must pass in a notification ID. If there are reminders with the same notification ID, the later one will overwrite the earlier one.| 851| groupId<sup>11+</sup> | string | No| Group ID used for the reminder. If "Don't ask again" or similar information is selected for the reminder, other reminders with the same group ID are also canceled.| 852| slotType | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | No| Type of the slot used by the reminder.| 853| tapDismissed<sup>10+</sup> | boolean | No| Whether the reminder is automatically cleared. For details, see [NotificationRequest.tapDismissed](../apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest). | 854| autoDeletedTime<sup>10+</sup> | number | No| Time when the reminder is automatically cleared. For details, see [NotificationRequest.autoDeletedTime](../apis-notification-kit/js-apis-inner-notification-notificationRequest.md#notificationrequest).| 855| snoozeSlotType<sup>11+</sup> | [notification.SlotType](../apis-notification-kit/js-apis-notificationManager.md#slottype) | No| Type of the slot used by the reminder. (It is not applicable to countdown reminders.)| 856| customRingUri<sup>11+</sup> | string | No| URI of the custom prompt tone.| 857 858## ReminderRequestCalendar 859 860ReminderRequestCalendar extends ReminderRequest 861 862Defines a reminder for a calendar event. 863 864**System capability**: SystemCapability.Notification.ReminderAgent 865 866| Name| Type| Mandatory| Description| 867| -------- | -------- | -------- | -------- | 868| dateTime | [LocalDateTime](#localdatetime) | Yes| Reminder time.| 869| repeatMonths | Array\<number> | No| Month in which the reminder repeats.| 870| repeatDays | Array\<number> | No| Date on which the reminder repeats.| 871| daysOfWeek<sup>11+</sup> | Array\<number> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.| 872| endDateTime<sup>12+</sup> | [LocalDateTime](#localdatetime) | No| End time of the reminder.| 873 874 875## ReminderRequestAlarm 876 877ReminderRequestAlarm extends ReminderRequest 878 879Defines a reminder for an alarm. 880 881**System capability**: SystemCapability.Notification.ReminderAgent 882 883| Name| Type| Mandatory| Description| 884| -------- | -------- | -------- | -------- | 885| hour | number | Yes| Hour portion of the reminder time.| 886| minute | number | Yes| Minute portion of the reminder time.| 887| daysOfWeek | Array\<number> | No| Days of a week when the reminder repeats. The value ranges from 1 to 7, corresponding to the data from Monday to Sunday.| 888 889 890## ReminderRequestTimer 891 892ReminderRequestTimer extends ReminderRequest 893 894Defines a reminder for a scheduled timer. 895 896**System capability**: SystemCapability.Notification.ReminderAgent 897 898| Name| Type| Mandatory| Description| 899| -------- | -------- | -------- | -------- | 900| triggerTimeInSeconds | number | Yes| Number of seconds in the countdown timer.| 901 902 903## LocalDateTime 904 905Defines the time information for a calendar reminder. 906 907**System capability**: SystemCapability.Notification.ReminderAgent 908 909| Name| Type| Mandatory| Description| 910| -------- | -------- | -------- | -------- | 911| year | number | Yes| Year.| 912| month | number | Yes| Month. The value ranges from 1 to 12.| 913| day | number | Yes| Day. The value ranges from 1 to 31.| 914| hour | number | Yes| Hour. The value ranges from 0 to 23.| 915| minute | number | Yes| Minute. The value ranges from 0 to 59.| 916| second | number | No| Second. The value ranges from 0 to 59.| 917 918## ReminderInfo<sup>12+</sup> 919 920Defines the reminder information. 921 922**System capability**: SystemCapability.Notification.ReminderAgent 923 924| Name | Type | Read Only| Optional| Description | 925| ----------- | ----------------------------------- | ---- | ---- | --------------------- | 926| reminderId | number | No | No | ID of the reminder.| 927| reminderReq | [ReminderRequest](#reminderrequest) | No | No | Request used for publishing the reminder. | 928